patch_realtek.c 294 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693
  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. #ifdef CONFIG_SND_DEBUG
  74. ALC260_TEST,
  75. #endif
  76. ALC260_AUTO,
  77. ALC260_MODEL_LAST /* last tag */
  78. };
  79. /* ALC262 models */
  80. enum {
  81. ALC262_BASIC,
  82. ALC262_HIPPO,
  83. ALC262_HIPPO_1,
  84. ALC262_FUJITSU,
  85. ALC262_HP_BPC,
  86. ALC262_HP_BPC_D7000_WL,
  87. ALC262_HP_BPC_D7000_WF,
  88. ALC262_BENQ_ED8,
  89. ALC262_AUTO,
  90. ALC262_MODEL_LAST /* last tag */
  91. };
  92. /* ALC861 models */
  93. enum {
  94. ALC861_3ST,
  95. ALC660_3ST,
  96. ALC861_3ST_DIG,
  97. ALC861_6ST_DIG,
  98. ALC861_UNIWILL_M31,
  99. ALC861_TOSHIBA,
  100. ALC861_ASUS,
  101. ALC861_ASUS_LAPTOP,
  102. ALC861_AUTO,
  103. ALC861_MODEL_LAST,
  104. };
  105. /* ALC861-VD models */
  106. enum {
  107. ALC660VD_3ST,
  108. ALC861VD_3ST,
  109. ALC861VD_3ST_DIG,
  110. ALC861VD_6ST_DIG,
  111. ALC861VD_AUTO,
  112. ALC861VD_MODEL_LAST,
  113. };
  114. /* ALC882 models */
  115. enum {
  116. ALC882_3ST_DIG,
  117. ALC882_6ST_DIG,
  118. ALC882_ARIMA,
  119. ALC882_AUTO,
  120. ALC885_MACPRO,
  121. ALC882_MODEL_LAST,
  122. };
  123. /* ALC883 models */
  124. enum {
  125. ALC883_3ST_2ch_DIG,
  126. ALC883_3ST_6ch_DIG,
  127. ALC883_3ST_6ch,
  128. ALC883_6ST_DIG,
  129. ALC883_TARGA_DIG,
  130. ALC883_TARGA_2ch_DIG,
  131. ALC888_DEMO_BOARD,
  132. ALC883_ACER,
  133. ALC883_MEDION,
  134. ALC883_LAPTOP_EAPD,
  135. ALC883_AUTO,
  136. ALC883_MODEL_LAST,
  137. };
  138. /* for GPIO Poll */
  139. #define GPIO_MASK 0x03
  140. struct alc_spec {
  141. /* codec parameterization */
  142. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  143. unsigned int num_mixers;
  144. const struct hda_verb *init_verbs[5]; /* initialization verbs
  145. * don't forget NULL
  146. * termination!
  147. */
  148. unsigned int num_init_verbs;
  149. char *stream_name_analog; /* analog PCM stream */
  150. struct hda_pcm_stream *stream_analog_playback;
  151. struct hda_pcm_stream *stream_analog_capture;
  152. char *stream_name_digital; /* digital PCM stream */
  153. struct hda_pcm_stream *stream_digital_playback;
  154. struct hda_pcm_stream *stream_digital_capture;
  155. /* playback */
  156. struct hda_multi_out multiout; /* playback set-up
  157. * max_channels, dacs must be set
  158. * dig_out_nid and hp_nid are optional
  159. */
  160. /* capture */
  161. unsigned int num_adc_nids;
  162. hda_nid_t *adc_nids;
  163. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  164. /* capture source */
  165. unsigned int num_mux_defs;
  166. const struct hda_input_mux *input_mux;
  167. unsigned int cur_mux[3];
  168. /* channel model */
  169. const struct hda_channel_mode *channel_mode;
  170. int num_channel_mode;
  171. int need_dac_fix;
  172. /* PCM information */
  173. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  174. /* dynamic controls, init_verbs and input_mux */
  175. struct auto_pin_cfg autocfg;
  176. unsigned int num_kctl_alloc, num_kctl_used;
  177. struct snd_kcontrol_new *kctl_alloc;
  178. struct hda_input_mux private_imux;
  179. hda_nid_t private_dac_nids[5];
  180. /* hooks */
  181. void (*init_hook)(struct hda_codec *codec);
  182. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  183. /* for pin sensing */
  184. unsigned int sense_updated: 1;
  185. unsigned int jack_present: 1;
  186. };
  187. /*
  188. * configuration template - to be copied to the spec instance
  189. */
  190. struct alc_config_preset {
  191. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  192. * with spec
  193. */
  194. const struct hda_verb *init_verbs[5];
  195. unsigned int num_dacs;
  196. hda_nid_t *dac_nids;
  197. hda_nid_t dig_out_nid; /* optional */
  198. hda_nid_t hp_nid; /* optional */
  199. unsigned int num_adc_nids;
  200. hda_nid_t *adc_nids;
  201. hda_nid_t dig_in_nid;
  202. unsigned int num_channel_mode;
  203. const struct hda_channel_mode *channel_mode;
  204. int need_dac_fix;
  205. unsigned int num_mux_defs;
  206. const struct hda_input_mux *input_mux;
  207. void (*unsol_event)(struct hda_codec *, unsigned int);
  208. void (*init_hook)(struct hda_codec *);
  209. };
  210. /*
  211. * input MUX handling
  212. */
  213. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  214. struct snd_ctl_elem_info *uinfo)
  215. {
  216. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  217. struct alc_spec *spec = codec->spec;
  218. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  219. if (mux_idx >= spec->num_mux_defs)
  220. mux_idx = 0;
  221. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  222. }
  223. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  224. struct snd_ctl_elem_value *ucontrol)
  225. {
  226. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  227. struct alc_spec *spec = codec->spec;
  228. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  229. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  230. return 0;
  231. }
  232. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  233. struct snd_ctl_elem_value *ucontrol)
  234. {
  235. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  236. struct alc_spec *spec = codec->spec;
  237. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  238. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  239. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  240. spec->adc_nids[adc_idx],
  241. &spec->cur_mux[adc_idx]);
  242. }
  243. /*
  244. * channel mode setting
  245. */
  246. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  247. struct snd_ctl_elem_info *uinfo)
  248. {
  249. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  250. struct alc_spec *spec = codec->spec;
  251. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  252. spec->num_channel_mode);
  253. }
  254. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_value *ucontrol)
  256. {
  257. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  258. struct alc_spec *spec = codec->spec;
  259. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  260. spec->num_channel_mode,
  261. spec->multiout.max_channels);
  262. }
  263. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  264. struct snd_ctl_elem_value *ucontrol)
  265. {
  266. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  267. struct alc_spec *spec = codec->spec;
  268. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  269. spec->num_channel_mode,
  270. &spec->multiout.max_channels);
  271. if (err >= 0 && spec->need_dac_fix)
  272. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  273. return err;
  274. }
  275. /*
  276. * Control the mode of pin widget settings via the mixer. "pc" is used
  277. * instead of "%" to avoid consequences of accidently treating the % as
  278. * being part of a format specifier. Maximum allowed length of a value is
  279. * 63 characters plus NULL terminator.
  280. *
  281. * Note: some retasking pin complexes seem to ignore requests for input
  282. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  283. * are requested. Therefore order this list so that this behaviour will not
  284. * cause problems when mixer clients move through the enum sequentially.
  285. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  286. * March 2006.
  287. */
  288. static char *alc_pin_mode_names[] = {
  289. "Mic 50pc bias", "Mic 80pc bias",
  290. "Line in", "Line out", "Headphone out",
  291. };
  292. static unsigned char alc_pin_mode_values[] = {
  293. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  294. };
  295. /* The control can present all 5 options, or it can limit the options based
  296. * in the pin being assumed to be exclusively an input or an output pin. In
  297. * addition, "input" pins may or may not process the mic bias option
  298. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  299. * accept requests for bias as of chip versions up to March 2006) and/or
  300. * wiring in the computer.
  301. */
  302. #define ALC_PIN_DIR_IN 0x00
  303. #define ALC_PIN_DIR_OUT 0x01
  304. #define ALC_PIN_DIR_INOUT 0x02
  305. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  306. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  307. /* Info about the pin modes supported by the different pin direction modes.
  308. * For each direction the minimum and maximum values are given.
  309. */
  310. static signed char alc_pin_mode_dir_info[5][2] = {
  311. { 0, 2 }, /* ALC_PIN_DIR_IN */
  312. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  313. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  314. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  315. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  316. };
  317. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  318. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  319. #define alc_pin_mode_n_items(_dir) \
  320. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  321. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  322. struct snd_ctl_elem_info *uinfo)
  323. {
  324. unsigned int item_num = uinfo->value.enumerated.item;
  325. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  326. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  327. uinfo->count = 1;
  328. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  329. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  330. item_num = alc_pin_mode_min(dir);
  331. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  332. return 0;
  333. }
  334. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  335. struct snd_ctl_elem_value *ucontrol)
  336. {
  337. unsigned int i;
  338. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  339. hda_nid_t nid = kcontrol->private_value & 0xffff;
  340. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  341. long *valp = ucontrol->value.integer.value;
  342. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  343. AC_VERB_GET_PIN_WIDGET_CONTROL,
  344. 0x00);
  345. /* Find enumerated value for current pinctl setting */
  346. i = alc_pin_mode_min(dir);
  347. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  348. i++;
  349. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  350. return 0;
  351. }
  352. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  353. struct snd_ctl_elem_value *ucontrol)
  354. {
  355. signed int change;
  356. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  357. hda_nid_t nid = kcontrol->private_value & 0xffff;
  358. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  359. long val = *ucontrol->value.integer.value;
  360. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  361. AC_VERB_GET_PIN_WIDGET_CONTROL,
  362. 0x00);
  363. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  364. val = alc_pin_mode_min(dir);
  365. change = pinctl != alc_pin_mode_values[val];
  366. if (change) {
  367. /* Set pin mode to that requested */
  368. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  369. alc_pin_mode_values[val]);
  370. /* Also enable the retasking pin's input/output as required
  371. * for the requested pin mode. Enum values of 2 or less are
  372. * input modes.
  373. *
  374. * Dynamically switching the input/output buffers probably
  375. * reduces noise slightly (particularly on input) so we'll
  376. * do it. However, having both input and output buffers
  377. * enabled simultaneously doesn't seem to be problematic if
  378. * this turns out to be necessary in the future.
  379. */
  380. if (val <= 2) {
  381. snd_hda_codec_write(codec, nid, 0,
  382. AC_VERB_SET_AMP_GAIN_MUTE,
  383. AMP_OUT_MUTE);
  384. snd_hda_codec_write(codec, nid, 0,
  385. AC_VERB_SET_AMP_GAIN_MUTE,
  386. AMP_IN_UNMUTE(0));
  387. } else {
  388. snd_hda_codec_write(codec, nid, 0,
  389. AC_VERB_SET_AMP_GAIN_MUTE,
  390. AMP_IN_MUTE(0));
  391. snd_hda_codec_write(codec, nid, 0,
  392. AC_VERB_SET_AMP_GAIN_MUTE,
  393. AMP_OUT_UNMUTE);
  394. }
  395. }
  396. return change;
  397. }
  398. #define ALC_PIN_MODE(xname, nid, dir) \
  399. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  400. .info = alc_pin_mode_info, \
  401. .get = alc_pin_mode_get, \
  402. .put = alc_pin_mode_put, \
  403. .private_value = nid | (dir<<16) }
  404. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  405. * together using a mask with more than one bit set. This control is
  406. * currently used only by the ALC260 test model. At this stage they are not
  407. * needed for any "production" models.
  408. */
  409. #ifdef CONFIG_SND_DEBUG
  410. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  411. struct snd_ctl_elem_info *uinfo)
  412. {
  413. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  414. uinfo->count = 1;
  415. uinfo->value.integer.min = 0;
  416. uinfo->value.integer.max = 1;
  417. return 0;
  418. }
  419. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  420. struct snd_ctl_elem_value *ucontrol)
  421. {
  422. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  423. hda_nid_t nid = kcontrol->private_value & 0xffff;
  424. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  425. long *valp = ucontrol->value.integer.value;
  426. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  427. AC_VERB_GET_GPIO_DATA, 0x00);
  428. *valp = (val & mask) != 0;
  429. return 0;
  430. }
  431. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_value *ucontrol)
  433. {
  434. signed int change;
  435. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  436. hda_nid_t nid = kcontrol->private_value & 0xffff;
  437. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  438. long val = *ucontrol->value.integer.value;
  439. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  440. AC_VERB_GET_GPIO_DATA,
  441. 0x00);
  442. /* Set/unset the masked GPIO bit(s) as needed */
  443. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  444. if (val == 0)
  445. gpio_data &= ~mask;
  446. else
  447. gpio_data |= mask;
  448. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  449. return change;
  450. }
  451. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  452. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  453. .info = alc_gpio_data_info, \
  454. .get = alc_gpio_data_get, \
  455. .put = alc_gpio_data_put, \
  456. .private_value = nid | (mask<<16) }
  457. #endif /* CONFIG_SND_DEBUG */
  458. /* A switch control to allow the enabling of the digital IO pins on the
  459. * ALC260. This is incredibly simplistic; the intention of this control is
  460. * to provide something in the test model allowing digital outputs to be
  461. * identified if present. If models are found which can utilise these
  462. * outputs a more complete mixer control can be devised for those models if
  463. * necessary.
  464. */
  465. #ifdef CONFIG_SND_DEBUG
  466. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_info *uinfo)
  468. {
  469. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  470. uinfo->count = 1;
  471. uinfo->value.integer.min = 0;
  472. uinfo->value.integer.max = 1;
  473. return 0;
  474. }
  475. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  476. struct snd_ctl_elem_value *ucontrol)
  477. {
  478. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  479. hda_nid_t nid = kcontrol->private_value & 0xffff;
  480. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  481. long *valp = ucontrol->value.integer.value;
  482. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  483. AC_VERB_GET_DIGI_CONVERT, 0x00);
  484. *valp = (val & mask) != 0;
  485. return 0;
  486. }
  487. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  488. struct snd_ctl_elem_value *ucontrol)
  489. {
  490. signed int change;
  491. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  492. hda_nid_t nid = kcontrol->private_value & 0xffff;
  493. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  494. long val = *ucontrol->value.integer.value;
  495. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  496. AC_VERB_GET_DIGI_CONVERT,
  497. 0x00);
  498. /* Set/unset the masked control bit(s) as needed */
  499. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  500. if (val==0)
  501. ctrl_data &= ~mask;
  502. else
  503. ctrl_data |= mask;
  504. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  505. ctrl_data);
  506. return change;
  507. }
  508. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  509. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  510. .info = alc_spdif_ctrl_info, \
  511. .get = alc_spdif_ctrl_get, \
  512. .put = alc_spdif_ctrl_put, \
  513. .private_value = nid | (mask<<16) }
  514. #endif /* CONFIG_SND_DEBUG */
  515. /*
  516. * set up from the preset table
  517. */
  518. static void setup_preset(struct alc_spec *spec,
  519. const struct alc_config_preset *preset)
  520. {
  521. int i;
  522. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  523. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  524. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  525. i++)
  526. spec->init_verbs[spec->num_init_verbs++] =
  527. preset->init_verbs[i];
  528. spec->channel_mode = preset->channel_mode;
  529. spec->num_channel_mode = preset->num_channel_mode;
  530. spec->need_dac_fix = preset->need_dac_fix;
  531. spec->multiout.max_channels = spec->channel_mode[0].channels;
  532. spec->multiout.num_dacs = preset->num_dacs;
  533. spec->multiout.dac_nids = preset->dac_nids;
  534. spec->multiout.dig_out_nid = preset->dig_out_nid;
  535. spec->multiout.hp_nid = preset->hp_nid;
  536. spec->num_mux_defs = preset->num_mux_defs;
  537. if (! spec->num_mux_defs)
  538. spec->num_mux_defs = 1;
  539. spec->input_mux = preset->input_mux;
  540. spec->num_adc_nids = preset->num_adc_nids;
  541. spec->adc_nids = preset->adc_nids;
  542. spec->dig_in_nid = preset->dig_in_nid;
  543. spec->unsol_event = preset->unsol_event;
  544. spec->init_hook = preset->init_hook;
  545. }
  546. /*
  547. * ALC880 3-stack model
  548. *
  549. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  550. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  551. * F-Mic = 0x1b, HP = 0x19
  552. */
  553. static hda_nid_t alc880_dac_nids[4] = {
  554. /* front, rear, clfe, rear_surr */
  555. 0x02, 0x05, 0x04, 0x03
  556. };
  557. static hda_nid_t alc880_adc_nids[3] = {
  558. /* ADC0-2 */
  559. 0x07, 0x08, 0x09,
  560. };
  561. /* The datasheet says the node 0x07 is connected from inputs,
  562. * but it shows zero connection in the real implementation on some devices.
  563. * Note: this is a 915GAV bug, fixed on 915GLV
  564. */
  565. static hda_nid_t alc880_adc_nids_alt[2] = {
  566. /* ADC1-2 */
  567. 0x08, 0x09,
  568. };
  569. #define ALC880_DIGOUT_NID 0x06
  570. #define ALC880_DIGIN_NID 0x0a
  571. static struct hda_input_mux alc880_capture_source = {
  572. .num_items = 4,
  573. .items = {
  574. { "Mic", 0x0 },
  575. { "Front Mic", 0x3 },
  576. { "Line", 0x2 },
  577. { "CD", 0x4 },
  578. },
  579. };
  580. /* channel source setting (2/6 channel selection for 3-stack) */
  581. /* 2ch mode */
  582. static struct hda_verb alc880_threestack_ch2_init[] = {
  583. /* set line-in to input, mute it */
  584. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  585. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  586. /* set mic-in to input vref 80%, mute it */
  587. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  588. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  589. { } /* end */
  590. };
  591. /* 6ch mode */
  592. static struct hda_verb alc880_threestack_ch6_init[] = {
  593. /* set line-in to output, unmute it */
  594. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  595. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  596. /* set mic-in to output, unmute it */
  597. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  598. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  599. { } /* end */
  600. };
  601. static struct hda_channel_mode alc880_threestack_modes[2] = {
  602. { 2, alc880_threestack_ch2_init },
  603. { 6, alc880_threestack_ch6_init },
  604. };
  605. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  606. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  607. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  608. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  609. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  610. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  611. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  612. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  613. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  614. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  615. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  616. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  617. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  619. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  620. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  621. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  622. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  623. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  624. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  625. {
  626. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  627. .name = "Channel Mode",
  628. .info = alc_ch_mode_info,
  629. .get = alc_ch_mode_get,
  630. .put = alc_ch_mode_put,
  631. },
  632. { } /* end */
  633. };
  634. /* capture mixer elements */
  635. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  636. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  637. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  638. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  639. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  640. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  641. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  642. {
  643. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  644. /* The multiple "Capture Source" controls confuse alsamixer
  645. * So call somewhat different..
  646. * FIXME: the controls appear in the "playback" view!
  647. */
  648. /* .name = "Capture Source", */
  649. .name = "Input Source",
  650. .count = 3,
  651. .info = alc_mux_enum_info,
  652. .get = alc_mux_enum_get,
  653. .put = alc_mux_enum_put,
  654. },
  655. { } /* end */
  656. };
  657. /* capture mixer elements (in case NID 0x07 not available) */
  658. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  659. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  660. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  661. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  662. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  663. {
  664. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  665. /* The multiple "Capture Source" controls confuse alsamixer
  666. * So call somewhat different..
  667. * FIXME: the controls appear in the "playback" view!
  668. */
  669. /* .name = "Capture Source", */
  670. .name = "Input Source",
  671. .count = 2,
  672. .info = alc_mux_enum_info,
  673. .get = alc_mux_enum_get,
  674. .put = alc_mux_enum_put,
  675. },
  676. { } /* end */
  677. };
  678. /*
  679. * ALC880 5-stack model
  680. *
  681. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  682. * Side = 0x02 (0xd)
  683. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  684. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  685. */
  686. /* additional mixers to alc880_three_stack_mixer */
  687. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  688. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  689. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  690. { } /* end */
  691. };
  692. /* channel source setting (6/8 channel selection for 5-stack) */
  693. /* 6ch mode */
  694. static struct hda_verb alc880_fivestack_ch6_init[] = {
  695. /* set line-in to input, mute it */
  696. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  697. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  698. { } /* end */
  699. };
  700. /* 8ch mode */
  701. static struct hda_verb alc880_fivestack_ch8_init[] = {
  702. /* set line-in to output, unmute it */
  703. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. { } /* end */
  706. };
  707. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  708. { 6, alc880_fivestack_ch6_init },
  709. { 8, alc880_fivestack_ch8_init },
  710. };
  711. /*
  712. * ALC880 6-stack model
  713. *
  714. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  715. * Side = 0x05 (0x0f)
  716. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  717. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  718. */
  719. static hda_nid_t alc880_6st_dac_nids[4] = {
  720. /* front, rear, clfe, rear_surr */
  721. 0x02, 0x03, 0x04, 0x05
  722. };
  723. static struct hda_input_mux alc880_6stack_capture_source = {
  724. .num_items = 4,
  725. .items = {
  726. { "Mic", 0x0 },
  727. { "Front Mic", 0x1 },
  728. { "Line", 0x2 },
  729. { "CD", 0x4 },
  730. },
  731. };
  732. /* fixed 8-channels */
  733. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  734. { 8, NULL },
  735. };
  736. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  737. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  738. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  740. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  741. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  742. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  744. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  745. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  747. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  748. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  750. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  752. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  754. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  755. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  756. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  757. {
  758. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  759. .name = "Channel Mode",
  760. .info = alc_ch_mode_info,
  761. .get = alc_ch_mode_get,
  762. .put = alc_ch_mode_put,
  763. },
  764. { } /* end */
  765. };
  766. /*
  767. * ALC880 W810 model
  768. *
  769. * W810 has rear IO for:
  770. * Front (DAC 02)
  771. * Surround (DAC 03)
  772. * Center/LFE (DAC 04)
  773. * Digital out (06)
  774. *
  775. * The system also has a pair of internal speakers, and a headphone jack.
  776. * These are both connected to Line2 on the codec, hence to DAC 02.
  777. *
  778. * There is a variable resistor to control the speaker or headphone
  779. * volume. This is a hardware-only device without a software API.
  780. *
  781. * Plugging headphones in will disable the internal speakers. This is
  782. * implemented in hardware, not via the driver using jack sense. In
  783. * a similar fashion, plugging into the rear socket marked "front" will
  784. * disable both the speakers and headphones.
  785. *
  786. * For input, there's a microphone jack, and an "audio in" jack.
  787. * These may not do anything useful with this driver yet, because I
  788. * haven't setup any initialization verbs for these yet...
  789. */
  790. static hda_nid_t alc880_w810_dac_nids[3] = {
  791. /* front, rear/surround, clfe */
  792. 0x02, 0x03, 0x04
  793. };
  794. /* fixed 6 channels */
  795. static struct hda_channel_mode alc880_w810_modes[1] = {
  796. { 6, NULL }
  797. };
  798. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  799. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  800. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  801. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  802. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  803. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  804. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  805. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  806. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  807. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  808. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  809. { } /* end */
  810. };
  811. /*
  812. * Z710V model
  813. *
  814. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  815. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  816. * Line = 0x1a
  817. */
  818. static hda_nid_t alc880_z71v_dac_nids[1] = {
  819. 0x02
  820. };
  821. #define ALC880_Z71V_HP_DAC 0x03
  822. /* fixed 2 channels */
  823. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  824. { 2, NULL }
  825. };
  826. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  827. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  828. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  829. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  830. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  831. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  832. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  833. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  834. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  835. { } /* end */
  836. };
  837. /* FIXME! */
  838. /*
  839. * ALC880 F1734 model
  840. *
  841. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  842. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  843. */
  844. static hda_nid_t alc880_f1734_dac_nids[1] = {
  845. 0x03
  846. };
  847. #define ALC880_F1734_HP_DAC 0x02
  848. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  849. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  850. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  856. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  857. { } /* end */
  858. };
  859. /* FIXME! */
  860. /*
  861. * ALC880 ASUS model
  862. *
  863. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  864. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  865. * Mic = 0x18, Line = 0x1a
  866. */
  867. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  868. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  869. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  870. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  871. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  878. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  879. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  881. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  882. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  883. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  884. {
  885. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  886. .name = "Channel Mode",
  887. .info = alc_ch_mode_info,
  888. .get = alc_ch_mode_get,
  889. .put = alc_ch_mode_put,
  890. },
  891. { } /* end */
  892. };
  893. /* FIXME! */
  894. /*
  895. * ALC880 ASUS W1V model
  896. *
  897. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  898. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  899. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  900. */
  901. /* additional mixers to alc880_asus_mixer */
  902. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  903. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  904. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  905. { } /* end */
  906. };
  907. /* additional mixers to alc880_asus_mixer */
  908. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  909. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  910. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  911. { } /* end */
  912. };
  913. /* TCL S700 */
  914. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  915. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  916. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  917. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  918. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  919. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  920. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  921. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  922. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  923. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  924. {
  925. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  926. /* The multiple "Capture Source" controls confuse alsamixer
  927. * So call somewhat different..
  928. * FIXME: the controls appear in the "playback" view!
  929. */
  930. /* .name = "Capture Source", */
  931. .name = "Input Source",
  932. .count = 1,
  933. .info = alc_mux_enum_info,
  934. .get = alc_mux_enum_get,
  935. .put = alc_mux_enum_put,
  936. },
  937. { } /* end */
  938. };
  939. /* Uniwill */
  940. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  941. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  942. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  943. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  944. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  945. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  946. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  947. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  948. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  949. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  950. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  951. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  952. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  953. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  954. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  955. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  956. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  957. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  958. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  959. {
  960. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  961. .name = "Channel Mode",
  962. .info = alc_ch_mode_info,
  963. .get = alc_ch_mode_get,
  964. .put = alc_ch_mode_put,
  965. },
  966. { } /* end */
  967. };
  968. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  969. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  970. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  971. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  972. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  973. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  974. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  975. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  976. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  977. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  978. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  979. { } /* end */
  980. };
  981. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  982. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  983. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  987. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  988. { } /* end */
  989. };
  990. /*
  991. * build control elements
  992. */
  993. static int alc_build_controls(struct hda_codec *codec)
  994. {
  995. struct alc_spec *spec = codec->spec;
  996. int err;
  997. int i;
  998. for (i = 0; i < spec->num_mixers; i++) {
  999. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1000. if (err < 0)
  1001. return err;
  1002. }
  1003. if (spec->multiout.dig_out_nid) {
  1004. err = snd_hda_create_spdif_out_ctls(codec,
  1005. spec->multiout.dig_out_nid);
  1006. if (err < 0)
  1007. return err;
  1008. }
  1009. if (spec->dig_in_nid) {
  1010. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1011. if (err < 0)
  1012. return err;
  1013. }
  1014. return 0;
  1015. }
  1016. /*
  1017. * initialize the codec volumes, etc
  1018. */
  1019. /*
  1020. * generic initialization of ADC, input mixers and output mixers
  1021. */
  1022. static struct hda_verb alc880_volume_init_verbs[] = {
  1023. /*
  1024. * Unmute ADC0-2 and set the default input to mic-in
  1025. */
  1026. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1028. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1029. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1030. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1031. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1032. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1033. * mixer widget
  1034. * Note: PASD motherboards uses the Line In 2 as the input for front
  1035. * panel mic (mic 2)
  1036. */
  1037. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1038. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1039. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1040. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1041. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1042. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1043. /*
  1044. * Set up output mixers (0x0c - 0x0f)
  1045. */
  1046. /* set vol=0 to output mixers */
  1047. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1048. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1049. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1050. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1051. /* set up input amps for analog loopback */
  1052. /* Amp Indices: DAC = 0, mixer = 1 */
  1053. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1055. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1056. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1057. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1058. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1059. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1060. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1061. { }
  1062. };
  1063. /*
  1064. * 3-stack pin configuration:
  1065. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1066. */
  1067. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1068. /*
  1069. * preset connection lists of input pins
  1070. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1071. */
  1072. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1073. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1074. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1075. /*
  1076. * Set pin mode and muting
  1077. */
  1078. /* set front pin widgets 0x14 for output */
  1079. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1080. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1081. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1082. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1083. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1084. /* Mic2 (as headphone out) for HP output */
  1085. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1086. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1087. /* Line In pin widget for input */
  1088. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1089. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1090. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1091. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1092. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1093. /* CD pin widget for input */
  1094. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1095. { }
  1096. };
  1097. /*
  1098. * 5-stack pin configuration:
  1099. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1100. * line-in/side = 0x1a, f-mic = 0x1b
  1101. */
  1102. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1103. /*
  1104. * preset connection lists of input pins
  1105. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1106. */
  1107. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1108. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1109. /*
  1110. * Set pin mode and muting
  1111. */
  1112. /* set pin widgets 0x14-0x17 for output */
  1113. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1114. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1115. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1116. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1117. /* unmute pins for output (no gain on this amp) */
  1118. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1119. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1120. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1121. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1122. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1123. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1124. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1125. /* Mic2 (as headphone out) for HP output */
  1126. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1127. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1128. /* Line In pin widget for input */
  1129. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1130. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1131. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1132. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1133. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1134. /* CD pin widget for input */
  1135. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1136. { }
  1137. };
  1138. /*
  1139. * W810 pin configuration:
  1140. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1141. */
  1142. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1143. /* hphone/speaker input selector: front DAC */
  1144. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1145. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1146. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1147. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1148. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1149. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1150. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1151. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1152. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1153. { }
  1154. };
  1155. /*
  1156. * Z71V pin configuration:
  1157. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1158. */
  1159. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1160. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1161. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1162. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1163. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1164. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1165. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1167. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1168. { }
  1169. };
  1170. /*
  1171. * 6-stack pin configuration:
  1172. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1173. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1174. */
  1175. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1176. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1178. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1179. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1180. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1181. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1182. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1183. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1184. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1185. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1186. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1187. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1188. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1190. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1191. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1192. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. { }
  1195. };
  1196. /*
  1197. * Uniwill pin configuration:
  1198. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1199. * line = 0x1a
  1200. */
  1201. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1202. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1203. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1204. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1205. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1206. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1207. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1208. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1209. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1210. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1211. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1212. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1213. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1215. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1216. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1217. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1218. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1219. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1220. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1223. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1224. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1225. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1227. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1228. { }
  1229. };
  1230. /*
  1231. * Uniwill P53
  1232. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1233. */
  1234. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1235. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1236. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1237. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1238. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1239. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1240. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1241. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1245. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1247. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1248. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1249. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1250. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1251. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1252. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1253. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1254. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1255. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1256. { }
  1257. };
  1258. static struct hda_verb alc880_beep_init_verbs[] = {
  1259. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1260. { }
  1261. };
  1262. /* toggle speaker-output according to the hp-jack state */
  1263. static void alc880_uniwill_automute(struct hda_codec *codec)
  1264. {
  1265. unsigned int present;
  1266. present = snd_hda_codec_read(codec, 0x14, 0,
  1267. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1268. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1269. 0x80, present ? 0x80 : 0);
  1270. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1271. 0x80, present ? 0x80 : 0);
  1272. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1273. 0x80, present ? 0x80 : 0);
  1274. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1275. 0x80, present ? 0x80 : 0);
  1276. present = snd_hda_codec_read(codec, 0x18, 0,
  1277. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1278. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1279. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  1280. }
  1281. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1282. unsigned int res)
  1283. {
  1284. /* Looks like the unsol event is incompatible with the standard
  1285. * definition. 4bit tag is placed at 28 bit!
  1286. */
  1287. if ((res >> 28) == ALC880_HP_EVENT ||
  1288. (res >> 28) == ALC880_MIC_EVENT)
  1289. alc880_uniwill_automute(codec);
  1290. }
  1291. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1292. {
  1293. unsigned int present;
  1294. present = snd_hda_codec_read(codec, 0x14, 0,
  1295. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1296. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1297. 0x80, present ? 0x80 : 0);
  1298. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1299. 0x80, present ? 0x80 : 0);
  1300. }
  1301. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1302. {
  1303. unsigned int present;
  1304. present = snd_hda_codec_read(codec, 0x21, 0,
  1305. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1306. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1307. 0x7f, present);
  1308. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1309. 0x7f, present);
  1310. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1311. 0x7f, present);
  1312. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1313. 0x7f, present);
  1314. }
  1315. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1316. unsigned int res)
  1317. {
  1318. /* Looks like the unsol event is incompatible with the standard
  1319. * definition. 4bit tag is placed at 28 bit!
  1320. */
  1321. if ((res >> 28) == ALC880_HP_EVENT)
  1322. alc880_uniwill_p53_hp_automute(codec);
  1323. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1324. alc880_uniwill_p53_dcvol_automute(codec);
  1325. }
  1326. /* FIXME! */
  1327. /*
  1328. * F1734 pin configuration:
  1329. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1330. */
  1331. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1332. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1333. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1334. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1335. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1336. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1337. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1338. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1339. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1341. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1342. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1343. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1344. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1345. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1349. { }
  1350. };
  1351. /* FIXME! */
  1352. /*
  1353. * ASUS pin configuration:
  1354. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1355. */
  1356. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1357. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1358. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1359. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1360. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1361. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1362. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1363. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1364. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1365. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1366. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1367. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1368. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1369. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1370. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1371. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1372. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1375. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1376. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1378. { }
  1379. };
  1380. /* Enable GPIO mask and set output */
  1381. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1382. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1383. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1384. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1385. { }
  1386. };
  1387. /* Enable GPIO mask and set output */
  1388. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1389. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1390. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1391. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1392. { }
  1393. };
  1394. /* Clevo m520g init */
  1395. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1396. /* headphone output */
  1397. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1398. /* line-out */
  1399. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1400. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. /* Line-in */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1404. /* CD */
  1405. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1406. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1407. /* Mic1 (rear panel) */
  1408. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1409. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1410. /* Mic2 (front panel) */
  1411. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1412. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1413. /* headphone */
  1414. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1415. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1416. /* change to EAPD mode */
  1417. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1418. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1419. { }
  1420. };
  1421. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1422. /* change to EAPD mode */
  1423. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1424. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1425. /* Headphone output */
  1426. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1427. /* Front output*/
  1428. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1429. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1430. /* Line In pin widget for input */
  1431. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1432. /* CD pin widget for input */
  1433. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1434. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1435. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1436. /* change to EAPD mode */
  1437. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1438. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1439. { }
  1440. };
  1441. /*
  1442. * LG m1 express dual
  1443. *
  1444. * Pin assignment:
  1445. * Rear Line-In/Out (blue): 0x14
  1446. * Build-in Mic-In: 0x15
  1447. * Speaker-out: 0x17
  1448. * HP-Out (green): 0x1b
  1449. * Mic-In/Out (red): 0x19
  1450. * SPDIF-Out: 0x1e
  1451. */
  1452. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1453. static hda_nid_t alc880_lg_dac_nids[3] = {
  1454. 0x05, 0x02, 0x03
  1455. };
  1456. /* seems analog CD is not working */
  1457. static struct hda_input_mux alc880_lg_capture_source = {
  1458. .num_items = 3,
  1459. .items = {
  1460. { "Mic", 0x1 },
  1461. { "Line", 0x5 },
  1462. { "Internal Mic", 0x6 },
  1463. },
  1464. };
  1465. /* 2,4,6 channel modes */
  1466. static struct hda_verb alc880_lg_ch2_init[] = {
  1467. /* set line-in and mic-in to input */
  1468. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1469. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1470. { }
  1471. };
  1472. static struct hda_verb alc880_lg_ch4_init[] = {
  1473. /* set line-in to out and mic-in to input */
  1474. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1475. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1476. { }
  1477. };
  1478. static struct hda_verb alc880_lg_ch6_init[] = {
  1479. /* set line-in and mic-in to output */
  1480. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1481. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1482. { }
  1483. };
  1484. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1485. { 2, alc880_lg_ch2_init },
  1486. { 4, alc880_lg_ch4_init },
  1487. { 6, alc880_lg_ch6_init },
  1488. };
  1489. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1490. /* FIXME: it's not really "master" but front channels */
  1491. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1492. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1493. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1494. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1495. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1496. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1497. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1498. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1499. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1500. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1501. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1502. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1503. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1504. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1505. {
  1506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1507. .name = "Channel Mode",
  1508. .info = alc_ch_mode_info,
  1509. .get = alc_ch_mode_get,
  1510. .put = alc_ch_mode_put,
  1511. },
  1512. { } /* end */
  1513. };
  1514. static struct hda_verb alc880_lg_init_verbs[] = {
  1515. /* set capture source to mic-in */
  1516. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1517. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1519. /* mute all amp mixer inputs */
  1520. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1521. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1522. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1523. /* line-in to input */
  1524. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1526. /* built-in mic */
  1527. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1528. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1529. /* speaker-out */
  1530. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1531. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1532. /* mic-in to input */
  1533. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1534. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1535. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. /* HP-out */
  1537. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1538. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1539. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* jack sense */
  1541. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1542. { }
  1543. };
  1544. /* toggle speaker-output according to the hp-jack state */
  1545. static void alc880_lg_automute(struct hda_codec *codec)
  1546. {
  1547. unsigned int present;
  1548. present = snd_hda_codec_read(codec, 0x1b, 0,
  1549. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1550. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1551. 0x80, present ? 0x80 : 0);
  1552. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1553. 0x80, present ? 0x80 : 0);
  1554. }
  1555. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1556. {
  1557. /* Looks like the unsol event is incompatible with the standard
  1558. * definition. 4bit tag is placed at 28 bit!
  1559. */
  1560. if ((res >> 28) == 0x01)
  1561. alc880_lg_automute(codec);
  1562. }
  1563. /*
  1564. * LG LW20
  1565. *
  1566. * Pin assignment:
  1567. * Speaker-out: 0x14
  1568. * Mic-In: 0x18
  1569. * Built-in Mic-In: 0x19 (?)
  1570. * HP-Out: 0x1b
  1571. * SPDIF-Out: 0x1e
  1572. */
  1573. /* seems analog CD is not working */
  1574. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1575. .num_items = 2,
  1576. .items = {
  1577. { "Mic", 0x0 },
  1578. { "Internal Mic", 0x1 },
  1579. },
  1580. };
  1581. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1582. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1583. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1584. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1585. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1586. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1587. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1588. { } /* end */
  1589. };
  1590. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1591. /* set capture source to mic-in */
  1592. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1593. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1594. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1595. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1596. /* speaker-out */
  1597. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1598. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1599. /* HP-out */
  1600. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1602. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1603. /* mic-in to input */
  1604. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1605. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1606. /* built-in mic */
  1607. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1608. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1609. /* jack sense */
  1610. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1611. { }
  1612. };
  1613. /* toggle speaker-output according to the hp-jack state */
  1614. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1615. {
  1616. unsigned int present;
  1617. present = snd_hda_codec_read(codec, 0x1b, 0,
  1618. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1619. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1620. 0x80, present ? 0x80 : 0);
  1621. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1622. 0x80, present ? 0x80 : 0);
  1623. }
  1624. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1625. {
  1626. /* Looks like the unsol event is incompatible with the standard
  1627. * definition. 4bit tag is placed at 28 bit!
  1628. */
  1629. if ((res >> 28) == 0x01)
  1630. alc880_lg_lw_automute(codec);
  1631. }
  1632. /*
  1633. * Common callbacks
  1634. */
  1635. static int alc_init(struct hda_codec *codec)
  1636. {
  1637. struct alc_spec *spec = codec->spec;
  1638. unsigned int i;
  1639. for (i = 0; i < spec->num_init_verbs; i++)
  1640. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1641. if (spec->init_hook)
  1642. spec->init_hook(codec);
  1643. return 0;
  1644. }
  1645. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1646. {
  1647. struct alc_spec *spec = codec->spec;
  1648. if (spec->unsol_event)
  1649. spec->unsol_event(codec, res);
  1650. }
  1651. #ifdef CONFIG_PM
  1652. /*
  1653. * resume
  1654. */
  1655. static int alc_resume(struct hda_codec *codec)
  1656. {
  1657. struct alc_spec *spec = codec->spec;
  1658. int i;
  1659. alc_init(codec);
  1660. for (i = 0; i < spec->num_mixers; i++)
  1661. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1662. if (spec->multiout.dig_out_nid)
  1663. snd_hda_resume_spdif_out(codec);
  1664. if (spec->dig_in_nid)
  1665. snd_hda_resume_spdif_in(codec);
  1666. return 0;
  1667. }
  1668. #endif
  1669. /*
  1670. * Analog playback callbacks
  1671. */
  1672. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1673. struct hda_codec *codec,
  1674. struct snd_pcm_substream *substream)
  1675. {
  1676. struct alc_spec *spec = codec->spec;
  1677. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1678. }
  1679. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1680. struct hda_codec *codec,
  1681. unsigned int stream_tag,
  1682. unsigned int format,
  1683. struct snd_pcm_substream *substream)
  1684. {
  1685. struct alc_spec *spec = codec->spec;
  1686. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1687. stream_tag, format, substream);
  1688. }
  1689. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1690. struct hda_codec *codec,
  1691. struct snd_pcm_substream *substream)
  1692. {
  1693. struct alc_spec *spec = codec->spec;
  1694. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1695. }
  1696. /*
  1697. * Digital out
  1698. */
  1699. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1700. struct hda_codec *codec,
  1701. struct snd_pcm_substream *substream)
  1702. {
  1703. struct alc_spec *spec = codec->spec;
  1704. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1705. }
  1706. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1707. struct hda_codec *codec,
  1708. struct snd_pcm_substream *substream)
  1709. {
  1710. struct alc_spec *spec = codec->spec;
  1711. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1712. }
  1713. /*
  1714. * Analog capture
  1715. */
  1716. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1717. struct hda_codec *codec,
  1718. unsigned int stream_tag,
  1719. unsigned int format,
  1720. struct snd_pcm_substream *substream)
  1721. {
  1722. struct alc_spec *spec = codec->spec;
  1723. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1724. stream_tag, 0, format);
  1725. return 0;
  1726. }
  1727. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1728. struct hda_codec *codec,
  1729. struct snd_pcm_substream *substream)
  1730. {
  1731. struct alc_spec *spec = codec->spec;
  1732. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1733. 0, 0, 0);
  1734. return 0;
  1735. }
  1736. /*
  1737. */
  1738. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1739. .substreams = 1,
  1740. .channels_min = 2,
  1741. .channels_max = 8,
  1742. /* NID is set in alc_build_pcms */
  1743. .ops = {
  1744. .open = alc880_playback_pcm_open,
  1745. .prepare = alc880_playback_pcm_prepare,
  1746. .cleanup = alc880_playback_pcm_cleanup
  1747. },
  1748. };
  1749. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1750. .substreams = 2,
  1751. .channels_min = 2,
  1752. .channels_max = 2,
  1753. /* NID is set in alc_build_pcms */
  1754. .ops = {
  1755. .prepare = alc880_capture_pcm_prepare,
  1756. .cleanup = alc880_capture_pcm_cleanup
  1757. },
  1758. };
  1759. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1760. .substreams = 1,
  1761. .channels_min = 2,
  1762. .channels_max = 2,
  1763. /* NID is set in alc_build_pcms */
  1764. .ops = {
  1765. .open = alc880_dig_playback_pcm_open,
  1766. .close = alc880_dig_playback_pcm_close
  1767. },
  1768. };
  1769. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1770. .substreams = 1,
  1771. .channels_min = 2,
  1772. .channels_max = 2,
  1773. /* NID is set in alc_build_pcms */
  1774. };
  1775. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1776. static struct hda_pcm_stream alc_pcm_null_playback = {
  1777. .substreams = 0,
  1778. .channels_min = 0,
  1779. .channels_max = 0,
  1780. };
  1781. static int alc_build_pcms(struct hda_codec *codec)
  1782. {
  1783. struct alc_spec *spec = codec->spec;
  1784. struct hda_pcm *info = spec->pcm_rec;
  1785. int i;
  1786. codec->num_pcms = 1;
  1787. codec->pcm_info = info;
  1788. info->name = spec->stream_name_analog;
  1789. if (spec->stream_analog_playback) {
  1790. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1791. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1792. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1793. }
  1794. if (spec->stream_analog_capture) {
  1795. snd_assert(spec->adc_nids, return -EINVAL);
  1796. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1797. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1798. }
  1799. if (spec->channel_mode) {
  1800. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1801. for (i = 0; i < spec->num_channel_mode; i++) {
  1802. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1803. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1804. }
  1805. }
  1806. }
  1807. /* SPDIF for stream index #1 */
  1808. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1809. codec->num_pcms = 2;
  1810. info = spec->pcm_rec + 1;
  1811. info->name = spec->stream_name_digital;
  1812. if (spec->multiout.dig_out_nid &&
  1813. spec->stream_digital_playback) {
  1814. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1815. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1816. }
  1817. if (spec->dig_in_nid &&
  1818. spec->stream_digital_capture) {
  1819. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1820. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1821. }
  1822. }
  1823. /* If the use of more than one ADC is requested for the current
  1824. * model, configure a second analog capture-only PCM.
  1825. */
  1826. /* Additional Analaog capture for index #2 */
  1827. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1828. spec->adc_nids) {
  1829. codec->num_pcms = 3;
  1830. info = spec->pcm_rec + 2;
  1831. info->name = spec->stream_name_analog;
  1832. /* No playback stream for second PCM */
  1833. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1834. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1835. if (spec->stream_analog_capture) {
  1836. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1837. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1838. }
  1839. }
  1840. return 0;
  1841. }
  1842. static void alc_free(struct hda_codec *codec)
  1843. {
  1844. struct alc_spec *spec = codec->spec;
  1845. unsigned int i;
  1846. if (! spec)
  1847. return;
  1848. if (spec->kctl_alloc) {
  1849. for (i = 0; i < spec->num_kctl_used; i++)
  1850. kfree(spec->kctl_alloc[i].name);
  1851. kfree(spec->kctl_alloc);
  1852. }
  1853. kfree(spec);
  1854. }
  1855. /*
  1856. */
  1857. static struct hda_codec_ops alc_patch_ops = {
  1858. .build_controls = alc_build_controls,
  1859. .build_pcms = alc_build_pcms,
  1860. .init = alc_init,
  1861. .free = alc_free,
  1862. .unsol_event = alc_unsol_event,
  1863. #ifdef CONFIG_PM
  1864. .resume = alc_resume,
  1865. #endif
  1866. };
  1867. /*
  1868. * Test configuration for debugging
  1869. *
  1870. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1871. * enum controls.
  1872. */
  1873. #ifdef CONFIG_SND_DEBUG
  1874. static hda_nid_t alc880_test_dac_nids[4] = {
  1875. 0x02, 0x03, 0x04, 0x05
  1876. };
  1877. static struct hda_input_mux alc880_test_capture_source = {
  1878. .num_items = 7,
  1879. .items = {
  1880. { "In-1", 0x0 },
  1881. { "In-2", 0x1 },
  1882. { "In-3", 0x2 },
  1883. { "In-4", 0x3 },
  1884. { "CD", 0x4 },
  1885. { "Front", 0x5 },
  1886. { "Surround", 0x6 },
  1887. },
  1888. };
  1889. static struct hda_channel_mode alc880_test_modes[4] = {
  1890. { 2, NULL },
  1891. { 4, NULL },
  1892. { 6, NULL },
  1893. { 8, NULL },
  1894. };
  1895. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1896. struct snd_ctl_elem_info *uinfo)
  1897. {
  1898. static char *texts[] = {
  1899. "N/A", "Line Out", "HP Out",
  1900. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1901. };
  1902. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1903. uinfo->count = 1;
  1904. uinfo->value.enumerated.items = 8;
  1905. if (uinfo->value.enumerated.item >= 8)
  1906. uinfo->value.enumerated.item = 7;
  1907. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1908. return 0;
  1909. }
  1910. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1911. struct snd_ctl_elem_value *ucontrol)
  1912. {
  1913. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1914. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1915. unsigned int pin_ctl, item = 0;
  1916. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1917. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1918. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1919. if (pin_ctl & AC_PINCTL_HP_EN)
  1920. item = 2;
  1921. else
  1922. item = 1;
  1923. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1924. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1925. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1926. case AC_PINCTL_VREF_50: item = 4; break;
  1927. case AC_PINCTL_VREF_GRD: item = 5; break;
  1928. case AC_PINCTL_VREF_80: item = 6; break;
  1929. case AC_PINCTL_VREF_100: item = 7; break;
  1930. }
  1931. }
  1932. ucontrol->value.enumerated.item[0] = item;
  1933. return 0;
  1934. }
  1935. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1936. struct snd_ctl_elem_value *ucontrol)
  1937. {
  1938. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1939. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1940. static unsigned int ctls[] = {
  1941. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1942. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1943. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1944. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1945. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1946. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1947. };
  1948. unsigned int old_ctl, new_ctl;
  1949. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1950. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1951. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1952. if (old_ctl != new_ctl) {
  1953. snd_hda_codec_write(codec, nid, 0,
  1954. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1955. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1956. (ucontrol->value.enumerated.item[0] >= 3 ?
  1957. 0xb080 : 0xb000));
  1958. return 1;
  1959. }
  1960. return 0;
  1961. }
  1962. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1963. struct snd_ctl_elem_info *uinfo)
  1964. {
  1965. static char *texts[] = {
  1966. "Front", "Surround", "CLFE", "Side"
  1967. };
  1968. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1969. uinfo->count = 1;
  1970. uinfo->value.enumerated.items = 4;
  1971. if (uinfo->value.enumerated.item >= 4)
  1972. uinfo->value.enumerated.item = 3;
  1973. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1974. return 0;
  1975. }
  1976. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1977. struct snd_ctl_elem_value *ucontrol)
  1978. {
  1979. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1980. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1981. unsigned int sel;
  1982. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1983. ucontrol->value.enumerated.item[0] = sel & 3;
  1984. return 0;
  1985. }
  1986. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1987. struct snd_ctl_elem_value *ucontrol)
  1988. {
  1989. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1990. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1991. unsigned int sel;
  1992. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1993. if (ucontrol->value.enumerated.item[0] != sel) {
  1994. sel = ucontrol->value.enumerated.item[0] & 3;
  1995. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1996. return 1;
  1997. }
  1998. return 0;
  1999. }
  2000. #define PIN_CTL_TEST(xname,nid) { \
  2001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2002. .name = xname, \
  2003. .info = alc_test_pin_ctl_info, \
  2004. .get = alc_test_pin_ctl_get, \
  2005. .put = alc_test_pin_ctl_put, \
  2006. .private_value = nid \
  2007. }
  2008. #define PIN_SRC_TEST(xname,nid) { \
  2009. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2010. .name = xname, \
  2011. .info = alc_test_pin_src_info, \
  2012. .get = alc_test_pin_src_get, \
  2013. .put = alc_test_pin_src_put, \
  2014. .private_value = nid \
  2015. }
  2016. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2017. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2018. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2019. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2020. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2021. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2022. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2023. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2024. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2025. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2026. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2027. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2028. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2029. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2030. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2031. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2032. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2033. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2034. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2035. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2036. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2037. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2038. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2039. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2040. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2041. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2042. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2043. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2044. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2045. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2046. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2047. {
  2048. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2049. .name = "Channel Mode",
  2050. .info = alc_ch_mode_info,
  2051. .get = alc_ch_mode_get,
  2052. .put = alc_ch_mode_put,
  2053. },
  2054. { } /* end */
  2055. };
  2056. static struct hda_verb alc880_test_init_verbs[] = {
  2057. /* Unmute inputs of 0x0c - 0x0f */
  2058. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2059. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2060. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2061. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2062. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2063. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2064. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2065. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2066. /* Vol output for 0x0c-0x0f */
  2067. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2068. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2069. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2070. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2071. /* Set output pins 0x14-0x17 */
  2072. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2073. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2074. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2075. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2076. /* Unmute output pins 0x14-0x17 */
  2077. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2078. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2079. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2080. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2081. /* Set input pins 0x18-0x1c */
  2082. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2083. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2084. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2085. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2086. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2087. /* Mute input pins 0x18-0x1b */
  2088. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2089. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2090. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2091. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2092. /* ADC set up */
  2093. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2094. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2095. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2096. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2097. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2098. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2099. /* Analog input/passthru */
  2100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2103. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2104. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2105. { }
  2106. };
  2107. #endif
  2108. /*
  2109. */
  2110. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2111. [ALC880_3ST] = "3stack",
  2112. [ALC880_TCL_S700] = "tcl",
  2113. [ALC880_3ST_DIG] = "3stack-digout",
  2114. [ALC880_CLEVO] = "clevo",
  2115. [ALC880_5ST] = "5stack",
  2116. [ALC880_5ST_DIG] = "5stack-digout",
  2117. [ALC880_W810] = "w810",
  2118. [ALC880_Z71V] = "z71v",
  2119. [ALC880_6ST] = "6stack",
  2120. [ALC880_6ST_DIG] = "6stack-digout",
  2121. [ALC880_ASUS] = "asus",
  2122. [ALC880_ASUS_W1V] = "asus-w1v",
  2123. [ALC880_ASUS_DIG] = "asus-dig",
  2124. [ALC880_ASUS_DIG2] = "asus-dig2",
  2125. [ALC880_UNIWILL_DIG] = "uniwill",
  2126. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2127. [ALC880_FUJITSU] = "fujitsu",
  2128. [ALC880_F1734] = "F1734",
  2129. [ALC880_LG] = "lg",
  2130. [ALC880_LG_LW] = "lg-lw",
  2131. #ifdef CONFIG_SND_DEBUG
  2132. [ALC880_TEST] = "test",
  2133. #endif
  2134. [ALC880_AUTO] = "auto",
  2135. };
  2136. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2137. /* Broken BIOS configuration */
  2138. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2139. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2140. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2141. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2142. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2143. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2144. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2145. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2146. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2147. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2148. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2149. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2150. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2151. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2152. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2153. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2154. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2155. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2156. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2157. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2158. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2159. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2160. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2161. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2162. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2163. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2164. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2165. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2166. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2167. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2168. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2169. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2170. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2171. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2172. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2173. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2174. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2175. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2176. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2177. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2178. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2179. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2180. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2181. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2182. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2183. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2184. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2185. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2186. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2187. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2188. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2189. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2190. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2191. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2192. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2193. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2194. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2195. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2196. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2197. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2198. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2199. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2200. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2201. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2202. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2203. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2204. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2205. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2206. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2207. {}
  2208. };
  2209. /*
  2210. * ALC880 codec presets
  2211. */
  2212. static struct alc_config_preset alc880_presets[] = {
  2213. [ALC880_3ST] = {
  2214. .mixers = { alc880_three_stack_mixer },
  2215. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2216. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2217. .dac_nids = alc880_dac_nids,
  2218. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2219. .channel_mode = alc880_threestack_modes,
  2220. .need_dac_fix = 1,
  2221. .input_mux = &alc880_capture_source,
  2222. },
  2223. [ALC880_3ST_DIG] = {
  2224. .mixers = { alc880_three_stack_mixer },
  2225. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2226. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2227. .dac_nids = alc880_dac_nids,
  2228. .dig_out_nid = ALC880_DIGOUT_NID,
  2229. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2230. .channel_mode = alc880_threestack_modes,
  2231. .need_dac_fix = 1,
  2232. .input_mux = &alc880_capture_source,
  2233. },
  2234. [ALC880_TCL_S700] = {
  2235. .mixers = { alc880_tcl_s700_mixer },
  2236. .init_verbs = { alc880_volume_init_verbs,
  2237. alc880_pin_tcl_S700_init_verbs,
  2238. alc880_gpio2_init_verbs },
  2239. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2240. .dac_nids = alc880_dac_nids,
  2241. .hp_nid = 0x03,
  2242. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2243. .channel_mode = alc880_2_jack_modes,
  2244. .input_mux = &alc880_capture_source,
  2245. },
  2246. [ALC880_5ST] = {
  2247. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2248. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2249. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2250. .dac_nids = alc880_dac_nids,
  2251. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2252. .channel_mode = alc880_fivestack_modes,
  2253. .input_mux = &alc880_capture_source,
  2254. },
  2255. [ALC880_5ST_DIG] = {
  2256. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2257. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2258. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2259. .dac_nids = alc880_dac_nids,
  2260. .dig_out_nid = ALC880_DIGOUT_NID,
  2261. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2262. .channel_mode = alc880_fivestack_modes,
  2263. .input_mux = &alc880_capture_source,
  2264. },
  2265. [ALC880_6ST] = {
  2266. .mixers = { alc880_six_stack_mixer },
  2267. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2268. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2269. .dac_nids = alc880_6st_dac_nids,
  2270. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2271. .channel_mode = alc880_sixstack_modes,
  2272. .input_mux = &alc880_6stack_capture_source,
  2273. },
  2274. [ALC880_6ST_DIG] = {
  2275. .mixers = { alc880_six_stack_mixer },
  2276. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2277. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2278. .dac_nids = alc880_6st_dac_nids,
  2279. .dig_out_nid = ALC880_DIGOUT_NID,
  2280. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2281. .channel_mode = alc880_sixstack_modes,
  2282. .input_mux = &alc880_6stack_capture_source,
  2283. },
  2284. [ALC880_W810] = {
  2285. .mixers = { alc880_w810_base_mixer },
  2286. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2287. alc880_gpio2_init_verbs },
  2288. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2289. .dac_nids = alc880_w810_dac_nids,
  2290. .dig_out_nid = ALC880_DIGOUT_NID,
  2291. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2292. .channel_mode = alc880_w810_modes,
  2293. .input_mux = &alc880_capture_source,
  2294. },
  2295. [ALC880_Z71V] = {
  2296. .mixers = { alc880_z71v_mixer },
  2297. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2298. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2299. .dac_nids = alc880_z71v_dac_nids,
  2300. .dig_out_nid = ALC880_DIGOUT_NID,
  2301. .hp_nid = 0x03,
  2302. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2303. .channel_mode = alc880_2_jack_modes,
  2304. .input_mux = &alc880_capture_source,
  2305. },
  2306. [ALC880_F1734] = {
  2307. .mixers = { alc880_f1734_mixer },
  2308. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2309. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2310. .dac_nids = alc880_f1734_dac_nids,
  2311. .hp_nid = 0x02,
  2312. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2313. .channel_mode = alc880_2_jack_modes,
  2314. .input_mux = &alc880_capture_source,
  2315. },
  2316. [ALC880_ASUS] = {
  2317. .mixers = { alc880_asus_mixer },
  2318. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2319. alc880_gpio1_init_verbs },
  2320. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2321. .dac_nids = alc880_asus_dac_nids,
  2322. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2323. .channel_mode = alc880_asus_modes,
  2324. .need_dac_fix = 1,
  2325. .input_mux = &alc880_capture_source,
  2326. },
  2327. [ALC880_ASUS_DIG] = {
  2328. .mixers = { alc880_asus_mixer },
  2329. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2330. alc880_gpio1_init_verbs },
  2331. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2332. .dac_nids = alc880_asus_dac_nids,
  2333. .dig_out_nid = ALC880_DIGOUT_NID,
  2334. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2335. .channel_mode = alc880_asus_modes,
  2336. .need_dac_fix = 1,
  2337. .input_mux = &alc880_capture_source,
  2338. },
  2339. [ALC880_ASUS_DIG2] = {
  2340. .mixers = { alc880_asus_mixer },
  2341. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2342. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2343. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2344. .dac_nids = alc880_asus_dac_nids,
  2345. .dig_out_nid = ALC880_DIGOUT_NID,
  2346. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2347. .channel_mode = alc880_asus_modes,
  2348. .need_dac_fix = 1,
  2349. .input_mux = &alc880_capture_source,
  2350. },
  2351. [ALC880_ASUS_W1V] = {
  2352. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2353. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2354. alc880_gpio1_init_verbs },
  2355. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2356. .dac_nids = alc880_asus_dac_nids,
  2357. .dig_out_nid = ALC880_DIGOUT_NID,
  2358. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2359. .channel_mode = alc880_asus_modes,
  2360. .need_dac_fix = 1,
  2361. .input_mux = &alc880_capture_source,
  2362. },
  2363. [ALC880_UNIWILL_DIG] = {
  2364. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2365. .init_verbs = { alc880_volume_init_verbs,
  2366. alc880_pin_asus_init_verbs },
  2367. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2368. .dac_nids = alc880_asus_dac_nids,
  2369. .dig_out_nid = ALC880_DIGOUT_NID,
  2370. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2371. .channel_mode = alc880_asus_modes,
  2372. .need_dac_fix = 1,
  2373. .input_mux = &alc880_capture_source,
  2374. },
  2375. [ALC880_UNIWILL] = {
  2376. .mixers = { alc880_uniwill_mixer },
  2377. .init_verbs = { alc880_volume_init_verbs,
  2378. alc880_uniwill_init_verbs },
  2379. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2380. .dac_nids = alc880_asus_dac_nids,
  2381. .dig_out_nid = ALC880_DIGOUT_NID,
  2382. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2383. .channel_mode = alc880_threestack_modes,
  2384. .need_dac_fix = 1,
  2385. .input_mux = &alc880_capture_source,
  2386. .unsol_event = alc880_uniwill_unsol_event,
  2387. .init_hook = alc880_uniwill_automute,
  2388. },
  2389. [ALC880_UNIWILL_P53] = {
  2390. .mixers = { alc880_uniwill_p53_mixer },
  2391. .init_verbs = { alc880_volume_init_verbs,
  2392. alc880_uniwill_p53_init_verbs },
  2393. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2394. .dac_nids = alc880_asus_dac_nids,
  2395. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2396. .channel_mode = alc880_threestack_modes,
  2397. .input_mux = &alc880_capture_source,
  2398. .unsol_event = alc880_uniwill_p53_unsol_event,
  2399. .init_hook = alc880_uniwill_p53_hp_automute,
  2400. },
  2401. [ALC880_FUJITSU] = {
  2402. .mixers = { alc880_fujitsu_mixer,
  2403. alc880_pcbeep_mixer, },
  2404. .init_verbs = { alc880_volume_init_verbs,
  2405. alc880_uniwill_p53_init_verbs,
  2406. alc880_beep_init_verbs },
  2407. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2408. .dac_nids = alc880_dac_nids,
  2409. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2410. .channel_mode = alc880_2_jack_modes,
  2411. .input_mux = &alc880_capture_source,
  2412. .unsol_event = alc880_uniwill_p53_unsol_event,
  2413. .init_hook = alc880_uniwill_p53_hp_automute,
  2414. },
  2415. [ALC880_CLEVO] = {
  2416. .mixers = { alc880_three_stack_mixer },
  2417. .init_verbs = { alc880_volume_init_verbs,
  2418. alc880_pin_clevo_init_verbs },
  2419. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2420. .dac_nids = alc880_dac_nids,
  2421. .hp_nid = 0x03,
  2422. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2423. .channel_mode = alc880_threestack_modes,
  2424. .need_dac_fix = 1,
  2425. .input_mux = &alc880_capture_source,
  2426. },
  2427. [ALC880_LG] = {
  2428. .mixers = { alc880_lg_mixer },
  2429. .init_verbs = { alc880_volume_init_verbs,
  2430. alc880_lg_init_verbs },
  2431. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2432. .dac_nids = alc880_lg_dac_nids,
  2433. .dig_out_nid = ALC880_DIGOUT_NID,
  2434. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2435. .channel_mode = alc880_lg_ch_modes,
  2436. .need_dac_fix = 1,
  2437. .input_mux = &alc880_lg_capture_source,
  2438. .unsol_event = alc880_lg_unsol_event,
  2439. .init_hook = alc880_lg_automute,
  2440. },
  2441. [ALC880_LG_LW] = {
  2442. .mixers = { alc880_lg_lw_mixer },
  2443. .init_verbs = { alc880_volume_init_verbs,
  2444. alc880_lg_lw_init_verbs },
  2445. .num_dacs = 1,
  2446. .dac_nids = alc880_dac_nids,
  2447. .dig_out_nid = ALC880_DIGOUT_NID,
  2448. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2449. .channel_mode = alc880_2_jack_modes,
  2450. .input_mux = &alc880_lg_lw_capture_source,
  2451. .unsol_event = alc880_lg_lw_unsol_event,
  2452. .init_hook = alc880_lg_lw_automute,
  2453. },
  2454. #ifdef CONFIG_SND_DEBUG
  2455. [ALC880_TEST] = {
  2456. .mixers = { alc880_test_mixer },
  2457. .init_verbs = { alc880_test_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2459. .dac_nids = alc880_test_dac_nids,
  2460. .dig_out_nid = ALC880_DIGOUT_NID,
  2461. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2462. .channel_mode = alc880_test_modes,
  2463. .input_mux = &alc880_test_capture_source,
  2464. },
  2465. #endif
  2466. };
  2467. /*
  2468. * Automatic parse of I/O pins from the BIOS configuration
  2469. */
  2470. #define NUM_CONTROL_ALLOC 32
  2471. #define NUM_VERB_ALLOC 32
  2472. enum {
  2473. ALC_CTL_WIDGET_VOL,
  2474. ALC_CTL_WIDGET_MUTE,
  2475. ALC_CTL_BIND_MUTE,
  2476. };
  2477. static struct snd_kcontrol_new alc880_control_templates[] = {
  2478. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2479. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2480. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2481. };
  2482. /* add dynamic controls */
  2483. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2484. {
  2485. struct snd_kcontrol_new *knew;
  2486. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2487. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2488. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2489. if (! knew)
  2490. return -ENOMEM;
  2491. if (spec->kctl_alloc) {
  2492. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2493. kfree(spec->kctl_alloc);
  2494. }
  2495. spec->kctl_alloc = knew;
  2496. spec->num_kctl_alloc = num;
  2497. }
  2498. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2499. *knew = alc880_control_templates[type];
  2500. knew->name = kstrdup(name, GFP_KERNEL);
  2501. if (! knew->name)
  2502. return -ENOMEM;
  2503. knew->private_value = val;
  2504. spec->num_kctl_used++;
  2505. return 0;
  2506. }
  2507. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2508. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2509. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2510. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2511. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2512. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2513. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2514. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2515. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2516. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2517. #define ALC880_PIN_CD_NID 0x1c
  2518. /* fill in the dac_nids table from the parsed pin configuration */
  2519. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2520. {
  2521. hda_nid_t nid;
  2522. int assigned[4];
  2523. int i, j;
  2524. memset(assigned, 0, sizeof(assigned));
  2525. spec->multiout.dac_nids = spec->private_dac_nids;
  2526. /* check the pins hardwired to audio widget */
  2527. for (i = 0; i < cfg->line_outs; i++) {
  2528. nid = cfg->line_out_pins[i];
  2529. if (alc880_is_fixed_pin(nid)) {
  2530. int idx = alc880_fixed_pin_idx(nid);
  2531. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2532. assigned[idx] = 1;
  2533. }
  2534. }
  2535. /* left pins can be connect to any audio widget */
  2536. for (i = 0; i < cfg->line_outs; i++) {
  2537. nid = cfg->line_out_pins[i];
  2538. if (alc880_is_fixed_pin(nid))
  2539. continue;
  2540. /* search for an empty channel */
  2541. for (j = 0; j < cfg->line_outs; j++) {
  2542. if (! assigned[j]) {
  2543. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2544. assigned[j] = 1;
  2545. break;
  2546. }
  2547. }
  2548. }
  2549. spec->multiout.num_dacs = cfg->line_outs;
  2550. return 0;
  2551. }
  2552. /* add playback controls from the parsed DAC table */
  2553. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2554. const struct auto_pin_cfg *cfg)
  2555. {
  2556. char name[32];
  2557. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2558. hda_nid_t nid;
  2559. int i, err;
  2560. for (i = 0; i < cfg->line_outs; i++) {
  2561. if (! spec->multiout.dac_nids[i])
  2562. continue;
  2563. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2564. if (i == 2) {
  2565. /* Center/LFE */
  2566. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2567. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2568. return err;
  2569. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2570. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2571. return err;
  2572. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2573. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2574. return err;
  2575. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2576. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2577. return err;
  2578. } else {
  2579. sprintf(name, "%s Playback Volume", chname[i]);
  2580. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2581. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2582. return err;
  2583. sprintf(name, "%s Playback Switch", chname[i]);
  2584. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2585. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2586. return err;
  2587. }
  2588. }
  2589. return 0;
  2590. }
  2591. /* add playback controls for speaker and HP outputs */
  2592. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2593. const char *pfx)
  2594. {
  2595. hda_nid_t nid;
  2596. int err;
  2597. char name[32];
  2598. if (! pin)
  2599. return 0;
  2600. if (alc880_is_fixed_pin(pin)) {
  2601. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2602. /* specify the DAC as the extra output */
  2603. if (! spec->multiout.hp_nid)
  2604. spec->multiout.hp_nid = nid;
  2605. else
  2606. spec->multiout.extra_out_nid[0] = nid;
  2607. /* control HP volume/switch on the output mixer amp */
  2608. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2609. sprintf(name, "%s Playback Volume", pfx);
  2610. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2611. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2612. return err;
  2613. sprintf(name, "%s Playback Switch", pfx);
  2614. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2615. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2616. return err;
  2617. } else if (alc880_is_multi_pin(pin)) {
  2618. /* set manual connection */
  2619. /* we have only a switch on HP-out PIN */
  2620. sprintf(name, "%s Playback Switch", pfx);
  2621. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2622. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2623. return err;
  2624. }
  2625. return 0;
  2626. }
  2627. /* create input playback/capture controls for the given pin */
  2628. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2629. int idx, hda_nid_t mix_nid)
  2630. {
  2631. char name[32];
  2632. int err;
  2633. sprintf(name, "%s Playback Volume", ctlname);
  2634. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2635. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2636. return err;
  2637. sprintf(name, "%s Playback Switch", ctlname);
  2638. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2639. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2640. return err;
  2641. return 0;
  2642. }
  2643. /* create playback/capture controls for input pins */
  2644. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2645. const struct auto_pin_cfg *cfg)
  2646. {
  2647. struct hda_input_mux *imux = &spec->private_imux;
  2648. int i, err, idx;
  2649. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2650. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2651. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2652. err = new_analog_input(spec, cfg->input_pins[i],
  2653. auto_pin_cfg_labels[i],
  2654. idx, 0x0b);
  2655. if (err < 0)
  2656. return err;
  2657. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2658. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2659. imux->num_items++;
  2660. }
  2661. }
  2662. return 0;
  2663. }
  2664. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2665. hda_nid_t nid, int pin_type,
  2666. int dac_idx)
  2667. {
  2668. /* set as output */
  2669. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2670. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2671. /* need the manual connection? */
  2672. if (alc880_is_multi_pin(nid)) {
  2673. struct alc_spec *spec = codec->spec;
  2674. int idx = alc880_multi_pin_idx(nid);
  2675. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2676. AC_VERB_SET_CONNECT_SEL,
  2677. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2678. }
  2679. }
  2680. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2681. {
  2682. struct alc_spec *spec = codec->spec;
  2683. int i;
  2684. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2685. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2686. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2687. }
  2688. }
  2689. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2690. {
  2691. struct alc_spec *spec = codec->spec;
  2692. hda_nid_t pin;
  2693. pin = spec->autocfg.speaker_pins[0];
  2694. if (pin) /* connect to front */
  2695. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2696. pin = spec->autocfg.hp_pins[0];
  2697. if (pin) /* connect to front */
  2698. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2699. }
  2700. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2701. {
  2702. struct alc_spec *spec = codec->spec;
  2703. int i;
  2704. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2705. hda_nid_t nid = spec->autocfg.input_pins[i];
  2706. if (alc880_is_input_pin(nid)) {
  2707. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2708. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2709. if (nid != ALC880_PIN_CD_NID)
  2710. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2711. AMP_OUT_MUTE);
  2712. }
  2713. }
  2714. }
  2715. /* parse the BIOS configuration and set up the alc_spec */
  2716. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2717. static int alc880_parse_auto_config(struct hda_codec *codec)
  2718. {
  2719. struct alc_spec *spec = codec->spec;
  2720. int err;
  2721. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2722. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2723. alc880_ignore)) < 0)
  2724. return err;
  2725. if (! spec->autocfg.line_outs)
  2726. return 0; /* can't find valid BIOS pin config */
  2727. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2728. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2729. (err = alc880_auto_create_extra_out(spec,
  2730. spec->autocfg.speaker_pins[0],
  2731. "Speaker")) < 0 ||
  2732. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2733. "Headphone")) < 0 ||
  2734. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2735. return err;
  2736. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2737. if (spec->autocfg.dig_out_pin)
  2738. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2739. if (spec->autocfg.dig_in_pin)
  2740. spec->dig_in_nid = ALC880_DIGIN_NID;
  2741. if (spec->kctl_alloc)
  2742. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2743. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2744. spec->num_mux_defs = 1;
  2745. spec->input_mux = &spec->private_imux;
  2746. return 1;
  2747. }
  2748. /* additional initialization for auto-configuration model */
  2749. static void alc880_auto_init(struct hda_codec *codec)
  2750. {
  2751. alc880_auto_init_multi_out(codec);
  2752. alc880_auto_init_extra_out(codec);
  2753. alc880_auto_init_analog_input(codec);
  2754. }
  2755. /*
  2756. * OK, here we have finally the patch for ALC880
  2757. */
  2758. static int patch_alc880(struct hda_codec *codec)
  2759. {
  2760. struct alc_spec *spec;
  2761. int board_config;
  2762. int err;
  2763. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2764. if (spec == NULL)
  2765. return -ENOMEM;
  2766. codec->spec = spec;
  2767. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2768. alc880_models,
  2769. alc880_cfg_tbl);
  2770. if (board_config < 0) {
  2771. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2772. "trying auto-probe from BIOS...\n");
  2773. board_config = ALC880_AUTO;
  2774. }
  2775. if (board_config == ALC880_AUTO) {
  2776. /* automatic parse from the BIOS config */
  2777. err = alc880_parse_auto_config(codec);
  2778. if (err < 0) {
  2779. alc_free(codec);
  2780. return err;
  2781. } else if (! err) {
  2782. printk(KERN_INFO
  2783. "hda_codec: Cannot set up configuration "
  2784. "from BIOS. Using 3-stack mode...\n");
  2785. board_config = ALC880_3ST;
  2786. }
  2787. }
  2788. if (board_config != ALC880_AUTO)
  2789. setup_preset(spec, &alc880_presets[board_config]);
  2790. spec->stream_name_analog = "ALC880 Analog";
  2791. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2792. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2793. spec->stream_name_digital = "ALC880 Digital";
  2794. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2795. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2796. if (! spec->adc_nids && spec->input_mux) {
  2797. /* check whether NID 0x07 is valid */
  2798. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2799. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2800. if (wcap != AC_WID_AUD_IN) {
  2801. spec->adc_nids = alc880_adc_nids_alt;
  2802. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2803. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2804. spec->num_mixers++;
  2805. } else {
  2806. spec->adc_nids = alc880_adc_nids;
  2807. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2808. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2809. spec->num_mixers++;
  2810. }
  2811. }
  2812. codec->patch_ops = alc_patch_ops;
  2813. if (board_config == ALC880_AUTO)
  2814. spec->init_hook = alc880_auto_init;
  2815. return 0;
  2816. }
  2817. /*
  2818. * ALC260 support
  2819. */
  2820. static hda_nid_t alc260_dac_nids[1] = {
  2821. /* front */
  2822. 0x02,
  2823. };
  2824. static hda_nid_t alc260_adc_nids[1] = {
  2825. /* ADC0 */
  2826. 0x04,
  2827. };
  2828. static hda_nid_t alc260_adc_nids_alt[1] = {
  2829. /* ADC1 */
  2830. 0x05,
  2831. };
  2832. static hda_nid_t alc260_hp_adc_nids[2] = {
  2833. /* ADC1, 0 */
  2834. 0x05, 0x04
  2835. };
  2836. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2837. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2838. */
  2839. static hda_nid_t alc260_dual_adc_nids[2] = {
  2840. /* ADC0, ADC1 */
  2841. 0x04, 0x05
  2842. };
  2843. #define ALC260_DIGOUT_NID 0x03
  2844. #define ALC260_DIGIN_NID 0x06
  2845. static struct hda_input_mux alc260_capture_source = {
  2846. .num_items = 4,
  2847. .items = {
  2848. { "Mic", 0x0 },
  2849. { "Front Mic", 0x1 },
  2850. { "Line", 0x2 },
  2851. { "CD", 0x4 },
  2852. },
  2853. };
  2854. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2855. * headphone jack and the internal CD lines since these are the only pins at
  2856. * which audio can appear. For flexibility, also allow the option of
  2857. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2858. * connection to the mixer output).
  2859. */
  2860. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2861. {
  2862. .num_items = 3,
  2863. .items = {
  2864. { "Mic/Line", 0x0 },
  2865. { "CD", 0x4 },
  2866. { "Headphone", 0x2 },
  2867. },
  2868. },
  2869. {
  2870. .num_items = 4,
  2871. .items = {
  2872. { "Mic/Line", 0x0 },
  2873. { "CD", 0x4 },
  2874. { "Headphone", 0x2 },
  2875. { "Mixer", 0x5 },
  2876. },
  2877. },
  2878. };
  2879. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2880. * the Fujitsu S702x, but jacks are marked differently.
  2881. */
  2882. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2883. {
  2884. .num_items = 4,
  2885. .items = {
  2886. { "Mic", 0x0 },
  2887. { "Line", 0x2 },
  2888. { "CD", 0x4 },
  2889. { "Headphone", 0x5 },
  2890. },
  2891. },
  2892. {
  2893. .num_items = 5,
  2894. .items = {
  2895. { "Mic", 0x0 },
  2896. { "Line", 0x2 },
  2897. { "CD", 0x4 },
  2898. { "Headphone", 0x6 },
  2899. { "Mixer", 0x5 },
  2900. },
  2901. },
  2902. };
  2903. /*
  2904. * This is just place-holder, so there's something for alc_build_pcms to look
  2905. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2906. * element which allows changing the channel mode, so the verb list is
  2907. * never used.
  2908. */
  2909. static struct hda_channel_mode alc260_modes[1] = {
  2910. { 2, NULL },
  2911. };
  2912. /* Mixer combinations
  2913. *
  2914. * basic: base_output + input + pc_beep + capture
  2915. * HP: base_output + input + capture_alt
  2916. * HP_3013: hp_3013 + input + capture
  2917. * fujitsu: fujitsu + capture
  2918. * acer: acer + capture
  2919. */
  2920. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2921. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2922. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2923. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2924. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2925. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2926. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2927. { } /* end */
  2928. };
  2929. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2930. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2931. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2932. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2933. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2934. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2935. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2936. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2937. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2938. { } /* end */
  2939. };
  2940. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2941. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2942. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2943. { } /* end */
  2944. };
  2945. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2946. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2947. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2948. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2949. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2950. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2951. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2952. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2953. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2954. { } /* end */
  2955. };
  2956. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2957. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2958. */
  2959. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2960. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2961. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2962. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2963. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2964. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2965. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2966. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2967. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2968. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2969. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2970. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2971. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2972. { } /* end */
  2973. };
  2974. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2975. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2976. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2977. * datasheet doesn't mention this restriction. At this stage it's not clear
  2978. * whether this behaviour is intentional or is a hardware bug in chip
  2979. * revisions available in early 2006. Therefore for now allow the
  2980. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2981. * that the lack of mic bias for this NID is intentional we could change the
  2982. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2983. *
  2984. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2985. * don't appear to make the mic bias available from the "line" jack, even
  2986. * though the NID used for this jack (0x14) can supply it. The theory is
  2987. * that perhaps Acer have included blocking capacitors between the ALC260
  2988. * and the output jack. If this turns out to be the case for all such
  2989. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2990. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2991. *
  2992. * The C20x Tablet series have a mono internal speaker which is controlled
  2993. * via the chip's Mono sum widget and pin complex, so include the necessary
  2994. * controls for such models. On models without a "mono speaker" the control
  2995. * won't do anything.
  2996. */
  2997. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2998. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2999. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3000. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3001. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3002. HDA_OUTPUT),
  3003. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3004. HDA_INPUT),
  3005. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3006. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3007. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3008. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3009. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3010. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3011. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3012. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3013. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3014. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3015. { } /* end */
  3016. };
  3017. /* capture mixer elements */
  3018. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3019. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3020. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3021. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3022. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3023. {
  3024. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3025. /* The multiple "Capture Source" controls confuse alsamixer
  3026. * So call somewhat different..
  3027. * FIXME: the controls appear in the "playback" view!
  3028. */
  3029. /* .name = "Capture Source", */
  3030. .name = "Input Source",
  3031. .count = 2,
  3032. .info = alc_mux_enum_info,
  3033. .get = alc_mux_enum_get,
  3034. .put = alc_mux_enum_put,
  3035. },
  3036. { } /* end */
  3037. };
  3038. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3039. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3040. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3041. {
  3042. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3043. /* The multiple "Capture Source" controls confuse alsamixer
  3044. * So call somewhat different..
  3045. * FIXME: the controls appear in the "playback" view!
  3046. */
  3047. /* .name = "Capture Source", */
  3048. .name = "Input Source",
  3049. .count = 1,
  3050. .info = alc_mux_enum_info,
  3051. .get = alc_mux_enum_get,
  3052. .put = alc_mux_enum_put,
  3053. },
  3054. { } /* end */
  3055. };
  3056. /*
  3057. * initialization verbs
  3058. */
  3059. static struct hda_verb alc260_init_verbs[] = {
  3060. /* Line In pin widget for input */
  3061. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3062. /* CD pin widget for input */
  3063. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3064. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3065. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3066. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3067. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3068. /* LINE-2 is used for line-out in rear */
  3069. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3070. /* select line-out */
  3071. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3072. /* LINE-OUT pin */
  3073. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3074. /* enable HP */
  3075. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3076. /* enable Mono */
  3077. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3078. /* mute capture amp left and right */
  3079. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3080. /* set connection select to line in (default select for this ADC) */
  3081. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3082. /* mute capture amp left and right */
  3083. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3084. /* set connection select to line in (default select for this ADC) */
  3085. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3086. /* set vol=0 Line-Out mixer amp left and right */
  3087. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3088. /* unmute pin widget amp left and right (no gain on this amp) */
  3089. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3090. /* set vol=0 HP mixer amp left and right */
  3091. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3092. /* unmute pin widget amp left and right (no gain on this amp) */
  3093. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3094. /* set vol=0 Mono mixer amp left and right */
  3095. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3096. /* unmute pin widget amp left and right (no gain on this amp) */
  3097. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3098. /* unmute LINE-2 out pin */
  3099. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3100. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3101. /* mute CD */
  3102. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3103. /* mute Line In */
  3104. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3105. /* mute Mic */
  3106. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3107. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3108. /* mute Front out path */
  3109. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3110. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3111. /* mute Headphone out path */
  3112. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3113. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3114. /* mute Mono out path */
  3115. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3116. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3117. { }
  3118. };
  3119. #if 0 /* should be identical with alc260_init_verbs? */
  3120. static struct hda_verb alc260_hp_init_verbs[] = {
  3121. /* Headphone and output */
  3122. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3123. /* mono output */
  3124. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3125. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3126. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3127. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3128. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3129. /* Line In pin widget for input */
  3130. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3131. /* Line-2 pin widget for output */
  3132. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3133. /* CD pin widget for input */
  3134. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3135. /* unmute amp left and right */
  3136. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3137. /* set connection select to line in (default select for this ADC) */
  3138. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3139. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3140. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3141. /* mute pin widget amp left and right (no gain on this amp) */
  3142. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3143. /* unmute HP mixer amp left and right (volume = 0) */
  3144. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3145. /* mute pin widget amp left and right (no gain on this amp) */
  3146. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3147. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3148. /* unmute CD */
  3149. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3150. /* unmute Line In */
  3151. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3152. /* unmute Mic */
  3153. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3154. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3155. /* Unmute Front out path */
  3156. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3157. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3158. /* Unmute Headphone out path */
  3159. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3160. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3161. /* Unmute Mono out path */
  3162. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3163. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3164. { }
  3165. };
  3166. #endif
  3167. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3168. /* Line out and output */
  3169. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3170. /* mono output */
  3171. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3172. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3173. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3174. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3175. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3176. /* Line In pin widget for input */
  3177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3178. /* Headphone pin widget for output */
  3179. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3180. /* CD pin widget for input */
  3181. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3182. /* unmute amp left and right */
  3183. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3184. /* set connection select to line in (default select for this ADC) */
  3185. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3186. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3187. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3188. /* mute pin widget amp left and right (no gain on this amp) */
  3189. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3190. /* unmute HP mixer amp left and right (volume = 0) */
  3191. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3192. /* mute pin widget amp left and right (no gain on this amp) */
  3193. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3194. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3195. /* unmute CD */
  3196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3197. /* unmute Line In */
  3198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3199. /* unmute Mic */
  3200. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3201. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3202. /* Unmute Front out path */
  3203. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3204. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3205. /* Unmute Headphone out path */
  3206. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3207. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3208. /* Unmute Mono out path */
  3209. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3210. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3211. { }
  3212. };
  3213. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3214. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3215. * audio = 0x16, internal speaker = 0x10.
  3216. */
  3217. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3218. /* Disable all GPIOs */
  3219. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3220. /* Internal speaker is connected to headphone pin */
  3221. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3222. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3223. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3224. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3225. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3226. /* Ensure all other unused pins are disabled and muted. */
  3227. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3228. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3229. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3230. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3231. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3232. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3233. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3234. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3235. /* Disable digital (SPDIF) pins */
  3236. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3237. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3238. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3239. * when acting as an output.
  3240. */
  3241. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3242. /* Start with output sum widgets muted and their output gains at min */
  3243. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3244. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3245. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3246. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3247. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3248. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3249. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3250. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3251. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3252. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3253. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3254. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3255. * If the pin mode is changed by the user the pin mode control will
  3256. * take care of enabling the pin's input/output buffers as needed.
  3257. * Therefore there's no need to enable the input buffer at this
  3258. * stage.
  3259. */
  3260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3261. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3262. * mixer ctrl)
  3263. */
  3264. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3265. /* Mute capture amp left and right */
  3266. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. /* Set ADC connection select to match default mixer setting - line
  3268. * in (on mic1 pin)
  3269. */
  3270. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3271. /* Do the same for the second ADC: mute capture input amp and
  3272. * set ADC connection to line in (on mic1 pin)
  3273. */
  3274. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3275. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3276. /* Mute all inputs to mixer widget (even unconnected ones) */
  3277. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3278. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3279. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3280. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3281. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3282. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3283. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3284. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3285. { }
  3286. };
  3287. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3288. * similar laptops (adapted from Fujitsu init verbs).
  3289. */
  3290. static struct hda_verb alc260_acer_init_verbs[] = {
  3291. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3292. * the headphone jack. Turn this on and rely on the standard mute
  3293. * methods whenever the user wants to turn these outputs off.
  3294. */
  3295. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3296. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3297. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3298. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3299. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3300. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3301. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3302. /* Line In jack is connected to Line1 pin */
  3303. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3304. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3305. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3306. /* Ensure all other unused pins are disabled and muted. */
  3307. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3308. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3309. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3310. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3313. /* Disable digital (SPDIF) pins */
  3314. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3315. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3316. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3317. * bus when acting as outputs.
  3318. */
  3319. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3320. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3321. /* Start with output sum widgets muted and their output gains at min */
  3322. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3323. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3324. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3325. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3326. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3327. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3328. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3329. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3330. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3331. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3332. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3333. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3334. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3335. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3336. * inputs. If the pin mode is changed by the user the pin mode control
  3337. * will take care of enabling the pin's input/output buffers as needed.
  3338. * Therefore there's no need to enable the input buffer at this
  3339. * stage.
  3340. */
  3341. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3343. /* Mute capture amp left and right */
  3344. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3345. /* Set ADC connection select to match default mixer setting - mic
  3346. * (on mic1 pin)
  3347. */
  3348. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3349. /* Do similar with the second ADC: mute capture input amp and
  3350. * set ADC connection to mic to match ALSA's default state.
  3351. */
  3352. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3353. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3354. /* Mute all inputs to mixer widget (even unconnected ones) */
  3355. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3356. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3357. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3358. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3359. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3360. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3361. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3362. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3363. { }
  3364. };
  3365. /* Test configuration for debugging, modelled after the ALC880 test
  3366. * configuration.
  3367. */
  3368. #ifdef CONFIG_SND_DEBUG
  3369. static hda_nid_t alc260_test_dac_nids[1] = {
  3370. 0x02,
  3371. };
  3372. static hda_nid_t alc260_test_adc_nids[2] = {
  3373. 0x04, 0x05,
  3374. };
  3375. /* For testing the ALC260, each input MUX needs its own definition since
  3376. * the signal assignments are different. This assumes that the first ADC
  3377. * is NID 0x04.
  3378. */
  3379. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3380. {
  3381. .num_items = 7,
  3382. .items = {
  3383. { "MIC1 pin", 0x0 },
  3384. { "MIC2 pin", 0x1 },
  3385. { "LINE1 pin", 0x2 },
  3386. { "LINE2 pin", 0x3 },
  3387. { "CD pin", 0x4 },
  3388. { "LINE-OUT pin", 0x5 },
  3389. { "HP-OUT pin", 0x6 },
  3390. },
  3391. },
  3392. {
  3393. .num_items = 8,
  3394. .items = {
  3395. { "MIC1 pin", 0x0 },
  3396. { "MIC2 pin", 0x1 },
  3397. { "LINE1 pin", 0x2 },
  3398. { "LINE2 pin", 0x3 },
  3399. { "CD pin", 0x4 },
  3400. { "Mixer", 0x5 },
  3401. { "LINE-OUT pin", 0x6 },
  3402. { "HP-OUT pin", 0x7 },
  3403. },
  3404. },
  3405. };
  3406. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3407. /* Output driver widgets */
  3408. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3409. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3410. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3411. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3412. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3413. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3414. /* Modes for retasking pin widgets
  3415. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3416. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3417. * mention this restriction. At this stage it's not clear whether
  3418. * this behaviour is intentional or is a hardware bug in chip
  3419. * revisions available at least up until early 2006. Therefore for
  3420. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3421. * choices, but if it turns out that the lack of mic bias for these
  3422. * NIDs is intentional we could change their modes from
  3423. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3424. */
  3425. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3426. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3427. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3428. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3429. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3430. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3431. /* Loopback mixer controls */
  3432. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3433. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3434. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3435. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3436. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3437. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3438. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3439. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3440. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3441. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3442. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3443. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3444. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3445. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3446. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3447. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3448. /* Controls for GPIO pins, assuming they are configured as outputs */
  3449. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3450. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3451. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3452. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3453. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3454. * is ambigious as to which NID is which; testing on laptops which
  3455. * make this output available should provide clarification.
  3456. */
  3457. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3458. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3459. { } /* end */
  3460. };
  3461. static struct hda_verb alc260_test_init_verbs[] = {
  3462. /* Enable all GPIOs as outputs with an initial value of 0 */
  3463. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3464. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3465. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3466. /* Enable retasking pins as output, initially without power amp */
  3467. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3468. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3469. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3470. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3471. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3472. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3473. /* Disable digital (SPDIF) pins initially, but users can enable
  3474. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3475. * payload also sets the generation to 0, output to be in "consumer"
  3476. * PCM format, copyright asserted, no pre-emphasis and no validity
  3477. * control.
  3478. */
  3479. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3480. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3481. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3482. * OUT1 sum bus when acting as an output.
  3483. */
  3484. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3485. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3486. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3487. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3488. /* Start with output sum widgets muted and their output gains at min */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3495. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3498. /* Unmute retasking pin widget output buffers since the default
  3499. * state appears to be output. As the pin mode is changed by the
  3500. * user the pin mode control will take care of enabling the pin's
  3501. * input/output buffers as needed.
  3502. */
  3503. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3504. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3507. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3508. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3509. /* Also unmute the mono-out pin widget */
  3510. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3511. /* Mute capture amp left and right */
  3512. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. /* Set ADC connection select to match default mixer setting (mic1
  3514. * pin)
  3515. */
  3516. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3517. /* Do the same for the second ADC: mute capture input amp and
  3518. * set ADC connection to mic1 pin
  3519. */
  3520. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3522. /* Mute all inputs to mixer widget (even unconnected ones) */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3531. { }
  3532. };
  3533. #endif
  3534. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3535. .substreams = 1,
  3536. .channels_min = 2,
  3537. .channels_max = 2,
  3538. };
  3539. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3540. .substreams = 1,
  3541. .channels_min = 2,
  3542. .channels_max = 2,
  3543. };
  3544. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3545. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3546. /*
  3547. * for BIOS auto-configuration
  3548. */
  3549. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3550. const char *pfx)
  3551. {
  3552. hda_nid_t nid_vol;
  3553. unsigned long vol_val, sw_val;
  3554. char name[32];
  3555. int err;
  3556. if (nid >= 0x0f && nid < 0x11) {
  3557. nid_vol = nid - 0x7;
  3558. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3559. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3560. } else if (nid == 0x11) {
  3561. nid_vol = nid - 0x7;
  3562. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3563. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3564. } else if (nid >= 0x12 && nid <= 0x15) {
  3565. nid_vol = 0x08;
  3566. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3567. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3568. } else
  3569. return 0; /* N/A */
  3570. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3571. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3572. return err;
  3573. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3574. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3575. return err;
  3576. return 1;
  3577. }
  3578. /* add playback controls from the parsed DAC table */
  3579. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3580. const struct auto_pin_cfg *cfg)
  3581. {
  3582. hda_nid_t nid;
  3583. int err;
  3584. spec->multiout.num_dacs = 1;
  3585. spec->multiout.dac_nids = spec->private_dac_nids;
  3586. spec->multiout.dac_nids[0] = 0x02;
  3587. nid = cfg->line_out_pins[0];
  3588. if (nid) {
  3589. err = alc260_add_playback_controls(spec, nid, "Front");
  3590. if (err < 0)
  3591. return err;
  3592. }
  3593. nid = cfg->speaker_pins[0];
  3594. if (nid) {
  3595. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3596. if (err < 0)
  3597. return err;
  3598. }
  3599. nid = cfg->hp_pins[0];
  3600. if (nid) {
  3601. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3602. if (err < 0)
  3603. return err;
  3604. }
  3605. return 0;
  3606. }
  3607. /* create playback/capture controls for input pins */
  3608. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3609. const struct auto_pin_cfg *cfg)
  3610. {
  3611. struct hda_input_mux *imux = &spec->private_imux;
  3612. int i, err, idx;
  3613. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3614. if (cfg->input_pins[i] >= 0x12) {
  3615. idx = cfg->input_pins[i] - 0x12;
  3616. err = new_analog_input(spec, cfg->input_pins[i],
  3617. auto_pin_cfg_labels[i], idx, 0x07);
  3618. if (err < 0)
  3619. return err;
  3620. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3621. imux->items[imux->num_items].index = idx;
  3622. imux->num_items++;
  3623. }
  3624. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3625. idx = cfg->input_pins[i] - 0x09;
  3626. err = new_analog_input(spec, cfg->input_pins[i],
  3627. auto_pin_cfg_labels[i], idx, 0x07);
  3628. if (err < 0)
  3629. return err;
  3630. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3631. imux->items[imux->num_items].index = idx;
  3632. imux->num_items++;
  3633. }
  3634. }
  3635. return 0;
  3636. }
  3637. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3638. hda_nid_t nid, int pin_type,
  3639. int sel_idx)
  3640. {
  3641. /* set as output */
  3642. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3643. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3644. /* need the manual connection? */
  3645. if (nid >= 0x12) {
  3646. int idx = nid - 0x12;
  3647. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3648. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3649. }
  3650. }
  3651. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3652. {
  3653. struct alc_spec *spec = codec->spec;
  3654. hda_nid_t nid;
  3655. nid = spec->autocfg.line_out_pins[0];
  3656. if (nid)
  3657. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3658. nid = spec->autocfg.speaker_pins[0];
  3659. if (nid)
  3660. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3661. nid = spec->autocfg.hp_pins[0];
  3662. if (nid)
  3663. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3664. }
  3665. #define ALC260_PIN_CD_NID 0x16
  3666. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3667. {
  3668. struct alc_spec *spec = codec->spec;
  3669. int i;
  3670. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3671. hda_nid_t nid = spec->autocfg.input_pins[i];
  3672. if (nid >= 0x12) {
  3673. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3674. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3675. if (nid != ALC260_PIN_CD_NID)
  3676. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3677. AMP_OUT_MUTE);
  3678. }
  3679. }
  3680. }
  3681. /*
  3682. * generic initialization of ADC, input mixers and output mixers
  3683. */
  3684. static struct hda_verb alc260_volume_init_verbs[] = {
  3685. /*
  3686. * Unmute ADC0-1 and set the default input to mic-in
  3687. */
  3688. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3689. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3690. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3691. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3692. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3693. * mixer widget
  3694. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3695. * mic (mic 2)
  3696. */
  3697. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3698. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3699. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3700. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3701. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3702. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3703. /*
  3704. * Set up output mixers (0x08 - 0x0a)
  3705. */
  3706. /* set vol=0 to output mixers */
  3707. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3708. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3709. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3710. /* set up input amps for analog loopback */
  3711. /* Amp Indices: DAC = 0, mixer = 1 */
  3712. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3713. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3714. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3715. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3716. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3717. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3718. { }
  3719. };
  3720. static int alc260_parse_auto_config(struct hda_codec *codec)
  3721. {
  3722. struct alc_spec *spec = codec->spec;
  3723. unsigned int wcap;
  3724. int err;
  3725. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3726. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3727. alc260_ignore)) < 0)
  3728. return err;
  3729. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3730. return err;
  3731. if (! spec->kctl_alloc)
  3732. return 0; /* can't find valid BIOS pin config */
  3733. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3734. return err;
  3735. spec->multiout.max_channels = 2;
  3736. if (spec->autocfg.dig_out_pin)
  3737. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3738. if (spec->kctl_alloc)
  3739. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3740. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3741. spec->num_mux_defs = 1;
  3742. spec->input_mux = &spec->private_imux;
  3743. /* check whether NID 0x04 is valid */
  3744. wcap = get_wcaps(codec, 0x04);
  3745. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3746. if (wcap != AC_WID_AUD_IN) {
  3747. spec->adc_nids = alc260_adc_nids_alt;
  3748. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3749. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3750. } else {
  3751. spec->adc_nids = alc260_adc_nids;
  3752. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3753. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3754. }
  3755. spec->num_mixers++;
  3756. return 1;
  3757. }
  3758. /* additional initialization for auto-configuration model */
  3759. static void alc260_auto_init(struct hda_codec *codec)
  3760. {
  3761. alc260_auto_init_multi_out(codec);
  3762. alc260_auto_init_analog_input(codec);
  3763. }
  3764. /*
  3765. * ALC260 configurations
  3766. */
  3767. static const char *alc260_models[ALC260_MODEL_LAST] = {
  3768. [ALC260_BASIC] = "basic",
  3769. [ALC260_HP] = "hp",
  3770. [ALC260_HP_3013] = "hp-3013",
  3771. [ALC260_FUJITSU_S702X] = "fujitsu",
  3772. [ALC260_ACER] = "acer",
  3773. #ifdef CONFIG_SND_DEBUG
  3774. [ALC260_TEST] = "test",
  3775. #endif
  3776. [ALC260_AUTO] = "auto",
  3777. };
  3778. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  3779. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  3780. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  3781. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  3782. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  3783. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  3784. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  3785. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  3786. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  3787. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  3788. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  3789. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  3790. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  3791. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  3792. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  3793. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  3794. {}
  3795. };
  3796. static struct alc_config_preset alc260_presets[] = {
  3797. [ALC260_BASIC] = {
  3798. .mixers = { alc260_base_output_mixer,
  3799. alc260_input_mixer,
  3800. alc260_pc_beep_mixer,
  3801. alc260_capture_mixer },
  3802. .init_verbs = { alc260_init_verbs },
  3803. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3804. .dac_nids = alc260_dac_nids,
  3805. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3806. .adc_nids = alc260_adc_nids,
  3807. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3808. .channel_mode = alc260_modes,
  3809. .input_mux = &alc260_capture_source,
  3810. },
  3811. [ALC260_HP] = {
  3812. .mixers = { alc260_base_output_mixer,
  3813. alc260_input_mixer,
  3814. alc260_capture_alt_mixer },
  3815. .init_verbs = { alc260_init_verbs },
  3816. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3817. .dac_nids = alc260_dac_nids,
  3818. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3819. .adc_nids = alc260_hp_adc_nids,
  3820. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3821. .channel_mode = alc260_modes,
  3822. .input_mux = &alc260_capture_source,
  3823. },
  3824. [ALC260_HP_3013] = {
  3825. .mixers = { alc260_hp_3013_mixer,
  3826. alc260_input_mixer,
  3827. alc260_capture_alt_mixer },
  3828. .init_verbs = { alc260_hp_3013_init_verbs },
  3829. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3830. .dac_nids = alc260_dac_nids,
  3831. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3832. .adc_nids = alc260_hp_adc_nids,
  3833. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3834. .channel_mode = alc260_modes,
  3835. .input_mux = &alc260_capture_source,
  3836. },
  3837. [ALC260_FUJITSU_S702X] = {
  3838. .mixers = { alc260_fujitsu_mixer,
  3839. alc260_capture_mixer },
  3840. .init_verbs = { alc260_fujitsu_init_verbs },
  3841. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3842. .dac_nids = alc260_dac_nids,
  3843. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3844. .adc_nids = alc260_dual_adc_nids,
  3845. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3846. .channel_mode = alc260_modes,
  3847. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3848. .input_mux = alc260_fujitsu_capture_sources,
  3849. },
  3850. [ALC260_ACER] = {
  3851. .mixers = { alc260_acer_mixer,
  3852. alc260_capture_mixer },
  3853. .init_verbs = { alc260_acer_init_verbs },
  3854. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3855. .dac_nids = alc260_dac_nids,
  3856. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3857. .adc_nids = alc260_dual_adc_nids,
  3858. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3859. .channel_mode = alc260_modes,
  3860. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3861. .input_mux = alc260_acer_capture_sources,
  3862. },
  3863. #ifdef CONFIG_SND_DEBUG
  3864. [ALC260_TEST] = {
  3865. .mixers = { alc260_test_mixer,
  3866. alc260_capture_mixer },
  3867. .init_verbs = { alc260_test_init_verbs },
  3868. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3869. .dac_nids = alc260_test_dac_nids,
  3870. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3871. .adc_nids = alc260_test_adc_nids,
  3872. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3873. .channel_mode = alc260_modes,
  3874. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3875. .input_mux = alc260_test_capture_sources,
  3876. },
  3877. #endif
  3878. };
  3879. static int patch_alc260(struct hda_codec *codec)
  3880. {
  3881. struct alc_spec *spec;
  3882. int err, board_config;
  3883. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3884. if (spec == NULL)
  3885. return -ENOMEM;
  3886. codec->spec = spec;
  3887. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  3888. alc260_models,
  3889. alc260_cfg_tbl);
  3890. if (board_config < 0) {
  3891. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3892. "trying auto-probe from BIOS...\n");
  3893. board_config = ALC260_AUTO;
  3894. }
  3895. if (board_config == ALC260_AUTO) {
  3896. /* automatic parse from the BIOS config */
  3897. err = alc260_parse_auto_config(codec);
  3898. if (err < 0) {
  3899. alc_free(codec);
  3900. return err;
  3901. } else if (! err) {
  3902. printk(KERN_INFO
  3903. "hda_codec: Cannot set up configuration "
  3904. "from BIOS. Using base mode...\n");
  3905. board_config = ALC260_BASIC;
  3906. }
  3907. }
  3908. if (board_config != ALC260_AUTO)
  3909. setup_preset(spec, &alc260_presets[board_config]);
  3910. spec->stream_name_analog = "ALC260 Analog";
  3911. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3912. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3913. spec->stream_name_digital = "ALC260 Digital";
  3914. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3915. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3916. codec->patch_ops = alc_patch_ops;
  3917. if (board_config == ALC260_AUTO)
  3918. spec->init_hook = alc260_auto_init;
  3919. return 0;
  3920. }
  3921. /*
  3922. * ALC882 support
  3923. *
  3924. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3925. * configuration. Each pin widget can choose any input DACs and a mixer.
  3926. * Each ADC is connected from a mixer of all inputs. This makes possible
  3927. * 6-channel independent captures.
  3928. *
  3929. * In addition, an independent DAC for the multi-playback (not used in this
  3930. * driver yet).
  3931. */
  3932. #define ALC882_DIGOUT_NID 0x06
  3933. #define ALC882_DIGIN_NID 0x0a
  3934. static struct hda_channel_mode alc882_ch_modes[1] = {
  3935. { 8, NULL }
  3936. };
  3937. static hda_nid_t alc882_dac_nids[4] = {
  3938. /* front, rear, clfe, rear_surr */
  3939. 0x02, 0x03, 0x04, 0x05
  3940. };
  3941. /* identical with ALC880 */
  3942. #define alc882_adc_nids alc880_adc_nids
  3943. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3944. /* input MUX */
  3945. /* FIXME: should be a matrix-type input source selection */
  3946. static struct hda_input_mux alc882_capture_source = {
  3947. .num_items = 4,
  3948. .items = {
  3949. { "Mic", 0x0 },
  3950. { "Front Mic", 0x1 },
  3951. { "Line", 0x2 },
  3952. { "CD", 0x4 },
  3953. },
  3954. };
  3955. #define alc882_mux_enum_info alc_mux_enum_info
  3956. #define alc882_mux_enum_get alc_mux_enum_get
  3957. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3958. {
  3959. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3960. struct alc_spec *spec = codec->spec;
  3961. const struct hda_input_mux *imux = spec->input_mux;
  3962. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3963. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3964. hda_nid_t nid = capture_mixers[adc_idx];
  3965. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3966. unsigned int i, idx;
  3967. idx = ucontrol->value.enumerated.item[0];
  3968. if (idx >= imux->num_items)
  3969. idx = imux->num_items - 1;
  3970. if (*cur_val == idx && ! codec->in_resume)
  3971. return 0;
  3972. for (i = 0; i < imux->num_items; i++) {
  3973. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3974. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3975. v | (imux->items[i].index << 8));
  3976. }
  3977. *cur_val = idx;
  3978. return 1;
  3979. }
  3980. /*
  3981. * 6ch mode
  3982. */
  3983. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3984. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3985. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3986. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3987. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3988. { } /* end */
  3989. };
  3990. /*
  3991. * 8ch mode
  3992. */
  3993. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3994. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3995. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3996. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3997. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3998. { } /* end */
  3999. };
  4000. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4001. { 6, alc882_sixstack_ch6_init },
  4002. { 8, alc882_sixstack_ch8_init },
  4003. };
  4004. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4005. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4006. */
  4007. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4008. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4009. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4010. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4011. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4012. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4013. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4014. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4015. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4016. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4017. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4018. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4019. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4020. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4023. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4024. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4025. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4026. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4027. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4028. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4029. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4030. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4031. { } /* end */
  4032. };
  4033. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4034. {
  4035. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4036. .name = "Channel Mode",
  4037. .info = alc_ch_mode_info,
  4038. .get = alc_ch_mode_get,
  4039. .put = alc_ch_mode_put,
  4040. },
  4041. { } /* end */
  4042. };
  4043. static struct hda_verb alc882_init_verbs[] = {
  4044. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4045. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4046. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4047. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4048. /* Rear mixer */
  4049. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4050. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4051. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4052. /* CLFE mixer */
  4053. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4054. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4055. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4056. /* Side mixer */
  4057. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4058. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4059. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4060. /* Front Pin: output 0 (0x0c) */
  4061. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4062. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4063. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4064. /* Rear Pin: output 1 (0x0d) */
  4065. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4066. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4067. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4068. /* CLFE Pin: output 2 (0x0e) */
  4069. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4070. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4071. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4072. /* Side Pin: output 3 (0x0f) */
  4073. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4074. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4075. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4076. /* Mic (rear) pin: input vref at 80% */
  4077. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4078. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4079. /* Front Mic pin: input vref at 80% */
  4080. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4081. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4082. /* Line In pin: input */
  4083. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4084. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4085. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4086. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4087. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4088. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4089. /* CD pin widget for input */
  4090. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4091. /* FIXME: use matrix-type input source selection */
  4092. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4093. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4094. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4095. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4096. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4097. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4098. /* Input mixer2 */
  4099. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4100. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4101. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4102. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4103. /* Input mixer3 */
  4104. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4105. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4106. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4107. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4108. /* ADC1: mute amp left and right */
  4109. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4110. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4111. /* ADC2: mute amp left and right */
  4112. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4113. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4114. /* ADC3: mute amp left and right */
  4115. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4116. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4117. { }
  4118. };
  4119. static struct hda_verb alc882_eapd_verbs[] = {
  4120. /* change to EAPD mode */
  4121. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4122. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4123. { }
  4124. };
  4125. /* Mac Pro test */
  4126. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4127. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4128. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4129. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4130. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4131. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4132. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4133. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4134. { } /* end */
  4135. };
  4136. static struct hda_verb alc882_macpro_init_verbs[] = {
  4137. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4138. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4139. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4140. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4141. /* Front Pin: output 0 (0x0c) */
  4142. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4144. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4145. /* Front Mic pin: input vref at 80% */
  4146. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4147. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4148. /* Speaker: output */
  4149. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4150. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4151. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4152. /* Headphone output (output 0 - 0x0c) */
  4153. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4154. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4155. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4156. /* FIXME: use matrix-type input source selection */
  4157. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4158. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4159. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4160. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4161. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4162. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4163. /* Input mixer2 */
  4164. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4165. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4166. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4167. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4168. /* Input mixer3 */
  4169. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4170. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4171. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4172. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4173. /* ADC1: mute amp left and right */
  4174. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4175. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4176. /* ADC2: mute amp left and right */
  4177. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4178. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4179. /* ADC3: mute amp left and right */
  4180. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4181. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4182. { }
  4183. };
  4184. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4185. {
  4186. unsigned int gpiostate, gpiomask, gpiodir;
  4187. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4188. AC_VERB_GET_GPIO_DATA, 0);
  4189. if (!muted)
  4190. gpiostate |= (1 << pin);
  4191. else
  4192. gpiostate &= ~(1 << pin);
  4193. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4194. AC_VERB_GET_GPIO_MASK, 0);
  4195. gpiomask |= (1 << pin);
  4196. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4197. AC_VERB_GET_GPIO_DIRECTION, 0);
  4198. gpiodir |= (1 << pin);
  4199. snd_hda_codec_write(codec, codec->afg, 0,
  4200. AC_VERB_SET_GPIO_MASK, gpiomask);
  4201. snd_hda_codec_write(codec, codec->afg, 0,
  4202. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4203. msleep(1);
  4204. snd_hda_codec_write(codec, codec->afg, 0,
  4205. AC_VERB_SET_GPIO_DATA, gpiostate);
  4206. }
  4207. /*
  4208. * generic initialization of ADC, input mixers and output mixers
  4209. */
  4210. static struct hda_verb alc882_auto_init_verbs[] = {
  4211. /*
  4212. * Unmute ADC0-2 and set the default input to mic-in
  4213. */
  4214. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4215. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4216. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4217. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4218. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4219. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4220. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4221. * mixer widget
  4222. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4223. * mic (mic 2)
  4224. */
  4225. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4226. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4227. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4230. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4231. /*
  4232. * Set up output mixers (0x0c - 0x0f)
  4233. */
  4234. /* set vol=0 to output mixers */
  4235. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4239. /* set up input amps for analog loopback */
  4240. /* Amp Indices: DAC = 0, mixer = 1 */
  4241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4247. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4248. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4249. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4250. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4251. /* FIXME: use matrix-type input source selection */
  4252. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4253. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4254. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4255. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4256. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4257. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4258. /* Input mixer2 */
  4259. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4260. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4261. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4262. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4263. /* Input mixer3 */
  4264. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4265. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4266. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4267. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4268. { }
  4269. };
  4270. /* capture mixer elements */
  4271. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4272. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4273. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4274. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4275. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4276. {
  4277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4278. /* The multiple "Capture Source" controls confuse alsamixer
  4279. * So call somewhat different..
  4280. * FIXME: the controls appear in the "playback" view!
  4281. */
  4282. /* .name = "Capture Source", */
  4283. .name = "Input Source",
  4284. .count = 2,
  4285. .info = alc882_mux_enum_info,
  4286. .get = alc882_mux_enum_get,
  4287. .put = alc882_mux_enum_put,
  4288. },
  4289. { } /* end */
  4290. };
  4291. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4292. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4293. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4294. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4295. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4296. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4297. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4298. {
  4299. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4300. /* The multiple "Capture Source" controls confuse alsamixer
  4301. * So call somewhat different..
  4302. * FIXME: the controls appear in the "playback" view!
  4303. */
  4304. /* .name = "Capture Source", */
  4305. .name = "Input Source",
  4306. .count = 3,
  4307. .info = alc882_mux_enum_info,
  4308. .get = alc882_mux_enum_get,
  4309. .put = alc882_mux_enum_put,
  4310. },
  4311. { } /* end */
  4312. };
  4313. /* pcm configuration: identiacal with ALC880 */
  4314. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4315. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4316. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4317. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4318. /*
  4319. * configuration and preset
  4320. */
  4321. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4322. [ALC882_3ST_DIG] = "3stack-dig",
  4323. [ALC882_6ST_DIG] = "6stack-dig",
  4324. [ALC882_ARIMA] = "arima",
  4325. [ALC885_MACPRO] = "macpro",
  4326. [ALC882_AUTO] = "auto",
  4327. };
  4328. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4329. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4330. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4331. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4332. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4333. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4334. {}
  4335. };
  4336. static struct alc_config_preset alc882_presets[] = {
  4337. [ALC882_3ST_DIG] = {
  4338. .mixers = { alc882_base_mixer },
  4339. .init_verbs = { alc882_init_verbs },
  4340. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4341. .dac_nids = alc882_dac_nids,
  4342. .dig_out_nid = ALC882_DIGOUT_NID,
  4343. .dig_in_nid = ALC882_DIGIN_NID,
  4344. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4345. .channel_mode = alc882_ch_modes,
  4346. .need_dac_fix = 1,
  4347. .input_mux = &alc882_capture_source,
  4348. },
  4349. [ALC882_6ST_DIG] = {
  4350. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4351. .init_verbs = { alc882_init_verbs },
  4352. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4353. .dac_nids = alc882_dac_nids,
  4354. .dig_out_nid = ALC882_DIGOUT_NID,
  4355. .dig_in_nid = ALC882_DIGIN_NID,
  4356. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4357. .channel_mode = alc882_sixstack_modes,
  4358. .input_mux = &alc882_capture_source,
  4359. },
  4360. [ALC882_ARIMA] = {
  4361. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4362. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4363. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4364. .dac_nids = alc882_dac_nids,
  4365. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4366. .channel_mode = alc882_sixstack_modes,
  4367. .input_mux = &alc882_capture_source,
  4368. },
  4369. [ALC885_MACPRO] = {
  4370. .mixers = { alc882_macpro_mixer },
  4371. .init_verbs = { alc882_macpro_init_verbs },
  4372. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4373. .dac_nids = alc882_dac_nids,
  4374. .dig_out_nid = ALC882_DIGOUT_NID,
  4375. .dig_in_nid = ALC882_DIGIN_NID,
  4376. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4377. .channel_mode = alc882_ch_modes,
  4378. .input_mux = &alc882_capture_source,
  4379. },
  4380. };
  4381. /*
  4382. * BIOS auto configuration
  4383. */
  4384. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4385. hda_nid_t nid, int pin_type,
  4386. int dac_idx)
  4387. {
  4388. /* set as output */
  4389. struct alc_spec *spec = codec->spec;
  4390. int idx;
  4391. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4392. idx = 4;
  4393. else
  4394. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4395. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4396. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4397. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4398. }
  4399. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4400. {
  4401. struct alc_spec *spec = codec->spec;
  4402. int i;
  4403. for (i = 0; i <= HDA_SIDE; i++) {
  4404. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4405. if (nid)
  4406. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4407. }
  4408. }
  4409. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4410. {
  4411. struct alc_spec *spec = codec->spec;
  4412. hda_nid_t pin;
  4413. pin = spec->autocfg.hp_pins[0];
  4414. if (pin) /* connect to front */
  4415. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4416. }
  4417. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4418. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4419. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4420. {
  4421. struct alc_spec *spec = codec->spec;
  4422. int i;
  4423. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4424. hda_nid_t nid = spec->autocfg.input_pins[i];
  4425. if (alc882_is_input_pin(nid)) {
  4426. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4427. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4428. if (nid != ALC882_PIN_CD_NID)
  4429. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4430. AMP_OUT_MUTE);
  4431. }
  4432. }
  4433. }
  4434. /* almost identical with ALC880 parser... */
  4435. static int alc882_parse_auto_config(struct hda_codec *codec)
  4436. {
  4437. struct alc_spec *spec = codec->spec;
  4438. int err = alc880_parse_auto_config(codec);
  4439. if (err < 0)
  4440. return err;
  4441. else if (err > 0)
  4442. /* hack - override the init verbs */
  4443. spec->init_verbs[0] = alc882_auto_init_verbs;
  4444. return err;
  4445. }
  4446. /* additional initialization for auto-configuration model */
  4447. static void alc882_auto_init(struct hda_codec *codec)
  4448. {
  4449. alc882_auto_init_multi_out(codec);
  4450. alc882_auto_init_hp_out(codec);
  4451. alc882_auto_init_analog_input(codec);
  4452. }
  4453. static int patch_alc882(struct hda_codec *codec)
  4454. {
  4455. struct alc_spec *spec;
  4456. int err, board_config;
  4457. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4458. if (spec == NULL)
  4459. return -ENOMEM;
  4460. codec->spec = spec;
  4461. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4462. alc882_models,
  4463. alc882_cfg_tbl);
  4464. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4465. /* Pick up systems that don't supply PCI SSID */
  4466. switch (codec->subsystem_id) {
  4467. case 0x106b0c00: /* Mac Pro */
  4468. board_config = ALC885_MACPRO;
  4469. break;
  4470. default:
  4471. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4472. "trying auto-probe from BIOS...\n");
  4473. board_config = ALC882_AUTO;
  4474. }
  4475. }
  4476. if (board_config == ALC882_AUTO) {
  4477. /* automatic parse from the BIOS config */
  4478. err = alc882_parse_auto_config(codec);
  4479. if (err < 0) {
  4480. alc_free(codec);
  4481. return err;
  4482. } else if (! err) {
  4483. printk(KERN_INFO
  4484. "hda_codec: Cannot set up configuration "
  4485. "from BIOS. Using base mode...\n");
  4486. board_config = ALC882_3ST_DIG;
  4487. }
  4488. }
  4489. if (board_config != ALC882_AUTO)
  4490. setup_preset(spec, &alc882_presets[board_config]);
  4491. if (board_config == ALC885_MACPRO) {
  4492. alc882_gpio_mute(codec, 0, 0);
  4493. alc882_gpio_mute(codec, 1, 0);
  4494. }
  4495. spec->stream_name_analog = "ALC882 Analog";
  4496. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4497. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4498. spec->stream_name_digital = "ALC882 Digital";
  4499. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4500. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4501. if (! spec->adc_nids && spec->input_mux) {
  4502. /* check whether NID 0x07 is valid */
  4503. unsigned int wcap = get_wcaps(codec, 0x07);
  4504. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4505. if (wcap != AC_WID_AUD_IN) {
  4506. spec->adc_nids = alc882_adc_nids_alt;
  4507. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4508. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4509. spec->num_mixers++;
  4510. } else {
  4511. spec->adc_nids = alc882_adc_nids;
  4512. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4513. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4514. spec->num_mixers++;
  4515. }
  4516. }
  4517. codec->patch_ops = alc_patch_ops;
  4518. if (board_config == ALC882_AUTO)
  4519. spec->init_hook = alc882_auto_init;
  4520. return 0;
  4521. }
  4522. /*
  4523. * ALC883 support
  4524. *
  4525. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4526. * configuration. Each pin widget can choose any input DACs and a mixer.
  4527. * Each ADC is connected from a mixer of all inputs. This makes possible
  4528. * 6-channel independent captures.
  4529. *
  4530. * In addition, an independent DAC for the multi-playback (not used in this
  4531. * driver yet).
  4532. */
  4533. #define ALC883_DIGOUT_NID 0x06
  4534. #define ALC883_DIGIN_NID 0x0a
  4535. static hda_nid_t alc883_dac_nids[4] = {
  4536. /* front, rear, clfe, rear_surr */
  4537. 0x02, 0x04, 0x03, 0x05
  4538. };
  4539. static hda_nid_t alc883_adc_nids[2] = {
  4540. /* ADC1-2 */
  4541. 0x08, 0x09,
  4542. };
  4543. /* input MUX */
  4544. /* FIXME: should be a matrix-type input source selection */
  4545. static struct hda_input_mux alc883_capture_source = {
  4546. .num_items = 4,
  4547. .items = {
  4548. { "Mic", 0x0 },
  4549. { "Front Mic", 0x1 },
  4550. { "Line", 0x2 },
  4551. { "CD", 0x4 },
  4552. },
  4553. };
  4554. #define alc883_mux_enum_info alc_mux_enum_info
  4555. #define alc883_mux_enum_get alc_mux_enum_get
  4556. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4557. struct snd_ctl_elem_value *ucontrol)
  4558. {
  4559. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4560. struct alc_spec *spec = codec->spec;
  4561. const struct hda_input_mux *imux = spec->input_mux;
  4562. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4563. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4564. hda_nid_t nid = capture_mixers[adc_idx];
  4565. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4566. unsigned int i, idx;
  4567. idx = ucontrol->value.enumerated.item[0];
  4568. if (idx >= imux->num_items)
  4569. idx = imux->num_items - 1;
  4570. if (*cur_val == idx && ! codec->in_resume)
  4571. return 0;
  4572. for (i = 0; i < imux->num_items; i++) {
  4573. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4574. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4575. v | (imux->items[i].index << 8));
  4576. }
  4577. *cur_val = idx;
  4578. return 1;
  4579. }
  4580. /*
  4581. * 2ch mode
  4582. */
  4583. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4584. { 2, NULL }
  4585. };
  4586. /*
  4587. * 2ch mode
  4588. */
  4589. static struct hda_verb alc883_3ST_ch2_init[] = {
  4590. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4591. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4592. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4593. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4594. { } /* end */
  4595. };
  4596. /*
  4597. * 6ch mode
  4598. */
  4599. static struct hda_verb alc883_3ST_ch6_init[] = {
  4600. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4601. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4602. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4603. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4604. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4605. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4606. { } /* end */
  4607. };
  4608. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4609. { 2, alc883_3ST_ch2_init },
  4610. { 6, alc883_3ST_ch6_init },
  4611. };
  4612. /*
  4613. * 6ch mode
  4614. */
  4615. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4616. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4617. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4618. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4619. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4620. { } /* end */
  4621. };
  4622. /*
  4623. * 8ch mode
  4624. */
  4625. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4626. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4627. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4628. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4629. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4630. { } /* end */
  4631. };
  4632. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4633. { 6, alc883_sixstack_ch6_init },
  4634. { 8, alc883_sixstack_ch8_init },
  4635. };
  4636. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4637. /* eanable EAPD on medion laptop */
  4638. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4639. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4640. { }
  4641. };
  4642. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4643. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4644. */
  4645. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4646. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4647. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4648. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4649. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4650. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4651. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4652. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4653. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4654. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4655. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4656. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4657. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4658. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4659. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4660. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4661. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4662. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4663. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4664. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4665. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4666. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4667. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4668. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4671. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4672. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4673. {
  4674. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4675. /* .name = "Capture Source", */
  4676. .name = "Input Source",
  4677. .count = 2,
  4678. .info = alc883_mux_enum_info,
  4679. .get = alc883_mux_enum_get,
  4680. .put = alc883_mux_enum_put,
  4681. },
  4682. { } /* end */
  4683. };
  4684. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4685. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4686. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4687. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4688. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4689. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4690. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4691. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4692. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4693. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4694. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4695. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4696. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4697. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4698. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4699. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4700. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4701. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4702. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4703. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4704. {
  4705. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4706. /* .name = "Capture Source", */
  4707. .name = "Input Source",
  4708. .count = 2,
  4709. .info = alc883_mux_enum_info,
  4710. .get = alc883_mux_enum_get,
  4711. .put = alc883_mux_enum_put,
  4712. },
  4713. { } /* end */
  4714. };
  4715. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4716. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4717. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4718. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4719. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4720. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4721. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4722. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4723. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4724. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4725. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4726. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4730. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4732. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4733. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4734. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4735. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4736. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4737. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4738. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4739. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4740. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4741. {
  4742. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4743. /* .name = "Capture Source", */
  4744. .name = "Input Source",
  4745. .count = 2,
  4746. .info = alc883_mux_enum_info,
  4747. .get = alc883_mux_enum_get,
  4748. .put = alc883_mux_enum_put,
  4749. },
  4750. { } /* end */
  4751. };
  4752. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  4753. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4754. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4755. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4756. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4757. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4758. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4759. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4760. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4761. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4762. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4763. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4764. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4765. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4766. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4767. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4768. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4769. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4770. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4771. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4772. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4773. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4774. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4775. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4776. {
  4777. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4778. /* .name = "Capture Source", */
  4779. .name = "Input Source",
  4780. .count = 1,
  4781. .info = alc883_mux_enum_info,
  4782. .get = alc883_mux_enum_get,
  4783. .put = alc883_mux_enum_put,
  4784. },
  4785. { } /* end */
  4786. };
  4787. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  4788. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4789. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4790. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4791. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4792. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4793. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4794. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4795. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4796. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4797. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4798. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4799. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4800. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4801. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4802. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4803. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4804. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4805. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4806. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4807. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4808. {
  4809. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4810. /* .name = "Capture Source", */
  4811. .name = "Input Source",
  4812. .count = 2,
  4813. .info = alc883_mux_enum_info,
  4814. .get = alc883_mux_enum_get,
  4815. .put = alc883_mux_enum_put,
  4816. },
  4817. { } /* end */
  4818. };
  4819. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  4820. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4821. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4822. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4823. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4824. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4825. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4826. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4827. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4828. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4829. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4830. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4831. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4832. {
  4833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4834. /* .name = "Capture Source", */
  4835. .name = "Input Source",
  4836. .count = 2,
  4837. .info = alc883_mux_enum_info,
  4838. .get = alc883_mux_enum_get,
  4839. .put = alc883_mux_enum_put,
  4840. },
  4841. { } /* end */
  4842. };
  4843. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4844. {
  4845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4846. .name = "Channel Mode",
  4847. .info = alc_ch_mode_info,
  4848. .get = alc_ch_mode_get,
  4849. .put = alc_ch_mode_put,
  4850. },
  4851. { } /* end */
  4852. };
  4853. static struct hda_verb alc883_init_verbs[] = {
  4854. /* ADC1: mute amp left and right */
  4855. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4856. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4857. /* ADC2: mute amp left and right */
  4858. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4859. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4860. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4863. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4864. /* Rear mixer */
  4865. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4866. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4867. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4868. /* CLFE mixer */
  4869. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4870. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4871. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4872. /* Side mixer */
  4873. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4874. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4875. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4881. /* Front Pin: output 0 (0x0c) */
  4882. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4883. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4884. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4885. /* Rear Pin: output 1 (0x0d) */
  4886. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4887. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4888. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4889. /* CLFE Pin: output 2 (0x0e) */
  4890. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4891. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4892. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4893. /* Side Pin: output 3 (0x0f) */
  4894. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4895. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4896. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4897. /* Mic (rear) pin: input vref at 80% */
  4898. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4899. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4900. /* Front Mic pin: input vref at 80% */
  4901. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4902. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4903. /* Line In pin: input */
  4904. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4905. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4906. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4907. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4908. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4909. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4910. /* CD pin widget for input */
  4911. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4912. /* FIXME: use matrix-type input source selection */
  4913. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4914. /* Input mixer2 */
  4915. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4916. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4917. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4918. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4919. /* Input mixer3 */
  4920. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4921. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4922. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4923. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4924. { }
  4925. };
  4926. static struct hda_verb alc883_tagra_verbs[] = {
  4927. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4928. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4929. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4930. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4931. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4932. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4933. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4934. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4935. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4936. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4937. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4938. { } /* end */
  4939. };
  4940. /* toggle speaker-output according to the hp-jack state */
  4941. static void alc883_tagra_automute(struct hda_codec *codec)
  4942. {
  4943. unsigned int present;
  4944. present = snd_hda_codec_read(codec, 0x14, 0,
  4945. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4946. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4947. 0x80, present ? 0x80 : 0);
  4948. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4949. 0x80, present ? 0x80 : 0);
  4950. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4951. }
  4952. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  4953. {
  4954. if ((res >> 26) == ALC880_HP_EVENT)
  4955. alc883_tagra_automute(codec);
  4956. }
  4957. /*
  4958. * generic initialization of ADC, input mixers and output mixers
  4959. */
  4960. static struct hda_verb alc883_auto_init_verbs[] = {
  4961. /*
  4962. * Unmute ADC0-2 and set the default input to mic-in
  4963. */
  4964. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4965. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4966. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4967. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4968. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4969. * mixer widget
  4970. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4971. * mic (mic 2)
  4972. */
  4973. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4974. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4975. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4976. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4979. /*
  4980. * Set up output mixers (0x0c - 0x0f)
  4981. */
  4982. /* set vol=0 to output mixers */
  4983. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4984. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4985. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4986. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4987. /* set up input amps for analog loopback */
  4988. /* Amp Indices: DAC = 0, mixer = 1 */
  4989. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4990. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4991. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4992. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4993. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4994. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4995. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4996. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4997. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4998. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4999. /* FIXME: use matrix-type input source selection */
  5000. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5001. /* Input mixer1 */
  5002. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5003. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5004. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5005. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5006. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5007. /* Input mixer2 */
  5008. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5009. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5010. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5011. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5012. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5013. { }
  5014. };
  5015. /* capture mixer elements */
  5016. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5017. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5018. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5019. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5020. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5021. {
  5022. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5023. /* The multiple "Capture Source" controls confuse alsamixer
  5024. * So call somewhat different..
  5025. * FIXME: the controls appear in the "playback" view!
  5026. */
  5027. /* .name = "Capture Source", */
  5028. .name = "Input Source",
  5029. .count = 2,
  5030. .info = alc882_mux_enum_info,
  5031. .get = alc882_mux_enum_get,
  5032. .put = alc882_mux_enum_put,
  5033. },
  5034. { } /* end */
  5035. };
  5036. /* pcm configuration: identiacal with ALC880 */
  5037. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5038. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5039. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5040. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5041. /*
  5042. * configuration and preset
  5043. */
  5044. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5045. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5046. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5047. [ALC883_3ST_6ch] = "3stack-6ch",
  5048. [ALC883_6ST_DIG] = "6stack-dig",
  5049. [ALC883_TARGA_DIG] = "targa-dig",
  5050. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5051. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  5052. [ALC883_ACER] = "acer",
  5053. [ALC883_MEDION] = "medion",
  5054. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5055. [ALC883_AUTO] = "auto",
  5056. };
  5057. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5058. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5059. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5060. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5061. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5062. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5063. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5064. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5065. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5066. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5067. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5068. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5069. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5070. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5071. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5072. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5073. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5074. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5075. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5076. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5077. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5078. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5079. {}
  5080. };
  5081. static struct alc_config_preset alc883_presets[] = {
  5082. [ALC883_3ST_2ch_DIG] = {
  5083. .mixers = { alc883_3ST_2ch_mixer },
  5084. .init_verbs = { alc883_init_verbs },
  5085. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5086. .dac_nids = alc883_dac_nids,
  5087. .dig_out_nid = ALC883_DIGOUT_NID,
  5088. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5089. .adc_nids = alc883_adc_nids,
  5090. .dig_in_nid = ALC883_DIGIN_NID,
  5091. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5092. .channel_mode = alc883_3ST_2ch_modes,
  5093. .input_mux = &alc883_capture_source,
  5094. },
  5095. [ALC883_3ST_6ch_DIG] = {
  5096. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5097. .init_verbs = { alc883_init_verbs },
  5098. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5099. .dac_nids = alc883_dac_nids,
  5100. .dig_out_nid = ALC883_DIGOUT_NID,
  5101. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5102. .adc_nids = alc883_adc_nids,
  5103. .dig_in_nid = ALC883_DIGIN_NID,
  5104. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5105. .channel_mode = alc883_3ST_6ch_modes,
  5106. .need_dac_fix = 1,
  5107. .input_mux = &alc883_capture_source,
  5108. },
  5109. [ALC883_3ST_6ch] = {
  5110. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5111. .init_verbs = { alc883_init_verbs },
  5112. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5113. .dac_nids = alc883_dac_nids,
  5114. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5115. .adc_nids = alc883_adc_nids,
  5116. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5117. .channel_mode = alc883_3ST_6ch_modes,
  5118. .need_dac_fix = 1,
  5119. .input_mux = &alc883_capture_source,
  5120. },
  5121. [ALC883_6ST_DIG] = {
  5122. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5123. .init_verbs = { alc883_init_verbs },
  5124. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5125. .dac_nids = alc883_dac_nids,
  5126. .dig_out_nid = ALC883_DIGOUT_NID,
  5127. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5128. .adc_nids = alc883_adc_nids,
  5129. .dig_in_nid = ALC883_DIGIN_NID,
  5130. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5131. .channel_mode = alc883_sixstack_modes,
  5132. .input_mux = &alc883_capture_source,
  5133. },
  5134. [ALC883_TARGA_DIG] = {
  5135. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5136. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5137. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5138. .dac_nids = alc883_dac_nids,
  5139. .dig_out_nid = ALC883_DIGOUT_NID,
  5140. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5141. .adc_nids = alc883_adc_nids,
  5142. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5143. .channel_mode = alc883_3ST_6ch_modes,
  5144. .need_dac_fix = 1,
  5145. .input_mux = &alc883_capture_source,
  5146. .unsol_event = alc883_tagra_unsol_event,
  5147. .init_hook = alc883_tagra_automute,
  5148. },
  5149. [ALC883_TARGA_2ch_DIG] = {
  5150. .mixers = { alc883_tagra_2ch_mixer},
  5151. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5152. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5153. .dac_nids = alc883_dac_nids,
  5154. .dig_out_nid = ALC883_DIGOUT_NID,
  5155. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5156. .adc_nids = alc883_adc_nids,
  5157. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5158. .channel_mode = alc883_3ST_2ch_modes,
  5159. .input_mux = &alc883_capture_source,
  5160. .unsol_event = alc883_tagra_unsol_event,
  5161. .init_hook = alc883_tagra_automute,
  5162. },
  5163. [ALC888_DEMO_BOARD] = {
  5164. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5165. .init_verbs = { alc883_init_verbs },
  5166. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5167. .dac_nids = alc883_dac_nids,
  5168. .dig_out_nid = ALC883_DIGOUT_NID,
  5169. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5170. .adc_nids = alc883_adc_nids,
  5171. .dig_in_nid = ALC883_DIGIN_NID,
  5172. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5173. .channel_mode = alc883_sixstack_modes,
  5174. .input_mux = &alc883_capture_source,
  5175. },
  5176. [ALC883_ACER] = {
  5177. .mixers = { alc883_base_mixer,
  5178. alc883_chmode_mixer },
  5179. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5180. * and the headphone jack. Turn this on and rely on the
  5181. * standard mute methods whenever the user wants to turn
  5182. * these outputs off.
  5183. */
  5184. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5185. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5186. .dac_nids = alc883_dac_nids,
  5187. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5188. .adc_nids = alc883_adc_nids,
  5189. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5190. .channel_mode = alc883_3ST_2ch_modes,
  5191. .input_mux = &alc883_capture_source,
  5192. },
  5193. [ALC883_MEDION] = {
  5194. .mixers = { alc883_fivestack_mixer,
  5195. alc883_chmode_mixer },
  5196. .init_verbs = { alc883_init_verbs,
  5197. alc883_medion_eapd_verbs },
  5198. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5199. .dac_nids = alc883_dac_nids,
  5200. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5201. .adc_nids = alc883_adc_nids,
  5202. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5203. .channel_mode = alc883_sixstack_modes,
  5204. .input_mux = &alc883_capture_source,
  5205. },
  5206. [ALC883_LAPTOP_EAPD] = {
  5207. .mixers = { alc883_base_mixer,
  5208. alc883_chmode_mixer },
  5209. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5210. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5211. .dac_nids = alc883_dac_nids,
  5212. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5213. .adc_nids = alc883_adc_nids,
  5214. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5215. .channel_mode = alc883_3ST_2ch_modes,
  5216. .input_mux = &alc883_capture_source,
  5217. },
  5218. };
  5219. /*
  5220. * BIOS auto configuration
  5221. */
  5222. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5223. hda_nid_t nid, int pin_type,
  5224. int dac_idx)
  5225. {
  5226. /* set as output */
  5227. struct alc_spec *spec = codec->spec;
  5228. int idx;
  5229. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5230. idx = 4;
  5231. else
  5232. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5233. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5234. pin_type);
  5235. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5236. AMP_OUT_UNMUTE);
  5237. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5238. }
  5239. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5240. {
  5241. struct alc_spec *spec = codec->spec;
  5242. int i;
  5243. for (i = 0; i <= HDA_SIDE; i++) {
  5244. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5245. if (nid)
  5246. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  5247. }
  5248. }
  5249. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5250. {
  5251. struct alc_spec *spec = codec->spec;
  5252. hda_nid_t pin;
  5253. pin = spec->autocfg.hp_pins[0];
  5254. if (pin) /* connect to front */
  5255. /* use dac 0 */
  5256. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5257. }
  5258. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5259. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5260. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5261. {
  5262. struct alc_spec *spec = codec->spec;
  5263. int i;
  5264. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5265. hda_nid_t nid = spec->autocfg.input_pins[i];
  5266. if (alc883_is_input_pin(nid)) {
  5267. snd_hda_codec_write(codec, nid, 0,
  5268. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5269. (i <= AUTO_PIN_FRONT_MIC ?
  5270. PIN_VREF80 : PIN_IN));
  5271. if (nid != ALC883_PIN_CD_NID)
  5272. snd_hda_codec_write(codec, nid, 0,
  5273. AC_VERB_SET_AMP_GAIN_MUTE,
  5274. AMP_OUT_MUTE);
  5275. }
  5276. }
  5277. }
  5278. /* almost identical with ALC880 parser... */
  5279. static int alc883_parse_auto_config(struct hda_codec *codec)
  5280. {
  5281. struct alc_spec *spec = codec->spec;
  5282. int err = alc880_parse_auto_config(codec);
  5283. if (err < 0)
  5284. return err;
  5285. else if (err > 0)
  5286. /* hack - override the init verbs */
  5287. spec->init_verbs[0] = alc883_auto_init_verbs;
  5288. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5289. spec->num_mixers++;
  5290. return err;
  5291. }
  5292. /* additional initialization for auto-configuration model */
  5293. static void alc883_auto_init(struct hda_codec *codec)
  5294. {
  5295. alc883_auto_init_multi_out(codec);
  5296. alc883_auto_init_hp_out(codec);
  5297. alc883_auto_init_analog_input(codec);
  5298. }
  5299. static int patch_alc883(struct hda_codec *codec)
  5300. {
  5301. struct alc_spec *spec;
  5302. int err, board_config;
  5303. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5304. if (spec == NULL)
  5305. return -ENOMEM;
  5306. codec->spec = spec;
  5307. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5308. alc883_models,
  5309. alc883_cfg_tbl);
  5310. if (board_config < 0) {
  5311. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5312. "trying auto-probe from BIOS...\n");
  5313. board_config = ALC883_AUTO;
  5314. }
  5315. if (board_config == ALC883_AUTO) {
  5316. /* automatic parse from the BIOS config */
  5317. err = alc883_parse_auto_config(codec);
  5318. if (err < 0) {
  5319. alc_free(codec);
  5320. return err;
  5321. } else if (! err) {
  5322. printk(KERN_INFO
  5323. "hda_codec: Cannot set up configuration "
  5324. "from BIOS. Using base mode...\n");
  5325. board_config = ALC883_3ST_2ch_DIG;
  5326. }
  5327. }
  5328. if (board_config != ALC883_AUTO)
  5329. setup_preset(spec, &alc883_presets[board_config]);
  5330. spec->stream_name_analog = "ALC883 Analog";
  5331. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5332. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5333. spec->stream_name_digital = "ALC883 Digital";
  5334. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5335. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5336. if (! spec->adc_nids && spec->input_mux) {
  5337. spec->adc_nids = alc883_adc_nids;
  5338. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5339. }
  5340. codec->patch_ops = alc_patch_ops;
  5341. if (board_config == ALC883_AUTO)
  5342. spec->init_hook = alc883_auto_init;
  5343. return 0;
  5344. }
  5345. /*
  5346. * ALC262 support
  5347. */
  5348. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5349. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5350. #define alc262_dac_nids alc260_dac_nids
  5351. #define alc262_adc_nids alc882_adc_nids
  5352. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5353. #define alc262_modes alc260_modes
  5354. #define alc262_capture_source alc882_capture_source
  5355. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5356. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5357. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5359. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5361. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5362. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5363. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5364. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5365. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5366. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5367. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5368. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5369. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5370. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5371. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5372. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5373. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5374. { } /* end */
  5375. };
  5376. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5377. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5378. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5379. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5380. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5382. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5383. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5384. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5386. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5387. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5388. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5389. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5390. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5391. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5392. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5393. { } /* end */
  5394. };
  5395. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5396. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5397. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5398. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5399. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5400. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5401. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5402. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5403. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5410. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5411. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5412. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5413. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5414. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5415. { } /* end */
  5416. };
  5417. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  5418. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5419. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5420. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5421. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5422. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5423. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5424. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5425. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5426. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5428. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5430. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5432. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5433. { } /* end */
  5434. };
  5435. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  5436. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5437. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5438. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  5439. { } /* end */
  5440. };
  5441. #define alc262_capture_mixer alc882_capture_mixer
  5442. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5443. /*
  5444. * generic initialization of ADC, input mixers and output mixers
  5445. */
  5446. static struct hda_verb alc262_init_verbs[] = {
  5447. /*
  5448. * Unmute ADC0-2 and set the default input to mic-in
  5449. */
  5450. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5451. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5452. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5453. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5454. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5456. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5457. * mixer widget
  5458. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5459. * mic (mic 2)
  5460. */
  5461. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5462. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5463. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5464. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5465. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5466. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5467. /*
  5468. * Set up output mixers (0x0c - 0x0e)
  5469. */
  5470. /* set vol=0 to output mixers */
  5471. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5472. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5473. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5474. /* set up input amps for analog loopback */
  5475. /* Amp Indices: DAC = 0, mixer = 1 */
  5476. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5477. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5478. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5479. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5480. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5481. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5482. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5483. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5484. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5485. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5486. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5487. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5488. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5489. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5490. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5491. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5492. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5493. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5494. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5495. /* FIXME: use matrix-type input source selection */
  5496. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5497. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5498. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5499. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5500. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5501. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5502. /* Input mixer2 */
  5503. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5504. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5505. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5506. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5507. /* Input mixer3 */
  5508. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5509. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5510. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5511. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5512. { }
  5513. };
  5514. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5515. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5516. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5517. {}
  5518. };
  5519. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5520. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5521. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5522. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5523. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5524. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5525. {}
  5526. };
  5527. /* mute/unmute internal speaker according to the hp jack and mute state */
  5528. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5529. {
  5530. struct alc_spec *spec = codec->spec;
  5531. unsigned int mute;
  5532. if (force || ! spec->sense_updated) {
  5533. unsigned int present;
  5534. /* need to execute and sync at first */
  5535. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5536. present = snd_hda_codec_read(codec, 0x15, 0,
  5537. AC_VERB_GET_PIN_SENSE, 0);
  5538. spec->jack_present = (present & 0x80000000) != 0;
  5539. spec->sense_updated = 1;
  5540. }
  5541. if (spec->jack_present) {
  5542. /* mute internal speaker */
  5543. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5544. 0x80, 0x80);
  5545. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5546. 0x80, 0x80);
  5547. } else {
  5548. /* unmute internal speaker if necessary */
  5549. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5550. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5551. 0x80, mute & 0x80);
  5552. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5553. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5554. 0x80, mute & 0x80);
  5555. }
  5556. }
  5557. /* unsolicited event for HP jack sensing */
  5558. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5559. unsigned int res)
  5560. {
  5561. if ((res >> 26) != ALC880_HP_EVENT)
  5562. return;
  5563. alc262_hippo_automute(codec, 1);
  5564. }
  5565. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5566. {
  5567. struct alc_spec *spec = codec->spec;
  5568. unsigned int mute;
  5569. if (force || ! spec->sense_updated) {
  5570. unsigned int present;
  5571. /* need to execute and sync at first */
  5572. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5573. present = snd_hda_codec_read(codec, 0x1b, 0,
  5574. AC_VERB_GET_PIN_SENSE, 0);
  5575. spec->jack_present = (present & 0x80000000) != 0;
  5576. spec->sense_updated = 1;
  5577. }
  5578. if (spec->jack_present) {
  5579. /* mute internal speaker */
  5580. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5581. 0x80, 0x80);
  5582. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5583. 0x80, 0x80);
  5584. } else {
  5585. /* unmute internal speaker if necessary */
  5586. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5587. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5588. 0x80, mute & 0x80);
  5589. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5590. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5591. 0x80, mute & 0x80);
  5592. }
  5593. }
  5594. /* unsolicited event for HP jack sensing */
  5595. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5596. unsigned int res)
  5597. {
  5598. if ((res >> 26) != ALC880_HP_EVENT)
  5599. return;
  5600. alc262_hippo1_automute(codec, 1);
  5601. }
  5602. /*
  5603. * fujitsu model
  5604. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5605. */
  5606. #define ALC_HP_EVENT 0x37
  5607. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5608. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5609. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5610. {}
  5611. };
  5612. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5613. .num_items = 2,
  5614. .items = {
  5615. { "Mic", 0x0 },
  5616. { "CD", 0x4 },
  5617. },
  5618. };
  5619. static struct hda_input_mux alc262_HP_capture_source = {
  5620. .num_items = 5,
  5621. .items = {
  5622. { "Mic", 0x0 },
  5623. { "Front Mic", 0x3 },
  5624. { "Line", 0x2 },
  5625. { "CD", 0x4 },
  5626. { "AUX IN", 0x6 },
  5627. },
  5628. };
  5629. /* mute/unmute internal speaker according to the hp jack and mute state */
  5630. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5631. {
  5632. struct alc_spec *spec = codec->spec;
  5633. unsigned int mute;
  5634. if (force || ! spec->sense_updated) {
  5635. unsigned int present;
  5636. /* need to execute and sync at first */
  5637. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5638. present = snd_hda_codec_read(codec, 0x14, 0,
  5639. AC_VERB_GET_PIN_SENSE, 0);
  5640. spec->jack_present = (present & 0x80000000) != 0;
  5641. spec->sense_updated = 1;
  5642. }
  5643. if (spec->jack_present) {
  5644. /* mute internal speaker */
  5645. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5646. 0x80, 0x80);
  5647. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5648. 0x80, 0x80);
  5649. } else {
  5650. /* unmute internal speaker if necessary */
  5651. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5652. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5653. 0x80, mute & 0x80);
  5654. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5655. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5656. 0x80, mute & 0x80);
  5657. }
  5658. }
  5659. /* unsolicited event for HP jack sensing */
  5660. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5661. unsigned int res)
  5662. {
  5663. if ((res >> 26) != ALC_HP_EVENT)
  5664. return;
  5665. alc262_fujitsu_automute(codec, 1);
  5666. }
  5667. /* bind volumes of both NID 0x0c and 0x0d */
  5668. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5669. struct snd_ctl_elem_value *ucontrol)
  5670. {
  5671. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5672. long *valp = ucontrol->value.integer.value;
  5673. int change;
  5674. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5675. 0x7f, valp[0] & 0x7f);
  5676. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5677. 0x7f, valp[1] & 0x7f);
  5678. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5679. 0x7f, valp[0] & 0x7f);
  5680. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5681. 0x7f, valp[1] & 0x7f);
  5682. return change;
  5683. }
  5684. /* bind hp and internal speaker mute (with plug check) */
  5685. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5686. struct snd_ctl_elem_value *ucontrol)
  5687. {
  5688. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5689. long *valp = ucontrol->value.integer.value;
  5690. int change;
  5691. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5692. 0x80, valp[0] ? 0 : 0x80);
  5693. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5694. 0x80, valp[1] ? 0 : 0x80);
  5695. if (change || codec->in_resume)
  5696. alc262_fujitsu_automute(codec, codec->in_resume);
  5697. return change;
  5698. }
  5699. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5700. {
  5701. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5702. .name = "Master Playback Volume",
  5703. .info = snd_hda_mixer_amp_volume_info,
  5704. .get = snd_hda_mixer_amp_volume_get,
  5705. .put = alc262_fujitsu_master_vol_put,
  5706. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5707. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5708. },
  5709. {
  5710. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5711. .name = "Master Playback Switch",
  5712. .info = snd_hda_mixer_amp_switch_info,
  5713. .get = snd_hda_mixer_amp_switch_get,
  5714. .put = alc262_fujitsu_master_sw_put,
  5715. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5716. },
  5717. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5718. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5719. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5720. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5721. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5722. { } /* end */
  5723. };
  5724. /* additional init verbs for Benq laptops */
  5725. static struct hda_verb alc262_EAPD_verbs[] = {
  5726. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5727. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5728. {}
  5729. };
  5730. /* add playback controls from the parsed DAC table */
  5731. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5732. {
  5733. hda_nid_t nid;
  5734. int err;
  5735. spec->multiout.num_dacs = 1; /* only use one dac */
  5736. spec->multiout.dac_nids = spec->private_dac_nids;
  5737. spec->multiout.dac_nids[0] = 2;
  5738. nid = cfg->line_out_pins[0];
  5739. if (nid) {
  5740. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5741. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5742. return err;
  5743. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5744. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5745. return err;
  5746. }
  5747. nid = cfg->speaker_pins[0];
  5748. if (nid) {
  5749. if (nid == 0x16) {
  5750. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5751. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5752. return err;
  5753. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5754. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5755. return err;
  5756. } else {
  5757. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5758. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5759. return err;
  5760. }
  5761. }
  5762. nid = cfg->hp_pins[0];
  5763. if (nid) {
  5764. /* spec->multiout.hp_nid = 2; */
  5765. if (nid == 0x16) {
  5766. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5767. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5768. return err;
  5769. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5770. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5771. return err;
  5772. } else {
  5773. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5774. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5775. return err;
  5776. }
  5777. }
  5778. return 0;
  5779. }
  5780. /* identical with ALC880 */
  5781. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5782. /*
  5783. * generic initialization of ADC, input mixers and output mixers
  5784. */
  5785. static struct hda_verb alc262_volume_init_verbs[] = {
  5786. /*
  5787. * Unmute ADC0-2 and set the default input to mic-in
  5788. */
  5789. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5790. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5791. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5792. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5793. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5794. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5795. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5796. * mixer widget
  5797. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5798. * mic (mic 2)
  5799. */
  5800. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5801. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5802. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5803. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5804. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5805. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5806. /*
  5807. * Set up output mixers (0x0c - 0x0f)
  5808. */
  5809. /* set vol=0 to output mixers */
  5810. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5811. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5812. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5813. /* set up input amps for analog loopback */
  5814. /* Amp Indices: DAC = 0, mixer = 1 */
  5815. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5816. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5817. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5818. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5819. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5820. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5821. /* FIXME: use matrix-type input source selection */
  5822. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5823. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5824. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5825. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5826. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5827. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5828. /* Input mixer2 */
  5829. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5830. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5831. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5832. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5833. /* Input mixer3 */
  5834. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5835. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5837. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5838. { }
  5839. };
  5840. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5841. /*
  5842. * Unmute ADC0-2 and set the default input to mic-in
  5843. */
  5844. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5845. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5846. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5847. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5848. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5849. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5850. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5851. * mixer widget
  5852. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5853. * mic (mic 2)
  5854. */
  5855. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5856. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5857. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5858. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5859. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5860. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5861. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5862. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5863. /*
  5864. * Set up output mixers (0x0c - 0x0e)
  5865. */
  5866. /* set vol=0 to output mixers */
  5867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5868. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5869. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5870. /* set up input amps for analog loopback */
  5871. /* Amp Indices: DAC = 0, mixer = 1 */
  5872. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5873. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5874. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5875. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5876. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5877. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5878. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5879. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5880. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5881. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5882. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5883. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5884. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5885. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5886. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5887. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5888. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5889. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5891. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5892. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5893. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5894. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5895. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5896. /* FIXME: use matrix-type input source selection */
  5897. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5898. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5899. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5900. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5901. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5902. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5903. /* Input mixer2 */
  5904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5905. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5906. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5907. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5908. /* Input mixer3 */
  5909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5913. { }
  5914. };
  5915. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  5916. /*
  5917. * Unmute ADC0-2 and set the default input to mic-in
  5918. */
  5919. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5920. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5921. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5922. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5923. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5924. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5925. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5926. * mixer widget
  5927. * Note: PASD motherboards uses the Line In 2 as the input for front
  5928. * panel mic (mic 2)
  5929. */
  5930. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5933. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5934. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5937. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5938. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  5939. /*
  5940. * Set up output mixers (0x0c - 0x0e)
  5941. */
  5942. /* set vol=0 to output mixers */
  5943. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5944. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5945. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5946. /* set up input amps for analog loopback */
  5947. /* Amp Indices: DAC = 0, mixer = 1 */
  5948. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5949. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5950. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5951. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5952. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5953. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5954. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  5955. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  5956. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  5957. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  5958. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  5959. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  5960. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  5961. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5963. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5964. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5965. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  5966. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5967. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5968. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5969. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5970. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5971. /* FIXME: use matrix-type input source selection */
  5972. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5973. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5974. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  5975. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  5976. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  5977. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  5978. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  5979. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5980. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  5981. /* Input mixer2 */
  5982. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5983. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  5984. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5985. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5986. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5987. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5988. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  5989. /* Input mixer3 */
  5990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  5992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5994. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5995. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5996. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  5997. { }
  5998. };
  5999. /* pcm configuration: identiacal with ALC880 */
  6000. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6001. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6002. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6003. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6004. /*
  6005. * BIOS auto configuration
  6006. */
  6007. static int alc262_parse_auto_config(struct hda_codec *codec)
  6008. {
  6009. struct alc_spec *spec = codec->spec;
  6010. int err;
  6011. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6012. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6013. alc262_ignore)) < 0)
  6014. return err;
  6015. if (! spec->autocfg.line_outs)
  6016. return 0; /* can't find valid BIOS pin config */
  6017. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6018. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6019. return err;
  6020. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6021. if (spec->autocfg.dig_out_pin)
  6022. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6023. if (spec->autocfg.dig_in_pin)
  6024. spec->dig_in_nid = ALC262_DIGIN_NID;
  6025. if (spec->kctl_alloc)
  6026. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6027. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6028. spec->num_mux_defs = 1;
  6029. spec->input_mux = &spec->private_imux;
  6030. return 1;
  6031. }
  6032. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6033. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6034. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6035. /* init callback for auto-configuration model -- overriding the default init */
  6036. static void alc262_auto_init(struct hda_codec *codec)
  6037. {
  6038. alc262_auto_init_multi_out(codec);
  6039. alc262_auto_init_hp_out(codec);
  6040. alc262_auto_init_analog_input(codec);
  6041. }
  6042. /*
  6043. * configuration and preset
  6044. */
  6045. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6046. [ALC262_BASIC] = "basic",
  6047. [ALC262_HIPPO] = "hippo",
  6048. [ALC262_HIPPO_1] = "hippo_1",
  6049. [ALC262_FUJITSU] = "fujitsu",
  6050. [ALC262_HP_BPC] = "hp-bpc",
  6051. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6052. [ALC262_BENQ_ED8] = "benq",
  6053. [ALC262_AUTO] = "auto",
  6054. };
  6055. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6056. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6057. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6058. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6059. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6060. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6061. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6062. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6063. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6064. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6065. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6066. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6067. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6068. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6069. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6070. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6071. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6072. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6073. {}
  6074. };
  6075. static struct alc_config_preset alc262_presets[] = {
  6076. [ALC262_BASIC] = {
  6077. .mixers = { alc262_base_mixer },
  6078. .init_verbs = { alc262_init_verbs },
  6079. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6080. .dac_nids = alc262_dac_nids,
  6081. .hp_nid = 0x03,
  6082. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6083. .channel_mode = alc262_modes,
  6084. .input_mux = &alc262_capture_source,
  6085. },
  6086. [ALC262_HIPPO] = {
  6087. .mixers = { alc262_base_mixer },
  6088. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6089. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6090. .dac_nids = alc262_dac_nids,
  6091. .hp_nid = 0x03,
  6092. .dig_out_nid = ALC262_DIGOUT_NID,
  6093. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6094. .channel_mode = alc262_modes,
  6095. .input_mux = &alc262_capture_source,
  6096. .unsol_event = alc262_hippo_unsol_event,
  6097. },
  6098. [ALC262_HIPPO_1] = {
  6099. .mixers = { alc262_hippo1_mixer },
  6100. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6101. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6102. .dac_nids = alc262_dac_nids,
  6103. .hp_nid = 0x02,
  6104. .dig_out_nid = ALC262_DIGOUT_NID,
  6105. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6106. .channel_mode = alc262_modes,
  6107. .input_mux = &alc262_capture_source,
  6108. .unsol_event = alc262_hippo1_unsol_event,
  6109. },
  6110. [ALC262_FUJITSU] = {
  6111. .mixers = { alc262_fujitsu_mixer },
  6112. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6113. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6114. .dac_nids = alc262_dac_nids,
  6115. .hp_nid = 0x03,
  6116. .dig_out_nid = ALC262_DIGOUT_NID,
  6117. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6118. .channel_mode = alc262_modes,
  6119. .input_mux = &alc262_fujitsu_capture_source,
  6120. .unsol_event = alc262_fujitsu_unsol_event,
  6121. },
  6122. [ALC262_HP_BPC] = {
  6123. .mixers = { alc262_HP_BPC_mixer },
  6124. .init_verbs = { alc262_HP_BPC_init_verbs },
  6125. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6126. .dac_nids = alc262_dac_nids,
  6127. .hp_nid = 0x03,
  6128. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6129. .channel_mode = alc262_modes,
  6130. .input_mux = &alc262_HP_capture_source,
  6131. },
  6132. [ALC262_HP_BPC_D7000_WF] = {
  6133. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6134. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6135. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6136. .dac_nids = alc262_dac_nids,
  6137. .hp_nid = 0x03,
  6138. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6139. .channel_mode = alc262_modes,
  6140. .input_mux = &alc262_HP_capture_source,
  6141. },
  6142. [ALC262_HP_BPC_D7000_WL] = {
  6143. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6144. alc262_HP_BPC_WildWest_option_mixer },
  6145. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6146. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6147. .dac_nids = alc262_dac_nids,
  6148. .hp_nid = 0x03,
  6149. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6150. .channel_mode = alc262_modes,
  6151. .input_mux = &alc262_HP_capture_source,
  6152. },
  6153. [ALC262_BENQ_ED8] = {
  6154. .mixers = { alc262_base_mixer },
  6155. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6156. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6157. .dac_nids = alc262_dac_nids,
  6158. .hp_nid = 0x03,
  6159. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6160. .channel_mode = alc262_modes,
  6161. .input_mux = &alc262_capture_source,
  6162. },
  6163. };
  6164. static int patch_alc262(struct hda_codec *codec)
  6165. {
  6166. struct alc_spec *spec;
  6167. int board_config;
  6168. int err;
  6169. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6170. if (spec == NULL)
  6171. return -ENOMEM;
  6172. codec->spec = spec;
  6173. #if 0
  6174. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  6175. {
  6176. int tmp;
  6177. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6178. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  6179. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6180. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  6181. }
  6182. #endif
  6183. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  6184. alc262_models,
  6185. alc262_cfg_tbl);
  6186. if (board_config < 0) {
  6187. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  6188. "trying auto-probe from BIOS...\n");
  6189. board_config = ALC262_AUTO;
  6190. }
  6191. if (board_config == ALC262_AUTO) {
  6192. /* automatic parse from the BIOS config */
  6193. err = alc262_parse_auto_config(codec);
  6194. if (err < 0) {
  6195. alc_free(codec);
  6196. return err;
  6197. } else if (! err) {
  6198. printk(KERN_INFO
  6199. "hda_codec: Cannot set up configuration "
  6200. "from BIOS. Using base mode...\n");
  6201. board_config = ALC262_BASIC;
  6202. }
  6203. }
  6204. if (board_config != ALC262_AUTO)
  6205. setup_preset(spec, &alc262_presets[board_config]);
  6206. spec->stream_name_analog = "ALC262 Analog";
  6207. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  6208. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  6209. spec->stream_name_digital = "ALC262 Digital";
  6210. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6211. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6212. if (! spec->adc_nids && spec->input_mux) {
  6213. /* check whether NID 0x07 is valid */
  6214. unsigned int wcap = get_wcaps(codec, 0x07);
  6215. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  6216. if (wcap != AC_WID_AUD_IN) {
  6217. spec->adc_nids = alc262_adc_nids_alt;
  6218. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6219. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  6220. spec->num_mixers++;
  6221. } else {
  6222. spec->adc_nids = alc262_adc_nids;
  6223. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6224. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6225. spec->num_mixers++;
  6226. }
  6227. }
  6228. codec->patch_ops = alc_patch_ops;
  6229. if (board_config == ALC262_AUTO)
  6230. spec->init_hook = alc262_auto_init;
  6231. return 0;
  6232. }
  6233. /*
  6234. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6235. */
  6236. /*
  6237. * set the path ways for 2 channel output
  6238. * need to set the codec line out and mic 1 pin widgets to inputs
  6239. */
  6240. static struct hda_verb alc861_threestack_ch2_init[] = {
  6241. /* set pin widget 1Ah (line in) for input */
  6242. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6243. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6244. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6245. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6246. #if 0
  6247. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6248. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6249. #endif
  6250. { } /* end */
  6251. };
  6252. /*
  6253. * 6ch mode
  6254. * need to set the codec line out and mic 1 pin widgets to outputs
  6255. */
  6256. static struct hda_verb alc861_threestack_ch6_init[] = {
  6257. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6258. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6259. /* set pin widget 18h (mic1) for output (CLFE)*/
  6260. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6261. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6262. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6263. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6264. #if 0
  6265. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6266. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6267. #endif
  6268. { } /* end */
  6269. };
  6270. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6271. { 2, alc861_threestack_ch2_init },
  6272. { 6, alc861_threestack_ch6_init },
  6273. };
  6274. /* Set mic1 as input and unmute the mixer */
  6275. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6276. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6277. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6278. { } /* end */
  6279. };
  6280. /* Set mic1 as output and mute mixer */
  6281. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6282. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6283. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6284. { } /* end */
  6285. };
  6286. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6287. { 2, alc861_uniwill_m31_ch2_init },
  6288. { 4, alc861_uniwill_m31_ch4_init },
  6289. };
  6290. /* Set mic1 and line-in as input and unmute the mixer */
  6291. static struct hda_verb alc861_asus_ch2_init[] = {
  6292. /* set pin widget 1Ah (line in) for input */
  6293. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6294. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6295. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6296. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6297. #if 0
  6298. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6299. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6300. #endif
  6301. { } /* end */
  6302. };
  6303. /* Set mic1 nad line-in as output and mute mixer */
  6304. static struct hda_verb alc861_asus_ch6_init[] = {
  6305. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6306. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6307. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6308. /* set pin widget 18h (mic1) for output (CLFE)*/
  6309. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6310. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6311. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6312. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6313. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6314. #if 0
  6315. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6316. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6317. #endif
  6318. { } /* end */
  6319. };
  6320. static struct hda_channel_mode alc861_asus_modes[2] = {
  6321. { 2, alc861_asus_ch2_init },
  6322. { 6, alc861_asus_ch6_init },
  6323. };
  6324. /* patch-ALC861 */
  6325. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6326. /* output mixer control */
  6327. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6328. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6329. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6330. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6331. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6332. /*Input mixer control */
  6333. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6334. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6335. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6336. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6337. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6338. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6339. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6340. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6341. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6342. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6343. /* Capture mixer control */
  6344. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6345. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6346. {
  6347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6348. .name = "Capture Source",
  6349. .count = 1,
  6350. .info = alc_mux_enum_info,
  6351. .get = alc_mux_enum_get,
  6352. .put = alc_mux_enum_put,
  6353. },
  6354. { } /* end */
  6355. };
  6356. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6357. /* output mixer control */
  6358. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6359. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6360. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6361. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6362. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6363. /* Input mixer control */
  6364. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6365. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6366. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6367. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6368. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6369. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6370. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6371. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6372. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6373. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6374. /* Capture mixer control */
  6375. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6376. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6377. {
  6378. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6379. .name = "Capture Source",
  6380. .count = 1,
  6381. .info = alc_mux_enum_info,
  6382. .get = alc_mux_enum_get,
  6383. .put = alc_mux_enum_put,
  6384. },
  6385. {
  6386. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6387. .name = "Channel Mode",
  6388. .info = alc_ch_mode_info,
  6389. .get = alc_ch_mode_get,
  6390. .put = alc_ch_mode_put,
  6391. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6392. },
  6393. { } /* end */
  6394. };
  6395. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6396. /* output mixer control */
  6397. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6398. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6399. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6400. /*Capture mixer control */
  6401. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6402. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6403. {
  6404. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6405. .name = "Capture Source",
  6406. .count = 1,
  6407. .info = alc_mux_enum_info,
  6408. .get = alc_mux_enum_get,
  6409. .put = alc_mux_enum_put,
  6410. },
  6411. { } /* end */
  6412. };
  6413. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6414. /* output mixer control */
  6415. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6416. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6417. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6418. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6419. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6420. /* Input mixer control */
  6421. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6422. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6423. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6424. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6425. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6426. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6427. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6428. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6429. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6430. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6431. /* Capture mixer control */
  6432. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6433. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6434. {
  6435. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6436. .name = "Capture Source",
  6437. .count = 1,
  6438. .info = alc_mux_enum_info,
  6439. .get = alc_mux_enum_get,
  6440. .put = alc_mux_enum_put,
  6441. },
  6442. {
  6443. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6444. .name = "Channel Mode",
  6445. .info = alc_ch_mode_info,
  6446. .get = alc_ch_mode_get,
  6447. .put = alc_ch_mode_put,
  6448. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6449. },
  6450. { } /* end */
  6451. };
  6452. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6453. /* output mixer control */
  6454. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6455. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6456. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6457. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6458. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6459. /* Input mixer control */
  6460. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6461. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6462. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6463. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6464. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6465. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6466. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6467. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6468. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6469. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
  6470. /* Capture mixer control */
  6471. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6472. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6473. {
  6474. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6475. .name = "Capture Source",
  6476. .count = 1,
  6477. .info = alc_mux_enum_info,
  6478. .get = alc_mux_enum_get,
  6479. .put = alc_mux_enum_put,
  6480. },
  6481. {
  6482. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6483. .name = "Channel Mode",
  6484. .info = alc_ch_mode_info,
  6485. .get = alc_ch_mode_get,
  6486. .put = alc_ch_mode_put,
  6487. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6488. },
  6489. { }
  6490. };
  6491. /* additional mixer */
  6492. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6493. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6494. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6495. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6496. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6497. { }
  6498. };
  6499. /*
  6500. * generic initialization of ADC, input mixers and output mixers
  6501. */
  6502. static struct hda_verb alc861_base_init_verbs[] = {
  6503. /*
  6504. * Unmute ADC0 and set the default input to mic-in
  6505. */
  6506. /* port-A for surround (rear panel) */
  6507. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6508. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6509. /* port-B for mic-in (rear panel) with vref */
  6510. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6511. /* port-C for line-in (rear panel) */
  6512. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6513. /* port-D for Front */
  6514. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6515. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6516. /* port-E for HP out (front panel) */
  6517. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6518. /* route front PCM to HP */
  6519. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6520. /* port-F for mic-in (front panel) with vref */
  6521. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6522. /* port-G for CLFE (rear panel) */
  6523. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6524. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6525. /* port-H for side (rear panel) */
  6526. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6527. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6528. /* CD-in */
  6529. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6530. /* route front mic to ADC1*/
  6531. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6532. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6533. /* Unmute DAC0~3 & spdif out*/
  6534. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6535. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6536. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6537. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6538. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6539. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6540. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6541. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6542. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6543. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6544. /* Unmute Stereo Mixer 15 */
  6545. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6546. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6547. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6548. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6549. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6550. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6551. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6552. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6553. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6554. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6555. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6556. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6557. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6558. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6559. { }
  6560. };
  6561. static struct hda_verb alc861_threestack_init_verbs[] = {
  6562. /*
  6563. * Unmute ADC0 and set the default input to mic-in
  6564. */
  6565. /* port-A for surround (rear panel) */
  6566. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6567. /* port-B for mic-in (rear panel) with vref */
  6568. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6569. /* port-C for line-in (rear panel) */
  6570. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6571. /* port-D for Front */
  6572. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6573. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6574. /* port-E for HP out (front panel) */
  6575. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6576. /* route front PCM to HP */
  6577. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6578. /* port-F for mic-in (front panel) with vref */
  6579. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6580. /* port-G for CLFE (rear panel) */
  6581. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6582. /* port-H for side (rear panel) */
  6583. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6584. /* CD-in */
  6585. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6586. /* route front mic to ADC1*/
  6587. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6588. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6589. /* Unmute DAC0~3 & spdif out*/
  6590. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6591. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6592. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6593. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6594. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6595. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6596. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6597. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6598. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6599. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6600. /* Unmute Stereo Mixer 15 */
  6601. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6602. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6603. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6604. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6605. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6606. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6607. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6608. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6609. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6610. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6611. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6612. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6613. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6614. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6615. { }
  6616. };
  6617. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  6618. /*
  6619. * Unmute ADC0 and set the default input to mic-in
  6620. */
  6621. /* port-A for surround (rear panel) */
  6622. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6623. /* port-B for mic-in (rear panel) with vref */
  6624. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6625. /* port-C for line-in (rear panel) */
  6626. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6627. /* port-D for Front */
  6628. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6629. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6630. /* port-E for HP out (front panel) */
  6631. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  6632. /* route front PCM to HP */
  6633. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6634. /* port-F for mic-in (front panel) with vref */
  6635. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6636. /* port-G for CLFE (rear panel) */
  6637. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6638. /* port-H for side (rear panel) */
  6639. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6640. /* CD-in */
  6641. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6642. /* route front mic to ADC1*/
  6643. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6644. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6645. /* Unmute DAC0~3 & spdif out*/
  6646. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6647. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6648. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6649. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6650. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6651. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6652. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6653. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6654. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6655. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6656. /* Unmute Stereo Mixer 15 */
  6657. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6658. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6659. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6660. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6661. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6662. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6663. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6664. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6665. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6666. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6667. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6668. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6669. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6670. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6671. { }
  6672. };
  6673. static struct hda_verb alc861_asus_init_verbs[] = {
  6674. /*
  6675. * Unmute ADC0 and set the default input to mic-in
  6676. */
  6677. /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
  6678. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  6679. /* route front PCM to HP */
  6680. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6681. /* port-B for mic-in (rear panel) with vref */
  6682. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6683. /* port-C for line-in (rear panel) */
  6684. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6685. /* port-D for Front */
  6686. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6687. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6688. /* port-E for HP out (front panel) */
  6689. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
  6690. /* route front PCM to HP */
  6691. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6692. /* port-F for mic-in (front panel) with vref */
  6693. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6694. /* port-G for CLFE (rear panel) */
  6695. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6696. /* port-H for side (rear panel) */
  6697. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6698. /* CD-in */
  6699. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6700. /* route front mic to ADC1*/
  6701. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6702. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6703. /* Unmute DAC0~3 & spdif out*/
  6704. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6705. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6706. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6707. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6708. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6709. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6710. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6711. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6712. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6713. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6714. /* Unmute Stereo Mixer 15 */
  6715. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6716. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6717. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6718. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
  6719. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6720. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6721. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6722. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6723. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6724. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6725. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6726. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6727. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
  6728. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6729. { }
  6730. };
  6731. /* additional init verbs for ASUS laptops */
  6732. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  6733. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  6734. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  6735. { }
  6736. };
  6737. /*
  6738. * generic initialization of ADC, input mixers and output mixers
  6739. */
  6740. static struct hda_verb alc861_auto_init_verbs[] = {
  6741. /*
  6742. * Unmute ADC0 and set the default input to mic-in
  6743. */
  6744. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6745. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6746. /* Unmute DAC0~3 & spdif out*/
  6747. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6748. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6749. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6750. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6751. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6752. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6753. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6754. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6755. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6756. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6757. /* Unmute Stereo Mixer 15 */
  6758. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6759. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6760. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6761. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  6762. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6763. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6764. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6765. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6766. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6767. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6768. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6769. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6770. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6771. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6772. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6773. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6774. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6775. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6776. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6777. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6778. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  6779. { }
  6780. };
  6781. static struct hda_verb alc861_toshiba_init_verbs[] = {
  6782. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6783. { }
  6784. };
  6785. /* toggle speaker-output according to the hp-jack state */
  6786. static void alc861_toshiba_automute(struct hda_codec *codec)
  6787. {
  6788. unsigned int present;
  6789. present = snd_hda_codec_read(codec, 0x0f, 0,
  6790. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6791. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  6792. 0x80, present ? 0x80 : 0);
  6793. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  6794. 0x80, present ? 0x80 : 0);
  6795. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  6796. 0x80, present ? 0 : 0x80);
  6797. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  6798. 0x80, present ? 0 : 0x80);
  6799. }
  6800. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  6801. unsigned int res)
  6802. {
  6803. /* Looks like the unsol event is incompatible with the standard
  6804. * definition. 6bit tag is placed at 26 bit!
  6805. */
  6806. if ((res >> 26) == ALC880_HP_EVENT)
  6807. alc861_toshiba_automute(codec);
  6808. }
  6809. /* pcm configuration: identiacal with ALC880 */
  6810. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  6811. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  6812. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  6813. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  6814. #define ALC861_DIGOUT_NID 0x07
  6815. static struct hda_channel_mode alc861_8ch_modes[1] = {
  6816. { 8, NULL }
  6817. };
  6818. static hda_nid_t alc861_dac_nids[4] = {
  6819. /* front, surround, clfe, side */
  6820. 0x03, 0x06, 0x05, 0x04
  6821. };
  6822. static hda_nid_t alc660_dac_nids[3] = {
  6823. /* front, clfe, surround */
  6824. 0x03, 0x05, 0x06
  6825. };
  6826. static hda_nid_t alc861_adc_nids[1] = {
  6827. /* ADC0-2 */
  6828. 0x08,
  6829. };
  6830. static struct hda_input_mux alc861_capture_source = {
  6831. .num_items = 5,
  6832. .items = {
  6833. { "Mic", 0x0 },
  6834. { "Front Mic", 0x3 },
  6835. { "Line", 0x1 },
  6836. { "CD", 0x4 },
  6837. { "Mixer", 0x5 },
  6838. },
  6839. };
  6840. /* fill in the dac_nids table from the parsed pin configuration */
  6841. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6842. {
  6843. int i;
  6844. hda_nid_t nid;
  6845. spec->multiout.dac_nids = spec->private_dac_nids;
  6846. for (i = 0; i < cfg->line_outs; i++) {
  6847. nid = cfg->line_out_pins[i];
  6848. if (nid) {
  6849. if (i >= ARRAY_SIZE(alc861_dac_nids))
  6850. continue;
  6851. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  6852. }
  6853. }
  6854. spec->multiout.num_dacs = cfg->line_outs;
  6855. return 0;
  6856. }
  6857. /* add playback controls from the parsed DAC table */
  6858. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  6859. const struct auto_pin_cfg *cfg)
  6860. {
  6861. char name[32];
  6862. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  6863. hda_nid_t nid;
  6864. int i, idx, err;
  6865. for (i = 0; i < cfg->line_outs; i++) {
  6866. nid = spec->multiout.dac_nids[i];
  6867. if (! nid)
  6868. continue;
  6869. if (nid == 0x05) {
  6870. /* Center/LFE */
  6871. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  6872. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  6873. return err;
  6874. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  6875. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  6876. return err;
  6877. } else {
  6878. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  6879. if (nid == alc861_dac_nids[idx])
  6880. break;
  6881. sprintf(name, "%s Playback Switch", chname[idx]);
  6882. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  6883. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6884. return err;
  6885. }
  6886. }
  6887. return 0;
  6888. }
  6889. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  6890. {
  6891. int err;
  6892. hda_nid_t nid;
  6893. if (! pin)
  6894. return 0;
  6895. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  6896. nid = 0x03;
  6897. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  6898. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6899. return err;
  6900. spec->multiout.hp_nid = nid;
  6901. }
  6902. return 0;
  6903. }
  6904. /* create playback/capture controls for input pins */
  6905. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6906. {
  6907. struct hda_input_mux *imux = &spec->private_imux;
  6908. int i, err, idx, idx1;
  6909. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6910. switch(cfg->input_pins[i]) {
  6911. case 0x0c:
  6912. idx1 = 1;
  6913. idx = 2; // Line In
  6914. break;
  6915. case 0x0f:
  6916. idx1 = 2;
  6917. idx = 2; // Line In
  6918. break;
  6919. case 0x0d:
  6920. idx1 = 0;
  6921. idx = 1; // Mic In
  6922. break;
  6923. case 0x10:
  6924. idx1 = 3;
  6925. idx = 1; // Mic In
  6926. break;
  6927. case 0x11:
  6928. idx1 = 4;
  6929. idx = 0; // CD
  6930. break;
  6931. default:
  6932. continue;
  6933. }
  6934. err = new_analog_input(spec, cfg->input_pins[i],
  6935. auto_pin_cfg_labels[i], idx, 0x15);
  6936. if (err < 0)
  6937. return err;
  6938. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  6939. imux->items[imux->num_items].index = idx1;
  6940. imux->num_items++;
  6941. }
  6942. return 0;
  6943. }
  6944. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  6945. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6946. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6947. {
  6948. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6949. /* The multiple "Capture Source" controls confuse alsamixer
  6950. * So call somewhat different..
  6951. *FIXME: the controls appear in the "playback" view!
  6952. */
  6953. /* .name = "Capture Source", */
  6954. .name = "Input Source",
  6955. .count = 1,
  6956. .info = alc_mux_enum_info,
  6957. .get = alc_mux_enum_get,
  6958. .put = alc_mux_enum_put,
  6959. },
  6960. { } /* end */
  6961. };
  6962. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6963. int pin_type, int dac_idx)
  6964. {
  6965. /* set as output */
  6966. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6967. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6968. }
  6969. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6970. {
  6971. struct alc_spec *spec = codec->spec;
  6972. int i;
  6973. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6974. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6975. if (nid)
  6976. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6977. }
  6978. }
  6979. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6980. {
  6981. struct alc_spec *spec = codec->spec;
  6982. hda_nid_t pin;
  6983. pin = spec->autocfg.hp_pins[0];
  6984. if (pin) /* connect to front */
  6985. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6986. }
  6987. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6988. {
  6989. struct alc_spec *spec = codec->spec;
  6990. int i;
  6991. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6992. hda_nid_t nid = spec->autocfg.input_pins[i];
  6993. if ((nid>=0x0c) && (nid <=0x11)) {
  6994. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6995. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6996. }
  6997. }
  6998. }
  6999. /* parse the BIOS configuration and set up the alc_spec */
  7000. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  7001. static int alc861_parse_auto_config(struct hda_codec *codec)
  7002. {
  7003. struct alc_spec *spec = codec->spec;
  7004. int err;
  7005. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  7006. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7007. alc861_ignore)) < 0)
  7008. return err;
  7009. if (! spec->autocfg.line_outs)
  7010. return 0; /* can't find valid BIOS pin config */
  7011. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  7012. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  7013. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  7014. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  7015. return err;
  7016. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7017. if (spec->autocfg.dig_out_pin)
  7018. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7019. if (spec->kctl_alloc)
  7020. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7021. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7022. spec->num_mux_defs = 1;
  7023. spec->input_mux = &spec->private_imux;
  7024. spec->adc_nids = alc861_adc_nids;
  7025. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7026. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7027. spec->num_mixers++;
  7028. return 1;
  7029. }
  7030. /* additional initialization for auto-configuration model */
  7031. static void alc861_auto_init(struct hda_codec *codec)
  7032. {
  7033. alc861_auto_init_multi_out(codec);
  7034. alc861_auto_init_hp_out(codec);
  7035. alc861_auto_init_analog_input(codec);
  7036. }
  7037. /*
  7038. * configuration and preset
  7039. */
  7040. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7041. [ALC861_3ST] = "3stack",
  7042. [ALC660_3ST] = "3stack-660",
  7043. [ALC861_3ST_DIG] = "3stack-dig",
  7044. [ALC861_6ST_DIG] = "6stack-dig",
  7045. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7046. [ALC861_TOSHIBA] = "toshiba",
  7047. [ALC861_ASUS] = "asus",
  7048. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7049. [ALC861_AUTO] = "auto",
  7050. };
  7051. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7052. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7053. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7054. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7055. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7056. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  7057. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7058. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7059. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7060. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7061. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7062. {}
  7063. };
  7064. static struct alc_config_preset alc861_presets[] = {
  7065. [ALC861_3ST] = {
  7066. .mixers = { alc861_3ST_mixer },
  7067. .init_verbs = { alc861_threestack_init_verbs },
  7068. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7069. .dac_nids = alc861_dac_nids,
  7070. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7071. .channel_mode = alc861_threestack_modes,
  7072. .need_dac_fix = 1,
  7073. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7074. .adc_nids = alc861_adc_nids,
  7075. .input_mux = &alc861_capture_source,
  7076. },
  7077. [ALC861_3ST_DIG] = {
  7078. .mixers = { alc861_base_mixer },
  7079. .init_verbs = { alc861_threestack_init_verbs },
  7080. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7081. .dac_nids = alc861_dac_nids,
  7082. .dig_out_nid = ALC861_DIGOUT_NID,
  7083. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7084. .channel_mode = alc861_threestack_modes,
  7085. .need_dac_fix = 1,
  7086. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7087. .adc_nids = alc861_adc_nids,
  7088. .input_mux = &alc861_capture_source,
  7089. },
  7090. [ALC861_6ST_DIG] = {
  7091. .mixers = { alc861_base_mixer },
  7092. .init_verbs = { alc861_base_init_verbs },
  7093. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7094. .dac_nids = alc861_dac_nids,
  7095. .dig_out_nid = ALC861_DIGOUT_NID,
  7096. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7097. .channel_mode = alc861_8ch_modes,
  7098. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7099. .adc_nids = alc861_adc_nids,
  7100. .input_mux = &alc861_capture_source,
  7101. },
  7102. [ALC660_3ST] = {
  7103. .mixers = { alc861_3ST_mixer },
  7104. .init_verbs = { alc861_threestack_init_verbs },
  7105. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7106. .dac_nids = alc660_dac_nids,
  7107. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7108. .channel_mode = alc861_threestack_modes,
  7109. .need_dac_fix = 1,
  7110. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7111. .adc_nids = alc861_adc_nids,
  7112. .input_mux = &alc861_capture_source,
  7113. },
  7114. [ALC861_UNIWILL_M31] = {
  7115. .mixers = { alc861_uniwill_m31_mixer },
  7116. .init_verbs = { alc861_uniwill_m31_init_verbs },
  7117. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7118. .dac_nids = alc861_dac_nids,
  7119. .dig_out_nid = ALC861_DIGOUT_NID,
  7120. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7121. .channel_mode = alc861_uniwill_m31_modes,
  7122. .need_dac_fix = 1,
  7123. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7124. .adc_nids = alc861_adc_nids,
  7125. .input_mux = &alc861_capture_source,
  7126. },
  7127. [ALC861_TOSHIBA] = {
  7128. .mixers = { alc861_toshiba_mixer },
  7129. .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
  7130. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7131. .dac_nids = alc861_dac_nids,
  7132. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7133. .channel_mode = alc883_3ST_2ch_modes,
  7134. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7135. .adc_nids = alc861_adc_nids,
  7136. .input_mux = &alc861_capture_source,
  7137. .unsol_event = alc861_toshiba_unsol_event,
  7138. .init_hook = alc861_toshiba_automute,
  7139. },
  7140. [ALC861_ASUS] = {
  7141. .mixers = { alc861_asus_mixer },
  7142. .init_verbs = { alc861_asus_init_verbs },
  7143. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7144. .dac_nids = alc861_dac_nids,
  7145. .dig_out_nid = ALC861_DIGOUT_NID,
  7146. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  7147. .channel_mode = alc861_asus_modes,
  7148. .need_dac_fix = 1,
  7149. .hp_nid = 0x06,
  7150. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7151. .adc_nids = alc861_adc_nids,
  7152. .input_mux = &alc861_capture_source,
  7153. },
  7154. [ALC861_ASUS_LAPTOP] = {
  7155. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  7156. .init_verbs = { alc861_asus_init_verbs,
  7157. alc861_asus_laptop_init_verbs },
  7158. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7159. .dac_nids = alc861_dac_nids,
  7160. .dig_out_nid = ALC861_DIGOUT_NID,
  7161. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7162. .channel_mode = alc883_3ST_2ch_modes,
  7163. .need_dac_fix = 1,
  7164. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7165. .adc_nids = alc861_adc_nids,
  7166. .input_mux = &alc861_capture_source,
  7167. },
  7168. };
  7169. static int patch_alc861(struct hda_codec *codec)
  7170. {
  7171. struct alc_spec *spec;
  7172. int board_config;
  7173. int err;
  7174. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7175. if (spec == NULL)
  7176. return -ENOMEM;
  7177. codec->spec = spec;
  7178. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  7179. alc861_models,
  7180. alc861_cfg_tbl);
  7181. if (board_config < 0) {
  7182. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  7183. "trying auto-probe from BIOS...\n");
  7184. board_config = ALC861_AUTO;
  7185. }
  7186. if (board_config == ALC861_AUTO) {
  7187. /* automatic parse from the BIOS config */
  7188. err = alc861_parse_auto_config(codec);
  7189. if (err < 0) {
  7190. alc_free(codec);
  7191. return err;
  7192. } else if (! err) {
  7193. printk(KERN_INFO
  7194. "hda_codec: Cannot set up configuration "
  7195. "from BIOS. Using base mode...\n");
  7196. board_config = ALC861_3ST_DIG;
  7197. }
  7198. }
  7199. if (board_config != ALC861_AUTO)
  7200. setup_preset(spec, &alc861_presets[board_config]);
  7201. spec->stream_name_analog = "ALC861 Analog";
  7202. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  7203. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  7204. spec->stream_name_digital = "ALC861 Digital";
  7205. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  7206. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  7207. codec->patch_ops = alc_patch_ops;
  7208. if (board_config == ALC861_AUTO)
  7209. spec->init_hook = alc861_auto_init;
  7210. return 0;
  7211. }
  7212. /*
  7213. * ALC861-VD support
  7214. *
  7215. * Based on ALC882
  7216. *
  7217. * In addition, an independent DAC
  7218. */
  7219. #define ALC861VD_DIGOUT_NID 0x06
  7220. static hda_nid_t alc861vd_dac_nids[4] = {
  7221. /* front, surr, clfe, side surr */
  7222. 0x02, 0x03, 0x04, 0x05
  7223. };
  7224. /* dac_nids for ALC660vd are in a different order - according to
  7225. * Realtek's driver.
  7226. * This should probably tesult in a different mixer for 6stack models
  7227. * of ALC660vd codecs, but for now there is only 3stack mixer
  7228. * - and it is the same as in 861vd.
  7229. * adc_nids in ALC660vd are (is) the same as in 861vd
  7230. */
  7231. static hda_nid_t alc660vd_dac_nids[3] = {
  7232. /* front, rear, clfe, rear_surr */
  7233. 0x02, 0x04, 0x03
  7234. };
  7235. static hda_nid_t alc861vd_adc_nids[1] = {
  7236. /* ADC0 */
  7237. 0x09,
  7238. };
  7239. /* input MUX */
  7240. /* FIXME: should be a matrix-type input source selection */
  7241. static struct hda_input_mux alc861vd_capture_source = {
  7242. .num_items = 4,
  7243. .items = {
  7244. { "Mic", 0x0 },
  7245. { "Front Mic", 0x1 },
  7246. { "Line", 0x2 },
  7247. { "CD", 0x4 },
  7248. },
  7249. };
  7250. #define alc861vd_mux_enum_info alc_mux_enum_info
  7251. #define alc861vd_mux_enum_get alc_mux_enum_get
  7252. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  7253. struct snd_ctl_elem_value *ucontrol)
  7254. {
  7255. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7256. struct alc_spec *spec = codec->spec;
  7257. const struct hda_input_mux *imux = spec->input_mux;
  7258. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7259. static hda_nid_t capture_mixers[1] = { 0x22 };
  7260. hda_nid_t nid = capture_mixers[adc_idx];
  7261. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7262. unsigned int i, idx;
  7263. idx = ucontrol->value.enumerated.item[0];
  7264. if (idx >= imux->num_items)
  7265. idx = imux->num_items - 1;
  7266. if (*cur_val == idx && ! codec->in_resume)
  7267. return 0;
  7268. for (i = 0; i < imux->num_items; i++) {
  7269. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7270. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7271. v | (imux->items[i].index << 8));
  7272. }
  7273. *cur_val = idx;
  7274. return 1;
  7275. }
  7276. /*
  7277. * 2ch mode
  7278. */
  7279. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  7280. { 2, NULL }
  7281. };
  7282. /*
  7283. * 6ch mode
  7284. */
  7285. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  7286. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7287. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7288. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7289. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7290. { } /* end */
  7291. };
  7292. /*
  7293. * 8ch mode
  7294. */
  7295. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  7296. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7297. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7298. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7299. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7300. { } /* end */
  7301. };
  7302. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  7303. { 6, alc861vd_6stack_ch6_init },
  7304. { 8, alc861vd_6stack_ch8_init },
  7305. };
  7306. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  7307. {
  7308. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7309. .name = "Channel Mode",
  7310. .info = alc_ch_mode_info,
  7311. .get = alc_ch_mode_get,
  7312. .put = alc_ch_mode_put,
  7313. },
  7314. { } /* end */
  7315. };
  7316. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  7317. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  7318. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  7319. {
  7320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7321. /* The multiple "Capture Source" controls confuse alsamixer
  7322. * So call somewhat different..
  7323. *FIXME: the controls appear in the "playback" view!
  7324. */
  7325. /* .name = "Capture Source", */
  7326. .name = "Input Source",
  7327. .count = 1,
  7328. .info = alc861vd_mux_enum_info,
  7329. .get = alc861vd_mux_enum_get,
  7330. .put = alc861vd_mux_enum_put,
  7331. },
  7332. { } /* end */
  7333. };
  7334. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  7335. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  7336. */
  7337. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  7338. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7339. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7340. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  7341. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  7342. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  7343. HDA_OUTPUT),
  7344. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  7345. HDA_OUTPUT),
  7346. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  7347. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  7348. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  7349. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  7350. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7351. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7352. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7353. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7354. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7355. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7356. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7357. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7358. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7359. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7360. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7361. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7362. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7363. { } /* end */
  7364. };
  7365. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  7366. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7367. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7368. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7369. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7370. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7371. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7372. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7373. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7374. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7375. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7376. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7377. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7378. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7379. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7380. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7381. { } /* end */
  7382. };
  7383. /*
  7384. * generic initialization of ADC, input mixers and output mixers
  7385. */
  7386. static struct hda_verb alc861vd_volume_init_verbs[] = {
  7387. /*
  7388. * Unmute ADC0 and set the default input to mic-in
  7389. */
  7390. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7391. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7392. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  7393. * the analog-loopback mixer widget
  7394. */
  7395. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7396. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7397. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7398. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7399. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7400. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7401. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  7402. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7403. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7404. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7405. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
  7406. /*
  7407. * Set up output mixers (0x02 - 0x05)
  7408. */
  7409. /* set vol=0 to output mixers */
  7410. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7411. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7412. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7413. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7414. /* set up input amps for analog loopback */
  7415. /* Amp Indices: DAC = 0, mixer = 1 */
  7416. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7417. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7418. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7419. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7420. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7421. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7422. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7423. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7424. { }
  7425. };
  7426. /*
  7427. * 3-stack pin configuration:
  7428. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  7429. */
  7430. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  7431. /*
  7432. * Set pin mode and muting
  7433. */
  7434. /* set front pin widgets 0x14 for output */
  7435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7436. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7437. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7438. /* Mic (rear) pin: input vref at 80% */
  7439. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7440. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7441. /* Front Mic pin: input vref at 80% */
  7442. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7443. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7444. /* Line In pin: input */
  7445. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7446. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7447. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7448. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7449. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7450. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7451. /* CD pin widget for input */
  7452. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7453. { }
  7454. };
  7455. /*
  7456. * 6-stack pin configuration:
  7457. */
  7458. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  7459. /*
  7460. * Set pin mode and muting
  7461. */
  7462. /* set front pin widgets 0x14 for output */
  7463. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7464. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7465. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7466. /* Rear Pin: output 1 (0x0d) */
  7467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7469. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7470. /* CLFE Pin: output 2 (0x0e) */
  7471. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7472. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7473. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  7474. /* Side Pin: output 3 (0x0f) */
  7475. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7476. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7477. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  7478. /* Mic (rear) pin: input vref at 80% */
  7479. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7480. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7481. /* Front Mic pin: input vref at 80% */
  7482. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7483. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7484. /* Line In pin: input */
  7485. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7486. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7487. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7488. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7489. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7490. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7491. /* CD pin widget for input */
  7492. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7493. { }
  7494. };
  7495. /* pcm configuration: identiacal with ALC880 */
  7496. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  7497. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  7498. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  7499. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  7500. /*
  7501. * configuration and preset
  7502. */
  7503. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  7504. [ALC660VD_3ST] = "3stack-660",
  7505. [ALC861VD_3ST] = "3stack",
  7506. [ALC861VD_3ST_DIG] = "3stack-digout",
  7507. [ALC861VD_6ST_DIG] = "6stack-digout",
  7508. [ALC861VD_AUTO] = "auto",
  7509. };
  7510. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  7511. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  7512. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  7513. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  7514. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
  7515. {}
  7516. };
  7517. static struct alc_config_preset alc861vd_presets[] = {
  7518. [ALC660VD_3ST] = {
  7519. .mixers = { alc861vd_3st_mixer },
  7520. .init_verbs = { alc861vd_volume_init_verbs,
  7521. alc861vd_3stack_init_verbs },
  7522. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  7523. .dac_nids = alc660vd_dac_nids,
  7524. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  7525. .adc_nids = alc861vd_adc_nids,
  7526. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7527. .channel_mode = alc861vd_3stack_2ch_modes,
  7528. .input_mux = &alc861vd_capture_source,
  7529. },
  7530. [ALC861VD_3ST] = {
  7531. .mixers = { alc861vd_3st_mixer },
  7532. .init_verbs = { alc861vd_volume_init_verbs,
  7533. alc861vd_3stack_init_verbs },
  7534. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7535. .dac_nids = alc861vd_dac_nids,
  7536. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7537. .channel_mode = alc861vd_3stack_2ch_modes,
  7538. .input_mux = &alc861vd_capture_source,
  7539. },
  7540. [ALC861VD_3ST_DIG] = {
  7541. .mixers = { alc861vd_3st_mixer },
  7542. .init_verbs = { alc861vd_volume_init_verbs,
  7543. alc861vd_3stack_init_verbs },
  7544. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7545. .dac_nids = alc861vd_dac_nids,
  7546. .dig_out_nid = ALC861VD_DIGOUT_NID,
  7547. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7548. .channel_mode = alc861vd_3stack_2ch_modes,
  7549. .input_mux = &alc861vd_capture_source,
  7550. },
  7551. [ALC861VD_6ST_DIG] = {
  7552. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  7553. .init_verbs = { alc861vd_volume_init_verbs,
  7554. alc861vd_6stack_init_verbs },
  7555. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7556. .dac_nids = alc861vd_dac_nids,
  7557. .dig_out_nid = ALC861VD_DIGOUT_NID,
  7558. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  7559. .channel_mode = alc861vd_6stack_modes,
  7560. .input_mux = &alc861vd_capture_source,
  7561. },
  7562. };
  7563. /*
  7564. * BIOS auto configuration
  7565. */
  7566. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  7567. hda_nid_t nid, int pin_type, int dac_idx)
  7568. {
  7569. /* set as output */
  7570. snd_hda_codec_write(codec, nid, 0,
  7571. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  7572. snd_hda_codec_write(codec, nid, 0,
  7573. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  7574. }
  7575. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  7576. {
  7577. struct alc_spec *spec = codec->spec;
  7578. int i;
  7579. for (i = 0; i <= HDA_SIDE; i++) {
  7580. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7581. if (nid)
  7582. alc861vd_auto_set_output_and_unmute(codec, nid,
  7583. PIN_OUT, i);
  7584. }
  7585. }
  7586. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  7587. {
  7588. struct alc_spec *spec = codec->spec;
  7589. hda_nid_t pin;
  7590. pin = spec->autocfg.hp_pins[0];
  7591. if (pin) /* connect to front and use dac 0 */
  7592. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  7593. }
  7594. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  7595. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  7596. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  7597. {
  7598. struct alc_spec *spec = codec->spec;
  7599. int i;
  7600. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7601. hda_nid_t nid = spec->autocfg.input_pins[i];
  7602. if (alc861vd_is_input_pin(nid)) {
  7603. snd_hda_codec_write(codec, nid, 0,
  7604. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7605. i <= AUTO_PIN_FRONT_MIC ?
  7606. PIN_VREF80 : PIN_IN);
  7607. if (nid != ALC861VD_PIN_CD_NID)
  7608. snd_hda_codec_write(codec, nid, 0,
  7609. AC_VERB_SET_AMP_GAIN_MUTE,
  7610. AMP_OUT_MUTE);
  7611. }
  7612. }
  7613. }
  7614. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  7615. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  7616. /* add playback controls from the parsed DAC table */
  7617. /* Based on ALC880 version. But ALC861VD has separate,
  7618. * different NIDs for mute/unmute switch and volume control */
  7619. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  7620. const struct auto_pin_cfg *cfg)
  7621. {
  7622. char name[32];
  7623. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  7624. hda_nid_t nid_v, nid_s;
  7625. int i, err;
  7626. for (i = 0; i < cfg->line_outs; i++) {
  7627. if (! spec->multiout.dac_nids[i])
  7628. continue;
  7629. nid_v = alc861vd_idx_to_mixer_vol(
  7630. alc880_dac_to_idx(
  7631. spec->multiout.dac_nids[i]));
  7632. nid_s = alc861vd_idx_to_mixer_switch(
  7633. alc880_dac_to_idx(
  7634. spec->multiout.dac_nids[i]));
  7635. if (i == 2) {
  7636. /* Center/LFE */
  7637. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7638. "Center Playback Volume",
  7639. HDA_COMPOSE_AMP_VAL(nid_v, 1,
  7640. 0, HDA_OUTPUT))) < 0)
  7641. return err;
  7642. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7643. "LFE Playback Volume",
  7644. HDA_COMPOSE_AMP_VAL(nid_v, 2,
  7645. 0, HDA_OUTPUT))) < 0)
  7646. return err;
  7647. if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
  7648. "Center Playback Switch",
  7649. HDA_COMPOSE_AMP_VAL(nid_s, 1,
  7650. 2, HDA_INPUT))) < 0)
  7651. return err;
  7652. if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
  7653. "LFE Playback Switch",
  7654. HDA_COMPOSE_AMP_VAL(nid_s, 2,
  7655. 2, HDA_INPUT))) < 0)
  7656. return err;
  7657. } else {
  7658. sprintf(name, "%s Playback Volume", chname[i]);
  7659. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7660. HDA_COMPOSE_AMP_VAL(nid_v, 3,
  7661. 0, HDA_OUTPUT))) < 0)
  7662. return err;
  7663. sprintf(name, "%s Playback Switch", chname[i]);
  7664. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7665. HDA_COMPOSE_AMP_VAL(nid_v, 3,
  7666. 2, HDA_INPUT))) < 0)
  7667. return err;
  7668. }
  7669. }
  7670. return 0;
  7671. }
  7672. /* add playback controls for speaker and HP outputs */
  7673. /* Based on ALC880 version. But ALC861VD has separate,
  7674. * different NIDs for mute/unmute switch and volume control */
  7675. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  7676. hda_nid_t pin, const char *pfx)
  7677. {
  7678. hda_nid_t nid_v, nid_s;
  7679. int err;
  7680. char name[32];
  7681. if (! pin)
  7682. return 0;
  7683. if (alc880_is_fixed_pin(pin)) {
  7684. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  7685. /* specify the DAC as the extra output */
  7686. if (! spec->multiout.hp_nid)
  7687. spec->multiout.hp_nid = nid_v;
  7688. else
  7689. spec->multiout.extra_out_nid[0] = nid_v;
  7690. /* control HP volume/switch on the output mixer amp */
  7691. nid_v = alc861vd_idx_to_mixer_vol(
  7692. alc880_fixed_pin_idx(pin));
  7693. nid_s = alc861vd_idx_to_mixer_switch(
  7694. alc880_fixed_pin_idx(pin));
  7695. sprintf(name, "%s Playback Volume", pfx);
  7696. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7697. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  7698. HDA_OUTPUT))) < 0)
  7699. return err;
  7700. sprintf(name, "%s Playback Switch", pfx);
  7701. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7702. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  7703. HDA_INPUT))) < 0)
  7704. return err;
  7705. } else if (alc880_is_multi_pin(pin)) {
  7706. /* set manual connection */
  7707. /* we have only a switch on HP-out PIN */
  7708. sprintf(name, "%s Playback Switch", pfx);
  7709. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7710. HDA_COMPOSE_AMP_VAL(pin, 3, 0,
  7711. HDA_OUTPUT))) < 0)
  7712. return err;
  7713. }
  7714. return 0;
  7715. }
  7716. /* parse the BIOS configuration and set up the alc_spec
  7717. * return 1 if successful, 0 if the proper config is not found,
  7718. * or a negative error code
  7719. * Based on ALC880 version - had to change it to override
  7720. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  7721. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  7722. {
  7723. struct alc_spec *spec = codec->spec;
  7724. int err;
  7725. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  7726. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7727. alc861vd_ignore)) < 0)
  7728. return err;
  7729. if (! spec->autocfg.line_outs)
  7730. return 0; /* can't find valid BIOS pin config */
  7731. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  7732. (err = alc861vd_auto_create_multi_out_ctls(spec,
  7733. &spec->autocfg)) < 0 ||
  7734. (err = alc861vd_auto_create_extra_out(spec,
  7735. spec->autocfg.speaker_pins[0], "Speaker")) < 0 ||
  7736. (err = alc861vd_auto_create_extra_out(spec,
  7737. spec->autocfg.hp_pins[0], "Headphone")) < 0 ||
  7738. (err = alc880_auto_create_analog_input_ctls(spec,
  7739. &spec->autocfg)) < 0)
  7740. return err;
  7741. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7742. if (spec->autocfg.dig_out_pin)
  7743. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  7744. if (spec->kctl_alloc)
  7745. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7746. spec->init_verbs[spec->num_init_verbs++]
  7747. = alc861vd_volume_init_verbs;
  7748. spec->num_mux_defs = 1;
  7749. spec->input_mux = &spec->private_imux;
  7750. return 1;
  7751. }
  7752. /* additional initialization for auto-configuration model */
  7753. static void alc861vd_auto_init(struct hda_codec *codec)
  7754. {
  7755. alc861vd_auto_init_multi_out(codec);
  7756. alc861vd_auto_init_hp_out(codec);
  7757. alc861vd_auto_init_analog_input(codec);
  7758. }
  7759. static int patch_alc861vd(struct hda_codec *codec)
  7760. {
  7761. struct alc_spec *spec;
  7762. int err, board_config;
  7763. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7764. if (spec == NULL)
  7765. return -ENOMEM;
  7766. codec->spec = spec;
  7767. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  7768. alc861vd_models,
  7769. alc861vd_cfg_tbl);
  7770. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  7771. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  7772. "ALC861VD, trying auto-probe from BIOS...\n");
  7773. board_config = ALC861VD_AUTO;
  7774. }
  7775. if (board_config == ALC861VD_AUTO) {
  7776. /* automatic parse from the BIOS config */
  7777. err = alc861vd_parse_auto_config(codec);
  7778. if (err < 0) {
  7779. alc_free(codec);
  7780. return err;
  7781. } else if (! err) {
  7782. printk(KERN_INFO
  7783. "hda_codec: Cannot set up configuration "
  7784. "from BIOS. Using base mode...\n");
  7785. board_config = ALC861VD_3ST;
  7786. }
  7787. }
  7788. if (board_config != ALC861VD_AUTO)
  7789. setup_preset(spec, &alc861vd_presets[board_config]);
  7790. spec->stream_name_analog = "ALC861VD Analog";
  7791. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  7792. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  7793. spec->stream_name_digital = "ALC861VD Digital";
  7794. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  7795. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  7796. spec->adc_nids = alc861vd_adc_nids;
  7797. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  7798. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  7799. spec->num_mixers++;
  7800. codec->patch_ops = alc_patch_ops;
  7801. if (board_config == ALC861VD_AUTO)
  7802. spec->init_hook = alc861vd_auto_init;
  7803. return 0;
  7804. }
  7805. /*
  7806. * patch entries
  7807. */
  7808. struct hda_codec_preset snd_hda_preset_realtek[] = {
  7809. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  7810. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  7811. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  7812. .patch = patch_alc861 },
  7813. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  7814. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  7815. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  7816. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  7817. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  7818. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  7819. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  7820. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  7821. {} /* terminator */
  7822. };