patch_realtek.c 405 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC882_ASUS_A7M,
  149. ALC885_MACPRO,
  150. ALC885_MBP3,
  151. ALC885_IMAC24,
  152. ALC882_AUTO,
  153. ALC882_MODEL_LAST,
  154. };
  155. /* ALC883 models */
  156. enum {
  157. ALC883_3ST_2ch_DIG,
  158. ALC883_3ST_6ch_DIG,
  159. ALC883_3ST_6ch,
  160. ALC883_6ST_DIG,
  161. ALC883_TARGA_DIG,
  162. ALC883_TARGA_2ch_DIG,
  163. ALC883_ACER,
  164. ALC883_ACER_ASPIRE,
  165. ALC883_MEDION,
  166. ALC883_MEDION_MD2,
  167. ALC883_LAPTOP_EAPD,
  168. ALC883_LENOVO_101E_2ch,
  169. ALC883_LENOVO_NB0763,
  170. ALC888_LENOVO_MS7195_DIG,
  171. ALC883_HAIER_W66,
  172. ALC888_6ST_HP,
  173. ALC888_3ST_HP,
  174. ALC883_AUTO,
  175. ALC883_MODEL_LAST,
  176. };
  177. /* for GPIO Poll */
  178. #define GPIO_MASK 0x03
  179. struct alc_spec {
  180. /* codec parameterization */
  181. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  182. unsigned int num_mixers;
  183. const struct hda_verb *init_verbs[5]; /* initialization verbs
  184. * don't forget NULL
  185. * termination!
  186. */
  187. unsigned int num_init_verbs;
  188. char *stream_name_analog; /* analog PCM stream */
  189. struct hda_pcm_stream *stream_analog_playback;
  190. struct hda_pcm_stream *stream_analog_capture;
  191. char *stream_name_digital; /* digital PCM stream */
  192. struct hda_pcm_stream *stream_digital_playback;
  193. struct hda_pcm_stream *stream_digital_capture;
  194. /* playback */
  195. struct hda_multi_out multiout; /* playback set-up
  196. * max_channels, dacs must be set
  197. * dig_out_nid and hp_nid are optional
  198. */
  199. /* capture */
  200. unsigned int num_adc_nids;
  201. hda_nid_t *adc_nids;
  202. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  203. /* capture source */
  204. unsigned int num_mux_defs;
  205. const struct hda_input_mux *input_mux;
  206. unsigned int cur_mux[3];
  207. /* channel model */
  208. const struct hda_channel_mode *channel_mode;
  209. int num_channel_mode;
  210. int need_dac_fix;
  211. /* PCM information */
  212. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  213. /* dynamic controls, init_verbs and input_mux */
  214. struct auto_pin_cfg autocfg;
  215. unsigned int num_kctl_alloc, num_kctl_used;
  216. struct snd_kcontrol_new *kctl_alloc;
  217. struct hda_input_mux private_imux;
  218. hda_nid_t private_dac_nids[5];
  219. /* hooks */
  220. void (*init_hook)(struct hda_codec *codec);
  221. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  222. /* for pin sensing */
  223. unsigned int sense_updated: 1;
  224. unsigned int jack_present: 1;
  225. #ifdef CONFIG_SND_HDA_POWER_SAVE
  226. struct hda_loopback_check loopback;
  227. #endif
  228. };
  229. /*
  230. * configuration template - to be copied to the spec instance
  231. */
  232. struct alc_config_preset {
  233. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  234. * with spec
  235. */
  236. const struct hda_verb *init_verbs[5];
  237. unsigned int num_dacs;
  238. hda_nid_t *dac_nids;
  239. hda_nid_t dig_out_nid; /* optional */
  240. hda_nid_t hp_nid; /* optional */
  241. unsigned int num_adc_nids;
  242. hda_nid_t *adc_nids;
  243. hda_nid_t dig_in_nid;
  244. unsigned int num_channel_mode;
  245. const struct hda_channel_mode *channel_mode;
  246. int need_dac_fix;
  247. unsigned int num_mux_defs;
  248. const struct hda_input_mux *input_mux;
  249. void (*unsol_event)(struct hda_codec *, unsigned int);
  250. void (*init_hook)(struct hda_codec *);
  251. #ifdef CONFIG_SND_HDA_POWER_SAVE
  252. struct hda_amp_list *loopbacks;
  253. #endif
  254. };
  255. /*
  256. * input MUX handling
  257. */
  258. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  259. struct snd_ctl_elem_info *uinfo)
  260. {
  261. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  262. struct alc_spec *spec = codec->spec;
  263. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  264. if (mux_idx >= spec->num_mux_defs)
  265. mux_idx = 0;
  266. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  267. }
  268. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  269. struct snd_ctl_elem_value *ucontrol)
  270. {
  271. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  272. struct alc_spec *spec = codec->spec;
  273. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  274. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  275. return 0;
  276. }
  277. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol)
  279. {
  280. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  281. struct alc_spec *spec = codec->spec;
  282. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  283. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  284. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  285. spec->adc_nids[adc_idx],
  286. &spec->cur_mux[adc_idx]);
  287. }
  288. /*
  289. * channel mode setting
  290. */
  291. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_info *uinfo)
  293. {
  294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  295. struct alc_spec *spec = codec->spec;
  296. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  297. spec->num_channel_mode);
  298. }
  299. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  300. struct snd_ctl_elem_value *ucontrol)
  301. {
  302. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  303. struct alc_spec *spec = codec->spec;
  304. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  305. spec->num_channel_mode,
  306. spec->multiout.max_channels);
  307. }
  308. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  309. struct snd_ctl_elem_value *ucontrol)
  310. {
  311. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  312. struct alc_spec *spec = codec->spec;
  313. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  314. spec->num_channel_mode,
  315. &spec->multiout.max_channels);
  316. if (err >= 0 && spec->need_dac_fix)
  317. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  318. return err;
  319. }
  320. /*
  321. * Control the mode of pin widget settings via the mixer. "pc" is used
  322. * instead of "%" to avoid consequences of accidently treating the % as
  323. * being part of a format specifier. Maximum allowed length of a value is
  324. * 63 characters plus NULL terminator.
  325. *
  326. * Note: some retasking pin complexes seem to ignore requests for input
  327. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  328. * are requested. Therefore order this list so that this behaviour will not
  329. * cause problems when mixer clients move through the enum sequentially.
  330. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  331. * March 2006.
  332. */
  333. static char *alc_pin_mode_names[] = {
  334. "Mic 50pc bias", "Mic 80pc bias",
  335. "Line in", "Line out", "Headphone out",
  336. };
  337. static unsigned char alc_pin_mode_values[] = {
  338. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  339. };
  340. /* The control can present all 5 options, or it can limit the options based
  341. * in the pin being assumed to be exclusively an input or an output pin. In
  342. * addition, "input" pins may or may not process the mic bias option
  343. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  344. * accept requests for bias as of chip versions up to March 2006) and/or
  345. * wiring in the computer.
  346. */
  347. #define ALC_PIN_DIR_IN 0x00
  348. #define ALC_PIN_DIR_OUT 0x01
  349. #define ALC_PIN_DIR_INOUT 0x02
  350. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  351. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  352. /* Info about the pin modes supported by the different pin direction modes.
  353. * For each direction the minimum and maximum values are given.
  354. */
  355. static signed char alc_pin_mode_dir_info[5][2] = {
  356. { 0, 2 }, /* ALC_PIN_DIR_IN */
  357. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  358. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  359. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  360. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  361. };
  362. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  363. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  364. #define alc_pin_mode_n_items(_dir) \
  365. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  366. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  367. struct snd_ctl_elem_info *uinfo)
  368. {
  369. unsigned int item_num = uinfo->value.enumerated.item;
  370. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  371. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  372. uinfo->count = 1;
  373. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  374. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  375. item_num = alc_pin_mode_min(dir);
  376. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  377. return 0;
  378. }
  379. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  380. struct snd_ctl_elem_value *ucontrol)
  381. {
  382. unsigned int i;
  383. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  384. hda_nid_t nid = kcontrol->private_value & 0xffff;
  385. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  386. long *valp = ucontrol->value.integer.value;
  387. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  388. AC_VERB_GET_PIN_WIDGET_CONTROL,
  389. 0x00);
  390. /* Find enumerated value for current pinctl setting */
  391. i = alc_pin_mode_min(dir);
  392. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  393. i++;
  394. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  395. return 0;
  396. }
  397. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  398. struct snd_ctl_elem_value *ucontrol)
  399. {
  400. signed int change;
  401. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  402. hda_nid_t nid = kcontrol->private_value & 0xffff;
  403. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  404. long val = *ucontrol->value.integer.value;
  405. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  406. AC_VERB_GET_PIN_WIDGET_CONTROL,
  407. 0x00);
  408. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  409. val = alc_pin_mode_min(dir);
  410. change = pinctl != alc_pin_mode_values[val];
  411. if (change) {
  412. /* Set pin mode to that requested */
  413. snd_hda_codec_write_cache(codec, nid, 0,
  414. AC_VERB_SET_PIN_WIDGET_CONTROL,
  415. alc_pin_mode_values[val]);
  416. /* Also enable the retasking pin's input/output as required
  417. * for the requested pin mode. Enum values of 2 or less are
  418. * input modes.
  419. *
  420. * Dynamically switching the input/output buffers probably
  421. * reduces noise slightly (particularly on input) so we'll
  422. * do it. However, having both input and output buffers
  423. * enabled simultaneously doesn't seem to be problematic if
  424. * this turns out to be necessary in the future.
  425. */
  426. if (val <= 2) {
  427. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  428. HDA_AMP_MUTE, HDA_AMP_MUTE);
  429. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  430. HDA_AMP_MUTE, 0);
  431. } else {
  432. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  433. HDA_AMP_MUTE, HDA_AMP_MUTE);
  434. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  435. HDA_AMP_MUTE, 0);
  436. }
  437. }
  438. return change;
  439. }
  440. #define ALC_PIN_MODE(xname, nid, dir) \
  441. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  442. .info = alc_pin_mode_info, \
  443. .get = alc_pin_mode_get, \
  444. .put = alc_pin_mode_put, \
  445. .private_value = nid | (dir<<16) }
  446. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  447. * together using a mask with more than one bit set. This control is
  448. * currently used only by the ALC260 test model. At this stage they are not
  449. * needed for any "production" models.
  450. */
  451. #ifdef CONFIG_SND_DEBUG
  452. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  453. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  454. struct snd_ctl_elem_value *ucontrol)
  455. {
  456. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  457. hda_nid_t nid = kcontrol->private_value & 0xffff;
  458. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  459. long *valp = ucontrol->value.integer.value;
  460. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  461. AC_VERB_GET_GPIO_DATA, 0x00);
  462. *valp = (val & mask) != 0;
  463. return 0;
  464. }
  465. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  466. struct snd_ctl_elem_value *ucontrol)
  467. {
  468. signed int change;
  469. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  470. hda_nid_t nid = kcontrol->private_value & 0xffff;
  471. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  472. long val = *ucontrol->value.integer.value;
  473. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  474. AC_VERB_GET_GPIO_DATA,
  475. 0x00);
  476. /* Set/unset the masked GPIO bit(s) as needed */
  477. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  478. if (val == 0)
  479. gpio_data &= ~mask;
  480. else
  481. gpio_data |= mask;
  482. snd_hda_codec_write_cache(codec, nid, 0,
  483. AC_VERB_SET_GPIO_DATA, gpio_data);
  484. return change;
  485. }
  486. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  487. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  488. .info = alc_gpio_data_info, \
  489. .get = alc_gpio_data_get, \
  490. .put = alc_gpio_data_put, \
  491. .private_value = nid | (mask<<16) }
  492. #endif /* CONFIG_SND_DEBUG */
  493. /* A switch control to allow the enabling of the digital IO pins on the
  494. * ALC260. This is incredibly simplistic; the intention of this control is
  495. * to provide something in the test model allowing digital outputs to be
  496. * identified if present. If models are found which can utilise these
  497. * outputs a more complete mixer control can be devised for those models if
  498. * necessary.
  499. */
  500. #ifdef CONFIG_SND_DEBUG
  501. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  502. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  503. struct snd_ctl_elem_value *ucontrol)
  504. {
  505. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  506. hda_nid_t nid = kcontrol->private_value & 0xffff;
  507. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  508. long *valp = ucontrol->value.integer.value;
  509. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  510. AC_VERB_GET_DIGI_CONVERT, 0x00);
  511. *valp = (val & mask) != 0;
  512. return 0;
  513. }
  514. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  515. struct snd_ctl_elem_value *ucontrol)
  516. {
  517. signed int change;
  518. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  519. hda_nid_t nid = kcontrol->private_value & 0xffff;
  520. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  521. long val = *ucontrol->value.integer.value;
  522. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  523. AC_VERB_GET_DIGI_CONVERT,
  524. 0x00);
  525. /* Set/unset the masked control bit(s) as needed */
  526. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  527. if (val==0)
  528. ctrl_data &= ~mask;
  529. else
  530. ctrl_data |= mask;
  531. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  532. ctrl_data);
  533. return change;
  534. }
  535. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  536. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  537. .info = alc_spdif_ctrl_info, \
  538. .get = alc_spdif_ctrl_get, \
  539. .put = alc_spdif_ctrl_put, \
  540. .private_value = nid | (mask<<16) }
  541. #endif /* CONFIG_SND_DEBUG */
  542. /*
  543. * set up from the preset table
  544. */
  545. static void setup_preset(struct alc_spec *spec,
  546. const struct alc_config_preset *preset)
  547. {
  548. int i;
  549. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  550. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  551. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  552. i++)
  553. spec->init_verbs[spec->num_init_verbs++] =
  554. preset->init_verbs[i];
  555. spec->channel_mode = preset->channel_mode;
  556. spec->num_channel_mode = preset->num_channel_mode;
  557. spec->need_dac_fix = preset->need_dac_fix;
  558. spec->multiout.max_channels = spec->channel_mode[0].channels;
  559. spec->multiout.num_dacs = preset->num_dacs;
  560. spec->multiout.dac_nids = preset->dac_nids;
  561. spec->multiout.dig_out_nid = preset->dig_out_nid;
  562. spec->multiout.hp_nid = preset->hp_nid;
  563. spec->num_mux_defs = preset->num_mux_defs;
  564. if (!spec->num_mux_defs)
  565. spec->num_mux_defs = 1;
  566. spec->input_mux = preset->input_mux;
  567. spec->num_adc_nids = preset->num_adc_nids;
  568. spec->adc_nids = preset->adc_nids;
  569. spec->dig_in_nid = preset->dig_in_nid;
  570. spec->unsol_event = preset->unsol_event;
  571. spec->init_hook = preset->init_hook;
  572. #ifdef CONFIG_SND_HDA_POWER_SAVE
  573. spec->loopback.amplist = preset->loopbacks;
  574. #endif
  575. }
  576. /* Enable GPIO mask and set output */
  577. static struct hda_verb alc_gpio1_init_verbs[] = {
  578. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  579. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  581. { }
  582. };
  583. static struct hda_verb alc_gpio2_init_verbs[] = {
  584. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  585. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  587. { }
  588. };
  589. static struct hda_verb alc_gpio3_init_verbs[] = {
  590. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  591. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  593. { }
  594. };
  595. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  596. * 31 ~ 16 : Manufacture ID
  597. * 15 ~ 8 : SKU ID
  598. * 7 ~ 0 : Assembly ID
  599. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  600. */
  601. static void alc_subsystem_id(struct hda_codec *codec,
  602. unsigned int porta, unsigned int porte,
  603. unsigned int portd)
  604. {
  605. unsigned int ass, tmp;
  606. ass = codec->subsystem_id;
  607. if (!(ass & 1))
  608. return;
  609. /* Override */
  610. tmp = (ass & 0x38) >> 3; /* external Amp control */
  611. switch (tmp) {
  612. case 1:
  613. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  614. break;
  615. case 3:
  616. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  617. break;
  618. case 7:
  619. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  620. break;
  621. case 5:
  622. switch (codec->vendor_id) {
  623. case 0x10ec0862:
  624. case 0x10ec0660:
  625. case 0x10ec0662:
  626. case 0x10ec0267:
  627. case 0x10ec0268:
  628. snd_hda_codec_write(codec, 0x14, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. snd_hda_codec_write(codec, 0x15, 0,
  631. AC_VERB_SET_EAPD_BTLENABLE, 2);
  632. return;
  633. }
  634. case 6:
  635. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  636. hda_nid_t port = 0;
  637. tmp = (ass & 0x1800) >> 11;
  638. switch (tmp) {
  639. case 0: port = porta; break;
  640. case 1: port = porte; break;
  641. case 2: port = portd; break;
  642. }
  643. if (port)
  644. snd_hda_codec_write(codec, port, 0,
  645. AC_VERB_SET_EAPD_BTLENABLE,
  646. 2);
  647. }
  648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  649. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  650. (tmp == 5 ? 0x3040 : 0x3050));
  651. break;
  652. }
  653. }
  654. /*
  655. * Fix-up pin default configurations
  656. */
  657. struct alc_pincfg {
  658. hda_nid_t nid;
  659. u32 val;
  660. };
  661. static void alc_fix_pincfg(struct hda_codec *codec,
  662. const struct snd_pci_quirk *quirk,
  663. const struct alc_pincfg **pinfix)
  664. {
  665. const struct alc_pincfg *cfg;
  666. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  667. if (!quirk)
  668. return;
  669. cfg = pinfix[quirk->value];
  670. for (; cfg->nid; cfg++) {
  671. int i;
  672. u32 val = cfg->val;
  673. for (i = 0; i < 4; i++) {
  674. snd_hda_codec_write(codec, cfg->nid, 0,
  675. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  676. val & 0xff);
  677. val >>= 8;
  678. }
  679. }
  680. }
  681. /*
  682. * ALC880 3-stack model
  683. *
  684. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  685. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  686. * F-Mic = 0x1b, HP = 0x19
  687. */
  688. static hda_nid_t alc880_dac_nids[4] = {
  689. /* front, rear, clfe, rear_surr */
  690. 0x02, 0x05, 0x04, 0x03
  691. };
  692. static hda_nid_t alc880_adc_nids[3] = {
  693. /* ADC0-2 */
  694. 0x07, 0x08, 0x09,
  695. };
  696. /* The datasheet says the node 0x07 is connected from inputs,
  697. * but it shows zero connection in the real implementation on some devices.
  698. * Note: this is a 915GAV bug, fixed on 915GLV
  699. */
  700. static hda_nid_t alc880_adc_nids_alt[2] = {
  701. /* ADC1-2 */
  702. 0x08, 0x09,
  703. };
  704. #define ALC880_DIGOUT_NID 0x06
  705. #define ALC880_DIGIN_NID 0x0a
  706. static struct hda_input_mux alc880_capture_source = {
  707. .num_items = 4,
  708. .items = {
  709. { "Mic", 0x0 },
  710. { "Front Mic", 0x3 },
  711. { "Line", 0x2 },
  712. { "CD", 0x4 },
  713. },
  714. };
  715. /* channel source setting (2/6 channel selection for 3-stack) */
  716. /* 2ch mode */
  717. static struct hda_verb alc880_threestack_ch2_init[] = {
  718. /* set line-in to input, mute it */
  719. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  720. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  721. /* set mic-in to input vref 80%, mute it */
  722. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  723. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  724. { } /* end */
  725. };
  726. /* 6ch mode */
  727. static struct hda_verb alc880_threestack_ch6_init[] = {
  728. /* set line-in to output, unmute it */
  729. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  730. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  731. /* set mic-in to output, unmute it */
  732. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  733. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  734. { } /* end */
  735. };
  736. static struct hda_channel_mode alc880_threestack_modes[2] = {
  737. { 2, alc880_threestack_ch2_init },
  738. { 6, alc880_threestack_ch6_init },
  739. };
  740. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  741. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  742. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  743. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  744. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  745. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  746. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  747. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  748. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  749. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  750. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  751. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  752. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  754. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  755. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  756. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  757. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  758. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  759. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  760. {
  761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  762. .name = "Channel Mode",
  763. .info = alc_ch_mode_info,
  764. .get = alc_ch_mode_get,
  765. .put = alc_ch_mode_put,
  766. },
  767. { } /* end */
  768. };
  769. /* capture mixer elements */
  770. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  771. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  772. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  773. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  774. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  775. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  776. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  777. {
  778. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  779. /* The multiple "Capture Source" controls confuse alsamixer
  780. * So call somewhat different..
  781. * FIXME: the controls appear in the "playback" view!
  782. */
  783. /* .name = "Capture Source", */
  784. .name = "Input Source",
  785. .count = 3,
  786. .info = alc_mux_enum_info,
  787. .get = alc_mux_enum_get,
  788. .put = alc_mux_enum_put,
  789. },
  790. { } /* end */
  791. };
  792. /* capture mixer elements (in case NID 0x07 not available) */
  793. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  794. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  795. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  796. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  797. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  798. {
  799. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  800. /* The multiple "Capture Source" controls confuse alsamixer
  801. * So call somewhat different..
  802. * FIXME: the controls appear in the "playback" view!
  803. */
  804. /* .name = "Capture Source", */
  805. .name = "Input Source",
  806. .count = 2,
  807. .info = alc_mux_enum_info,
  808. .get = alc_mux_enum_get,
  809. .put = alc_mux_enum_put,
  810. },
  811. { } /* end */
  812. };
  813. /*
  814. * ALC880 5-stack model
  815. *
  816. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  817. * Side = 0x02 (0xd)
  818. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  819. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  820. */
  821. /* additional mixers to alc880_three_stack_mixer */
  822. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  823. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  824. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  825. { } /* end */
  826. };
  827. /* channel source setting (6/8 channel selection for 5-stack) */
  828. /* 6ch mode */
  829. static struct hda_verb alc880_fivestack_ch6_init[] = {
  830. /* set line-in to input, mute it */
  831. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  832. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  833. { } /* end */
  834. };
  835. /* 8ch mode */
  836. static struct hda_verb alc880_fivestack_ch8_init[] = {
  837. /* set line-in to output, unmute it */
  838. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  839. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  840. { } /* end */
  841. };
  842. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  843. { 6, alc880_fivestack_ch6_init },
  844. { 8, alc880_fivestack_ch8_init },
  845. };
  846. /*
  847. * ALC880 6-stack model
  848. *
  849. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  850. * Side = 0x05 (0x0f)
  851. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  852. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  853. */
  854. static hda_nid_t alc880_6st_dac_nids[4] = {
  855. /* front, rear, clfe, rear_surr */
  856. 0x02, 0x03, 0x04, 0x05
  857. };
  858. static struct hda_input_mux alc880_6stack_capture_source = {
  859. .num_items = 4,
  860. .items = {
  861. { "Mic", 0x0 },
  862. { "Front Mic", 0x1 },
  863. { "Line", 0x2 },
  864. { "CD", 0x4 },
  865. },
  866. };
  867. /* fixed 8-channels */
  868. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  869. { 8, NULL },
  870. };
  871. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  872. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  875. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  876. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  877. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  878. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  879. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  881. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  882. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  883. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  884. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  885. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  886. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  887. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  888. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  889. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  890. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  891. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  892. {
  893. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  894. .name = "Channel Mode",
  895. .info = alc_ch_mode_info,
  896. .get = alc_ch_mode_get,
  897. .put = alc_ch_mode_put,
  898. },
  899. { } /* end */
  900. };
  901. /*
  902. * ALC880 W810 model
  903. *
  904. * W810 has rear IO for:
  905. * Front (DAC 02)
  906. * Surround (DAC 03)
  907. * Center/LFE (DAC 04)
  908. * Digital out (06)
  909. *
  910. * The system also has a pair of internal speakers, and a headphone jack.
  911. * These are both connected to Line2 on the codec, hence to DAC 02.
  912. *
  913. * There is a variable resistor to control the speaker or headphone
  914. * volume. This is a hardware-only device without a software API.
  915. *
  916. * Plugging headphones in will disable the internal speakers. This is
  917. * implemented in hardware, not via the driver using jack sense. In
  918. * a similar fashion, plugging into the rear socket marked "front" will
  919. * disable both the speakers and headphones.
  920. *
  921. * For input, there's a microphone jack, and an "audio in" jack.
  922. * These may not do anything useful with this driver yet, because I
  923. * haven't setup any initialization verbs for these yet...
  924. */
  925. static hda_nid_t alc880_w810_dac_nids[3] = {
  926. /* front, rear/surround, clfe */
  927. 0x02, 0x03, 0x04
  928. };
  929. /* fixed 6 channels */
  930. static struct hda_channel_mode alc880_w810_modes[1] = {
  931. { 6, NULL }
  932. };
  933. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  934. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  935. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  938. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  939. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  940. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  941. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  942. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  943. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  944. { } /* end */
  945. };
  946. /*
  947. * Z710V model
  948. *
  949. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  950. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  951. * Line = 0x1a
  952. */
  953. static hda_nid_t alc880_z71v_dac_nids[1] = {
  954. 0x02
  955. };
  956. #define ALC880_Z71V_HP_DAC 0x03
  957. /* fixed 2 channels */
  958. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  959. { 2, NULL }
  960. };
  961. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  962. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  963. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  964. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  965. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  966. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  967. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  968. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  969. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  970. { } /* end */
  971. };
  972. /* FIXME! */
  973. /*
  974. * ALC880 F1734 model
  975. *
  976. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  977. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  978. */
  979. static hda_nid_t alc880_f1734_dac_nids[1] = {
  980. 0x03
  981. };
  982. #define ALC880_F1734_HP_DAC 0x02
  983. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  984. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  987. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  988. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  990. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  991. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  992. { } /* end */
  993. };
  994. /* FIXME! */
  995. /*
  996. * ALC880 ASUS model
  997. *
  998. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  999. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1000. * Mic = 0x18, Line = 0x1a
  1001. */
  1002. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1003. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1004. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1005. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1006. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1007. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1008. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1009. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1010. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1011. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1012. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1013. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1014. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1015. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1016. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1017. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1018. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1019. {
  1020. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1021. .name = "Channel Mode",
  1022. .info = alc_ch_mode_info,
  1023. .get = alc_ch_mode_get,
  1024. .put = alc_ch_mode_put,
  1025. },
  1026. { } /* end */
  1027. };
  1028. /* FIXME! */
  1029. /*
  1030. * ALC880 ASUS W1V model
  1031. *
  1032. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1033. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1034. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1035. */
  1036. /* additional mixers to alc880_asus_mixer */
  1037. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1038. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1039. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1040. { } /* end */
  1041. };
  1042. /* additional mixers to alc880_asus_mixer */
  1043. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1044. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1045. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1046. { } /* end */
  1047. };
  1048. /* TCL S700 */
  1049. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1050. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1054. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1056. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1059. {
  1060. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1061. /* The multiple "Capture Source" controls confuse alsamixer
  1062. * So call somewhat different..
  1063. * FIXME: the controls appear in the "playback" view!
  1064. */
  1065. /* .name = "Capture Source", */
  1066. .name = "Input Source",
  1067. .count = 1,
  1068. .info = alc_mux_enum_info,
  1069. .get = alc_mux_enum_get,
  1070. .put = alc_mux_enum_put,
  1071. },
  1072. { } /* end */
  1073. };
  1074. /* Uniwill */
  1075. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1076. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1080. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1081. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1082. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1083. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1085. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1088. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1089. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1091. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1093. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1094. {
  1095. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1096. .name = "Channel Mode",
  1097. .info = alc_ch_mode_info,
  1098. .get = alc_ch_mode_get,
  1099. .put = alc_ch_mode_put,
  1100. },
  1101. { } /* end */
  1102. };
  1103. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1104. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1105. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1107. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1109. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1110. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1111. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1112. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1113. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1114. { } /* end */
  1115. };
  1116. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1117. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1118. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1119. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1120. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1121. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1122. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1123. { } /* end */
  1124. };
  1125. /*
  1126. * build control elements
  1127. */
  1128. static int alc_build_controls(struct hda_codec *codec)
  1129. {
  1130. struct alc_spec *spec = codec->spec;
  1131. int err;
  1132. int i;
  1133. for (i = 0; i < spec->num_mixers; i++) {
  1134. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1135. if (err < 0)
  1136. return err;
  1137. }
  1138. if (spec->multiout.dig_out_nid) {
  1139. err = snd_hda_create_spdif_out_ctls(codec,
  1140. spec->multiout.dig_out_nid);
  1141. if (err < 0)
  1142. return err;
  1143. }
  1144. if (spec->dig_in_nid) {
  1145. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1146. if (err < 0)
  1147. return err;
  1148. }
  1149. return 0;
  1150. }
  1151. /*
  1152. * initialize the codec volumes, etc
  1153. */
  1154. /*
  1155. * generic initialization of ADC, input mixers and output mixers
  1156. */
  1157. static struct hda_verb alc880_volume_init_verbs[] = {
  1158. /*
  1159. * Unmute ADC0-2 and set the default input to mic-in
  1160. */
  1161. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1162. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1163. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1164. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1165. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1166. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1167. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1168. * mixer widget
  1169. * Note: PASD motherboards uses the Line In 2 as the input for front
  1170. * panel mic (mic 2)
  1171. */
  1172. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1180. /*
  1181. * Set up output mixers (0x0c - 0x0f)
  1182. */
  1183. /* set vol=0 to output mixers */
  1184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1188. /* set up input amps for analog loopback */
  1189. /* Amp Indices: DAC = 0, mixer = 1 */
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1198. { }
  1199. };
  1200. /*
  1201. * 3-stack pin configuration:
  1202. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1203. */
  1204. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1205. /*
  1206. * preset connection lists of input pins
  1207. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1208. */
  1209. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1210. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1211. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1212. /*
  1213. * Set pin mode and muting
  1214. */
  1215. /* set front pin widgets 0x14 for output */
  1216. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1219. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. /* Mic2 (as headphone out) for HP output */
  1222. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1223. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1224. /* Line In pin widget for input */
  1225. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1228. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1229. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* CD pin widget for input */
  1231. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1232. { }
  1233. };
  1234. /*
  1235. * 5-stack pin configuration:
  1236. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1237. * line-in/side = 0x1a, f-mic = 0x1b
  1238. */
  1239. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1240. /*
  1241. * preset connection lists of input pins
  1242. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1243. */
  1244. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1245. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1246. /*
  1247. * Set pin mode and muting
  1248. */
  1249. /* set pin widgets 0x14-0x17 for output */
  1250. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. /* unmute pins for output (no gain on this amp) */
  1255. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1259. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1260. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1261. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1262. /* Mic2 (as headphone out) for HP output */
  1263. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1264. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1265. /* Line In pin widget for input */
  1266. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1268. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1269. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1270. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1271. /* CD pin widget for input */
  1272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1273. { }
  1274. };
  1275. /*
  1276. * W810 pin configuration:
  1277. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1278. */
  1279. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1280. /* hphone/speaker input selector: front DAC */
  1281. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1282. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1287. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1288. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1289. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1290. { }
  1291. };
  1292. /*
  1293. * Z71V pin configuration:
  1294. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1295. */
  1296. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1297. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1298. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1300. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1301. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1302. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1303. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1304. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1305. { }
  1306. };
  1307. /*
  1308. * 6-stack pin configuration:
  1309. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1310. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1311. */
  1312. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1313. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1314. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1319. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1321. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1322. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1326. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1327. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1328. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1329. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1330. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1331. { }
  1332. };
  1333. /*
  1334. * Uniwill pin configuration:
  1335. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1336. * line = 0x1a
  1337. */
  1338. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1339. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1342. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1361. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1362. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1363. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1364. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1365. { }
  1366. };
  1367. /*
  1368. * Uniwill P53
  1369. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1370. */
  1371. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1372. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1385. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1386. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1387. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1388. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1389. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1390. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1391. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1392. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1393. { }
  1394. };
  1395. static struct hda_verb alc880_beep_init_verbs[] = {
  1396. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1397. { }
  1398. };
  1399. /* toggle speaker-output according to the hp-jack state */
  1400. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1401. {
  1402. unsigned int present;
  1403. unsigned char bits;
  1404. present = snd_hda_codec_read(codec, 0x14, 0,
  1405. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1406. bits = present ? HDA_AMP_MUTE : 0;
  1407. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1408. HDA_AMP_MUTE, bits);
  1409. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1410. HDA_AMP_MUTE, bits);
  1411. }
  1412. /* auto-toggle front mic */
  1413. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1414. {
  1415. unsigned int present;
  1416. unsigned char bits;
  1417. present = snd_hda_codec_read(codec, 0x18, 0,
  1418. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1419. bits = present ? HDA_AMP_MUTE : 0;
  1420. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1421. }
  1422. static void alc880_uniwill_automute(struct hda_codec *codec)
  1423. {
  1424. alc880_uniwill_hp_automute(codec);
  1425. alc880_uniwill_mic_automute(codec);
  1426. }
  1427. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1428. unsigned int res)
  1429. {
  1430. /* Looks like the unsol event is incompatible with the standard
  1431. * definition. 4bit tag is placed at 28 bit!
  1432. */
  1433. switch (res >> 28) {
  1434. case ALC880_HP_EVENT:
  1435. alc880_uniwill_hp_automute(codec);
  1436. break;
  1437. case ALC880_MIC_EVENT:
  1438. alc880_uniwill_mic_automute(codec);
  1439. break;
  1440. }
  1441. }
  1442. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1443. {
  1444. unsigned int present;
  1445. unsigned char bits;
  1446. present = snd_hda_codec_read(codec, 0x14, 0,
  1447. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1448. bits = present ? HDA_AMP_MUTE : 0;
  1449. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1450. }
  1451. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1452. {
  1453. unsigned int present;
  1454. present = snd_hda_codec_read(codec, 0x21, 0,
  1455. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1456. present &= HDA_AMP_VOLMASK;
  1457. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1458. HDA_AMP_VOLMASK, present);
  1459. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1460. HDA_AMP_VOLMASK, present);
  1461. }
  1462. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1463. unsigned int res)
  1464. {
  1465. /* Looks like the unsol event is incompatible with the standard
  1466. * definition. 4bit tag is placed at 28 bit!
  1467. */
  1468. if ((res >> 28) == ALC880_HP_EVENT)
  1469. alc880_uniwill_p53_hp_automute(codec);
  1470. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1471. alc880_uniwill_p53_dcvol_automute(codec);
  1472. }
  1473. /* FIXME! */
  1474. /*
  1475. * F1734 pin configuration:
  1476. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1477. */
  1478. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1479. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1480. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1482. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1486. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1487. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1488. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1489. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1490. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1491. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1494. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1495. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. { }
  1497. };
  1498. /* FIXME! */
  1499. /*
  1500. * ASUS pin configuration:
  1501. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1502. */
  1503. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1504. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1505. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1506. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1507. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1508. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1510. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1513. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1514. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1515. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1516. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1518. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1519. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1520. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1522. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1523. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1525. { }
  1526. };
  1527. /* Enable GPIO mask and set output */
  1528. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1529. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1530. /* Clevo m520g init */
  1531. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1532. /* headphone output */
  1533. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1534. /* line-out */
  1535. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1536. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* Line-in */
  1538. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1539. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* CD */
  1541. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1542. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1543. /* Mic1 (rear panel) */
  1544. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1545. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1546. /* Mic2 (front panel) */
  1547. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1548. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* headphone */
  1550. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1551. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1552. /* change to EAPD mode */
  1553. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1554. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1555. { }
  1556. };
  1557. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1558. /* change to EAPD mode */
  1559. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1560. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1561. /* Headphone output */
  1562. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1563. /* Front output*/
  1564. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1565. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1566. /* Line In pin widget for input */
  1567. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1568. /* CD pin widget for input */
  1569. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1570. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1571. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1572. /* change to EAPD mode */
  1573. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1574. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1575. { }
  1576. };
  1577. /*
  1578. * LG m1 express dual
  1579. *
  1580. * Pin assignment:
  1581. * Rear Line-In/Out (blue): 0x14
  1582. * Build-in Mic-In: 0x15
  1583. * Speaker-out: 0x17
  1584. * HP-Out (green): 0x1b
  1585. * Mic-In/Out (red): 0x19
  1586. * SPDIF-Out: 0x1e
  1587. */
  1588. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1589. static hda_nid_t alc880_lg_dac_nids[3] = {
  1590. 0x05, 0x02, 0x03
  1591. };
  1592. /* seems analog CD is not working */
  1593. static struct hda_input_mux alc880_lg_capture_source = {
  1594. .num_items = 3,
  1595. .items = {
  1596. { "Mic", 0x1 },
  1597. { "Line", 0x5 },
  1598. { "Internal Mic", 0x6 },
  1599. },
  1600. };
  1601. /* 2,4,6 channel modes */
  1602. static struct hda_verb alc880_lg_ch2_init[] = {
  1603. /* set line-in and mic-in to input */
  1604. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1605. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1606. { }
  1607. };
  1608. static struct hda_verb alc880_lg_ch4_init[] = {
  1609. /* set line-in to out and mic-in to input */
  1610. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1611. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1612. { }
  1613. };
  1614. static struct hda_verb alc880_lg_ch6_init[] = {
  1615. /* set line-in and mic-in to output */
  1616. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1617. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1618. { }
  1619. };
  1620. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1621. { 2, alc880_lg_ch2_init },
  1622. { 4, alc880_lg_ch4_init },
  1623. { 6, alc880_lg_ch6_init },
  1624. };
  1625. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1626. /* FIXME: it's not really "master" but front channels */
  1627. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1628. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1629. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1630. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1631. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1632. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1633. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1634. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1635. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1636. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1637. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1638. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1639. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1640. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1641. {
  1642. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1643. .name = "Channel Mode",
  1644. .info = alc_ch_mode_info,
  1645. .get = alc_ch_mode_get,
  1646. .put = alc_ch_mode_put,
  1647. },
  1648. { } /* end */
  1649. };
  1650. static struct hda_verb alc880_lg_init_verbs[] = {
  1651. /* set capture source to mic-in */
  1652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1655. /* mute all amp mixer inputs */
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1659. /* line-in to input */
  1660. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1661. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. /* built-in mic */
  1663. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1664. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1665. /* speaker-out */
  1666. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1667. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1668. /* mic-in to input */
  1669. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1670. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1671. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1672. /* HP-out */
  1673. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1674. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1675. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1676. /* jack sense */
  1677. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1678. { }
  1679. };
  1680. /* toggle speaker-output according to the hp-jack state */
  1681. static void alc880_lg_automute(struct hda_codec *codec)
  1682. {
  1683. unsigned int present;
  1684. unsigned char bits;
  1685. present = snd_hda_codec_read(codec, 0x1b, 0,
  1686. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1687. bits = present ? HDA_AMP_MUTE : 0;
  1688. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1689. HDA_AMP_MUTE, bits);
  1690. }
  1691. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1692. {
  1693. /* Looks like the unsol event is incompatible with the standard
  1694. * definition. 4bit tag is placed at 28 bit!
  1695. */
  1696. if ((res >> 28) == 0x01)
  1697. alc880_lg_automute(codec);
  1698. }
  1699. /*
  1700. * LG LW20
  1701. *
  1702. * Pin assignment:
  1703. * Speaker-out: 0x14
  1704. * Mic-In: 0x18
  1705. * Built-in Mic-In: 0x19
  1706. * Line-In: 0x1b
  1707. * HP-Out: 0x1a
  1708. * SPDIF-Out: 0x1e
  1709. */
  1710. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1711. .num_items = 3,
  1712. .items = {
  1713. { "Mic", 0x0 },
  1714. { "Internal Mic", 0x1 },
  1715. { "Line In", 0x2 },
  1716. },
  1717. };
  1718. #define alc880_lg_lw_modes alc880_threestack_modes
  1719. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1720. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1721. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1722. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1723. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1724. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1725. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1726. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1727. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1728. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1732. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1733. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1734. {
  1735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1736. .name = "Channel Mode",
  1737. .info = alc_ch_mode_info,
  1738. .get = alc_ch_mode_get,
  1739. .put = alc_ch_mode_put,
  1740. },
  1741. { } /* end */
  1742. };
  1743. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1744. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1745. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1746. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1747. /* set capture source to mic-in */
  1748. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1752. /* speaker-out */
  1753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1754. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1755. /* HP-out */
  1756. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1757. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1758. /* mic-in to input */
  1759. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1760. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1761. /* built-in mic */
  1762. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1763. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1764. /* jack sense */
  1765. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1766. { }
  1767. };
  1768. /* toggle speaker-output according to the hp-jack state */
  1769. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1770. {
  1771. unsigned int present;
  1772. unsigned char bits;
  1773. present = snd_hda_codec_read(codec, 0x1b, 0,
  1774. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1775. bits = present ? HDA_AMP_MUTE : 0;
  1776. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1777. HDA_AMP_MUTE, bits);
  1778. }
  1779. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1780. {
  1781. /* Looks like the unsol event is incompatible with the standard
  1782. * definition. 4bit tag is placed at 28 bit!
  1783. */
  1784. if ((res >> 28) == 0x01)
  1785. alc880_lg_lw_automute(codec);
  1786. }
  1787. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1788. static struct hda_amp_list alc880_loopbacks[] = {
  1789. { 0x0b, HDA_INPUT, 0 },
  1790. { 0x0b, HDA_INPUT, 1 },
  1791. { 0x0b, HDA_INPUT, 2 },
  1792. { 0x0b, HDA_INPUT, 3 },
  1793. { 0x0b, HDA_INPUT, 4 },
  1794. { } /* end */
  1795. };
  1796. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1797. { 0x0b, HDA_INPUT, 1 },
  1798. { 0x0b, HDA_INPUT, 6 },
  1799. { 0x0b, HDA_INPUT, 7 },
  1800. { } /* end */
  1801. };
  1802. #endif
  1803. /*
  1804. * Common callbacks
  1805. */
  1806. static int alc_init(struct hda_codec *codec)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. unsigned int i;
  1810. for (i = 0; i < spec->num_init_verbs; i++)
  1811. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1812. if (spec->init_hook)
  1813. spec->init_hook(codec);
  1814. return 0;
  1815. }
  1816. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. if (spec->unsol_event)
  1820. spec->unsol_event(codec, res);
  1821. }
  1822. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1823. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1824. {
  1825. struct alc_spec *spec = codec->spec;
  1826. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1827. }
  1828. #endif
  1829. /*
  1830. * Analog playback callbacks
  1831. */
  1832. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1833. struct hda_codec *codec,
  1834. struct snd_pcm_substream *substream)
  1835. {
  1836. struct alc_spec *spec = codec->spec;
  1837. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1838. }
  1839. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1840. struct hda_codec *codec,
  1841. unsigned int stream_tag,
  1842. unsigned int format,
  1843. struct snd_pcm_substream *substream)
  1844. {
  1845. struct alc_spec *spec = codec->spec;
  1846. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1847. stream_tag, format, substream);
  1848. }
  1849. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1850. struct hda_codec *codec,
  1851. struct snd_pcm_substream *substream)
  1852. {
  1853. struct alc_spec *spec = codec->spec;
  1854. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1855. }
  1856. /*
  1857. * Digital out
  1858. */
  1859. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1860. struct hda_codec *codec,
  1861. struct snd_pcm_substream *substream)
  1862. {
  1863. struct alc_spec *spec = codec->spec;
  1864. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1865. }
  1866. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1867. struct hda_codec *codec,
  1868. unsigned int stream_tag,
  1869. unsigned int format,
  1870. struct snd_pcm_substream *substream)
  1871. {
  1872. struct alc_spec *spec = codec->spec;
  1873. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1874. stream_tag, format, substream);
  1875. }
  1876. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1877. struct hda_codec *codec,
  1878. struct snd_pcm_substream *substream)
  1879. {
  1880. struct alc_spec *spec = codec->spec;
  1881. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1882. }
  1883. /*
  1884. * Analog capture
  1885. */
  1886. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1887. struct hda_codec *codec,
  1888. unsigned int stream_tag,
  1889. unsigned int format,
  1890. struct snd_pcm_substream *substream)
  1891. {
  1892. struct alc_spec *spec = codec->spec;
  1893. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1894. stream_tag, 0, format);
  1895. return 0;
  1896. }
  1897. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1898. struct hda_codec *codec,
  1899. struct snd_pcm_substream *substream)
  1900. {
  1901. struct alc_spec *spec = codec->spec;
  1902. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1903. 0, 0, 0);
  1904. return 0;
  1905. }
  1906. /*
  1907. */
  1908. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1909. .substreams = 1,
  1910. .channels_min = 2,
  1911. .channels_max = 8,
  1912. /* NID is set in alc_build_pcms */
  1913. .ops = {
  1914. .open = alc880_playback_pcm_open,
  1915. .prepare = alc880_playback_pcm_prepare,
  1916. .cleanup = alc880_playback_pcm_cleanup
  1917. },
  1918. };
  1919. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1920. .substreams = 2,
  1921. .channels_min = 2,
  1922. .channels_max = 2,
  1923. /* NID is set in alc_build_pcms */
  1924. .ops = {
  1925. .prepare = alc880_capture_pcm_prepare,
  1926. .cleanup = alc880_capture_pcm_cleanup
  1927. },
  1928. };
  1929. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1930. .substreams = 1,
  1931. .channels_min = 2,
  1932. .channels_max = 2,
  1933. /* NID is set in alc_build_pcms */
  1934. .ops = {
  1935. .open = alc880_dig_playback_pcm_open,
  1936. .close = alc880_dig_playback_pcm_close,
  1937. .prepare = alc880_dig_playback_pcm_prepare
  1938. },
  1939. };
  1940. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1941. .substreams = 1,
  1942. .channels_min = 2,
  1943. .channels_max = 2,
  1944. /* NID is set in alc_build_pcms */
  1945. };
  1946. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1947. static struct hda_pcm_stream alc_pcm_null_playback = {
  1948. .substreams = 0,
  1949. .channels_min = 0,
  1950. .channels_max = 0,
  1951. };
  1952. static int alc_build_pcms(struct hda_codec *codec)
  1953. {
  1954. struct alc_spec *spec = codec->spec;
  1955. struct hda_pcm *info = spec->pcm_rec;
  1956. int i;
  1957. codec->num_pcms = 1;
  1958. codec->pcm_info = info;
  1959. info->name = spec->stream_name_analog;
  1960. if (spec->stream_analog_playback) {
  1961. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1962. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1963. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1964. }
  1965. if (spec->stream_analog_capture) {
  1966. snd_assert(spec->adc_nids, return -EINVAL);
  1967. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1968. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1969. }
  1970. if (spec->channel_mode) {
  1971. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1972. for (i = 0; i < spec->num_channel_mode; i++) {
  1973. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1974. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1975. }
  1976. }
  1977. }
  1978. /* SPDIF for stream index #1 */
  1979. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1980. codec->num_pcms = 2;
  1981. info = spec->pcm_rec + 1;
  1982. info->name = spec->stream_name_digital;
  1983. if (spec->multiout.dig_out_nid &&
  1984. spec->stream_digital_playback) {
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1986. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1987. }
  1988. if (spec->dig_in_nid &&
  1989. spec->stream_digital_capture) {
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1991. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1992. }
  1993. }
  1994. /* If the use of more than one ADC is requested for the current
  1995. * model, configure a second analog capture-only PCM.
  1996. */
  1997. /* Additional Analaog capture for index #2 */
  1998. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1999. spec->adc_nids) {
  2000. codec->num_pcms = 3;
  2001. info = spec->pcm_rec + 2;
  2002. info->name = spec->stream_name_analog;
  2003. /* No playback stream for second PCM */
  2004. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2005. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2006. if (spec->stream_analog_capture) {
  2007. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2008. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2009. }
  2010. }
  2011. return 0;
  2012. }
  2013. static void alc_free(struct hda_codec *codec)
  2014. {
  2015. struct alc_spec *spec = codec->spec;
  2016. unsigned int i;
  2017. if (!spec)
  2018. return;
  2019. if (spec->kctl_alloc) {
  2020. for (i = 0; i < spec->num_kctl_used; i++)
  2021. kfree(spec->kctl_alloc[i].name);
  2022. kfree(spec->kctl_alloc);
  2023. }
  2024. kfree(spec);
  2025. }
  2026. /*
  2027. */
  2028. static struct hda_codec_ops alc_patch_ops = {
  2029. .build_controls = alc_build_controls,
  2030. .build_pcms = alc_build_pcms,
  2031. .init = alc_init,
  2032. .free = alc_free,
  2033. .unsol_event = alc_unsol_event,
  2034. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2035. .check_power_status = alc_check_power_status,
  2036. #endif
  2037. };
  2038. /*
  2039. * Test configuration for debugging
  2040. *
  2041. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2042. * enum controls.
  2043. */
  2044. #ifdef CONFIG_SND_DEBUG
  2045. static hda_nid_t alc880_test_dac_nids[4] = {
  2046. 0x02, 0x03, 0x04, 0x05
  2047. };
  2048. static struct hda_input_mux alc880_test_capture_source = {
  2049. .num_items = 7,
  2050. .items = {
  2051. { "In-1", 0x0 },
  2052. { "In-2", 0x1 },
  2053. { "In-3", 0x2 },
  2054. { "In-4", 0x3 },
  2055. { "CD", 0x4 },
  2056. { "Front", 0x5 },
  2057. { "Surround", 0x6 },
  2058. },
  2059. };
  2060. static struct hda_channel_mode alc880_test_modes[4] = {
  2061. { 2, NULL },
  2062. { 4, NULL },
  2063. { 6, NULL },
  2064. { 8, NULL },
  2065. };
  2066. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2067. struct snd_ctl_elem_info *uinfo)
  2068. {
  2069. static char *texts[] = {
  2070. "N/A", "Line Out", "HP Out",
  2071. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2072. };
  2073. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2074. uinfo->count = 1;
  2075. uinfo->value.enumerated.items = 8;
  2076. if (uinfo->value.enumerated.item >= 8)
  2077. uinfo->value.enumerated.item = 7;
  2078. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2079. return 0;
  2080. }
  2081. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2082. struct snd_ctl_elem_value *ucontrol)
  2083. {
  2084. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2085. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2086. unsigned int pin_ctl, item = 0;
  2087. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2088. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2089. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2090. if (pin_ctl & AC_PINCTL_HP_EN)
  2091. item = 2;
  2092. else
  2093. item = 1;
  2094. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2095. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2096. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2097. case AC_PINCTL_VREF_50: item = 4; break;
  2098. case AC_PINCTL_VREF_GRD: item = 5; break;
  2099. case AC_PINCTL_VREF_80: item = 6; break;
  2100. case AC_PINCTL_VREF_100: item = 7; break;
  2101. }
  2102. }
  2103. ucontrol->value.enumerated.item[0] = item;
  2104. return 0;
  2105. }
  2106. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2107. struct snd_ctl_elem_value *ucontrol)
  2108. {
  2109. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2110. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2111. static unsigned int ctls[] = {
  2112. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2117. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2118. };
  2119. unsigned int old_ctl, new_ctl;
  2120. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2121. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2122. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2123. if (old_ctl != new_ctl) {
  2124. int val;
  2125. snd_hda_codec_write_cache(codec, nid, 0,
  2126. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2127. new_ctl);
  2128. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2129. HDA_AMP_MUTE : 0;
  2130. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2131. HDA_AMP_MUTE, val);
  2132. return 1;
  2133. }
  2134. return 0;
  2135. }
  2136. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2137. struct snd_ctl_elem_info *uinfo)
  2138. {
  2139. static char *texts[] = {
  2140. "Front", "Surround", "CLFE", "Side"
  2141. };
  2142. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2143. uinfo->count = 1;
  2144. uinfo->value.enumerated.items = 4;
  2145. if (uinfo->value.enumerated.item >= 4)
  2146. uinfo->value.enumerated.item = 3;
  2147. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2148. return 0;
  2149. }
  2150. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2151. struct snd_ctl_elem_value *ucontrol)
  2152. {
  2153. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2154. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2155. unsigned int sel;
  2156. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2157. ucontrol->value.enumerated.item[0] = sel & 3;
  2158. return 0;
  2159. }
  2160. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2161. struct snd_ctl_elem_value *ucontrol)
  2162. {
  2163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2164. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2165. unsigned int sel;
  2166. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2167. if (ucontrol->value.enumerated.item[0] != sel) {
  2168. sel = ucontrol->value.enumerated.item[0] & 3;
  2169. snd_hda_codec_write_cache(codec, nid, 0,
  2170. AC_VERB_SET_CONNECT_SEL, sel);
  2171. return 1;
  2172. }
  2173. return 0;
  2174. }
  2175. #define PIN_CTL_TEST(xname,nid) { \
  2176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2177. .name = xname, \
  2178. .info = alc_test_pin_ctl_info, \
  2179. .get = alc_test_pin_ctl_get, \
  2180. .put = alc_test_pin_ctl_put, \
  2181. .private_value = nid \
  2182. }
  2183. #define PIN_SRC_TEST(xname,nid) { \
  2184. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2185. .name = xname, \
  2186. .info = alc_test_pin_src_info, \
  2187. .get = alc_test_pin_src_get, \
  2188. .put = alc_test_pin_src_put, \
  2189. .private_value = nid \
  2190. }
  2191. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2192. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2195. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2196. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2199. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2200. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2201. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2202. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2203. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2204. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2205. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2206. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2207. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2208. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2209. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2210. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2211. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2212. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2213. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2214. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2215. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2216. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2217. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2218. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2219. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2220. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2221. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2222. {
  2223. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2224. .name = "Channel Mode",
  2225. .info = alc_ch_mode_info,
  2226. .get = alc_ch_mode_get,
  2227. .put = alc_ch_mode_put,
  2228. },
  2229. { } /* end */
  2230. };
  2231. static struct hda_verb alc880_test_init_verbs[] = {
  2232. /* Unmute inputs of 0x0c - 0x0f */
  2233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2238. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2240. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2241. /* Vol output for 0x0c-0x0f */
  2242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2246. /* Set output pins 0x14-0x17 */
  2247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2251. /* Unmute output pins 0x14-0x17 */
  2252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2256. /* Set input pins 0x18-0x1c */
  2257. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2258. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2259. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2262. /* Mute input pins 0x18-0x1b */
  2263. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2267. /* ADC set up */
  2268. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2269. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2270. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2271. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2272. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2273. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2274. /* Analog input/passthru */
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2280. { }
  2281. };
  2282. #endif
  2283. /*
  2284. */
  2285. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2286. [ALC880_3ST] = "3stack",
  2287. [ALC880_TCL_S700] = "tcl",
  2288. [ALC880_3ST_DIG] = "3stack-digout",
  2289. [ALC880_CLEVO] = "clevo",
  2290. [ALC880_5ST] = "5stack",
  2291. [ALC880_5ST_DIG] = "5stack-digout",
  2292. [ALC880_W810] = "w810",
  2293. [ALC880_Z71V] = "z71v",
  2294. [ALC880_6ST] = "6stack",
  2295. [ALC880_6ST_DIG] = "6stack-digout",
  2296. [ALC880_ASUS] = "asus",
  2297. [ALC880_ASUS_W1V] = "asus-w1v",
  2298. [ALC880_ASUS_DIG] = "asus-dig",
  2299. [ALC880_ASUS_DIG2] = "asus-dig2",
  2300. [ALC880_UNIWILL_DIG] = "uniwill",
  2301. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2302. [ALC880_FUJITSU] = "fujitsu",
  2303. [ALC880_F1734] = "F1734",
  2304. [ALC880_LG] = "lg",
  2305. [ALC880_LG_LW] = "lg-lw",
  2306. #ifdef CONFIG_SND_DEBUG
  2307. [ALC880_TEST] = "test",
  2308. #endif
  2309. [ALC880_AUTO] = "auto",
  2310. };
  2311. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2312. /* Broken BIOS configuration */
  2313. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2316. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2317. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2318. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2323. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2324. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2325. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2326. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2327. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2332. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2333. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2334. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2337. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2339. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2340. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2341. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2342. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2343. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2346. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2347. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2348. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2349. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2350. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2351. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2352. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2353. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2358. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2359. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2360. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2361. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2362. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2363. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2364. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2365. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2366. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2367. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2368. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2369. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2370. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2371. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2382. {}
  2383. };
  2384. /*
  2385. * ALC880 codec presets
  2386. */
  2387. static struct alc_config_preset alc880_presets[] = {
  2388. [ALC880_3ST] = {
  2389. .mixers = { alc880_three_stack_mixer },
  2390. .init_verbs = { alc880_volume_init_verbs,
  2391. alc880_pin_3stack_init_verbs },
  2392. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2393. .dac_nids = alc880_dac_nids,
  2394. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2395. .channel_mode = alc880_threestack_modes,
  2396. .need_dac_fix = 1,
  2397. .input_mux = &alc880_capture_source,
  2398. },
  2399. [ALC880_3ST_DIG] = {
  2400. .mixers = { alc880_three_stack_mixer },
  2401. .init_verbs = { alc880_volume_init_verbs,
  2402. alc880_pin_3stack_init_verbs },
  2403. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2404. .dac_nids = alc880_dac_nids,
  2405. .dig_out_nid = ALC880_DIGOUT_NID,
  2406. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2407. .channel_mode = alc880_threestack_modes,
  2408. .need_dac_fix = 1,
  2409. .input_mux = &alc880_capture_source,
  2410. },
  2411. [ALC880_TCL_S700] = {
  2412. .mixers = { alc880_tcl_s700_mixer },
  2413. .init_verbs = { alc880_volume_init_verbs,
  2414. alc880_pin_tcl_S700_init_verbs,
  2415. alc880_gpio2_init_verbs },
  2416. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2417. .dac_nids = alc880_dac_nids,
  2418. .hp_nid = 0x03,
  2419. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2420. .channel_mode = alc880_2_jack_modes,
  2421. .input_mux = &alc880_capture_source,
  2422. },
  2423. [ALC880_5ST] = {
  2424. .mixers = { alc880_three_stack_mixer,
  2425. alc880_five_stack_mixer},
  2426. .init_verbs = { alc880_volume_init_verbs,
  2427. alc880_pin_5stack_init_verbs },
  2428. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2429. .dac_nids = alc880_dac_nids,
  2430. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2431. .channel_mode = alc880_fivestack_modes,
  2432. .input_mux = &alc880_capture_source,
  2433. },
  2434. [ALC880_5ST_DIG] = {
  2435. .mixers = { alc880_three_stack_mixer,
  2436. alc880_five_stack_mixer },
  2437. .init_verbs = { alc880_volume_init_verbs,
  2438. alc880_pin_5stack_init_verbs },
  2439. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2440. .dac_nids = alc880_dac_nids,
  2441. .dig_out_nid = ALC880_DIGOUT_NID,
  2442. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2443. .channel_mode = alc880_fivestack_modes,
  2444. .input_mux = &alc880_capture_source,
  2445. },
  2446. [ALC880_6ST] = {
  2447. .mixers = { alc880_six_stack_mixer },
  2448. .init_verbs = { alc880_volume_init_verbs,
  2449. alc880_pin_6stack_init_verbs },
  2450. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2451. .dac_nids = alc880_6st_dac_nids,
  2452. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2453. .channel_mode = alc880_sixstack_modes,
  2454. .input_mux = &alc880_6stack_capture_source,
  2455. },
  2456. [ALC880_6ST_DIG] = {
  2457. .mixers = { alc880_six_stack_mixer },
  2458. .init_verbs = { alc880_volume_init_verbs,
  2459. alc880_pin_6stack_init_verbs },
  2460. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2461. .dac_nids = alc880_6st_dac_nids,
  2462. .dig_out_nid = ALC880_DIGOUT_NID,
  2463. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2464. .channel_mode = alc880_sixstack_modes,
  2465. .input_mux = &alc880_6stack_capture_source,
  2466. },
  2467. [ALC880_W810] = {
  2468. .mixers = { alc880_w810_base_mixer },
  2469. .init_verbs = { alc880_volume_init_verbs,
  2470. alc880_pin_w810_init_verbs,
  2471. alc880_gpio2_init_verbs },
  2472. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2473. .dac_nids = alc880_w810_dac_nids,
  2474. .dig_out_nid = ALC880_DIGOUT_NID,
  2475. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2476. .channel_mode = alc880_w810_modes,
  2477. .input_mux = &alc880_capture_source,
  2478. },
  2479. [ALC880_Z71V] = {
  2480. .mixers = { alc880_z71v_mixer },
  2481. .init_verbs = { alc880_volume_init_verbs,
  2482. alc880_pin_z71v_init_verbs },
  2483. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2484. .dac_nids = alc880_z71v_dac_nids,
  2485. .dig_out_nid = ALC880_DIGOUT_NID,
  2486. .hp_nid = 0x03,
  2487. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2488. .channel_mode = alc880_2_jack_modes,
  2489. .input_mux = &alc880_capture_source,
  2490. },
  2491. [ALC880_F1734] = {
  2492. .mixers = { alc880_f1734_mixer },
  2493. .init_verbs = { alc880_volume_init_verbs,
  2494. alc880_pin_f1734_init_verbs },
  2495. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2496. .dac_nids = alc880_f1734_dac_nids,
  2497. .hp_nid = 0x02,
  2498. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2499. .channel_mode = alc880_2_jack_modes,
  2500. .input_mux = &alc880_capture_source,
  2501. },
  2502. [ALC880_ASUS] = {
  2503. .mixers = { alc880_asus_mixer },
  2504. .init_verbs = { alc880_volume_init_verbs,
  2505. alc880_pin_asus_init_verbs,
  2506. alc880_gpio1_init_verbs },
  2507. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2508. .dac_nids = alc880_asus_dac_nids,
  2509. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2510. .channel_mode = alc880_asus_modes,
  2511. .need_dac_fix = 1,
  2512. .input_mux = &alc880_capture_source,
  2513. },
  2514. [ALC880_ASUS_DIG] = {
  2515. .mixers = { alc880_asus_mixer },
  2516. .init_verbs = { alc880_volume_init_verbs,
  2517. alc880_pin_asus_init_verbs,
  2518. alc880_gpio1_init_verbs },
  2519. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2520. .dac_nids = alc880_asus_dac_nids,
  2521. .dig_out_nid = ALC880_DIGOUT_NID,
  2522. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2523. .channel_mode = alc880_asus_modes,
  2524. .need_dac_fix = 1,
  2525. .input_mux = &alc880_capture_source,
  2526. },
  2527. [ALC880_ASUS_DIG2] = {
  2528. .mixers = { alc880_asus_mixer },
  2529. .init_verbs = { alc880_volume_init_verbs,
  2530. alc880_pin_asus_init_verbs,
  2531. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2532. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2533. .dac_nids = alc880_asus_dac_nids,
  2534. .dig_out_nid = ALC880_DIGOUT_NID,
  2535. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2536. .channel_mode = alc880_asus_modes,
  2537. .need_dac_fix = 1,
  2538. .input_mux = &alc880_capture_source,
  2539. },
  2540. [ALC880_ASUS_W1V] = {
  2541. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2542. .init_verbs = { alc880_volume_init_verbs,
  2543. alc880_pin_asus_init_verbs,
  2544. alc880_gpio1_init_verbs },
  2545. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2546. .dac_nids = alc880_asus_dac_nids,
  2547. .dig_out_nid = ALC880_DIGOUT_NID,
  2548. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2549. .channel_mode = alc880_asus_modes,
  2550. .need_dac_fix = 1,
  2551. .input_mux = &alc880_capture_source,
  2552. },
  2553. [ALC880_UNIWILL_DIG] = {
  2554. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2555. .init_verbs = { alc880_volume_init_verbs,
  2556. alc880_pin_asus_init_verbs },
  2557. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2558. .dac_nids = alc880_asus_dac_nids,
  2559. .dig_out_nid = ALC880_DIGOUT_NID,
  2560. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2561. .channel_mode = alc880_asus_modes,
  2562. .need_dac_fix = 1,
  2563. .input_mux = &alc880_capture_source,
  2564. },
  2565. [ALC880_UNIWILL] = {
  2566. .mixers = { alc880_uniwill_mixer },
  2567. .init_verbs = { alc880_volume_init_verbs,
  2568. alc880_uniwill_init_verbs },
  2569. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2570. .dac_nids = alc880_asus_dac_nids,
  2571. .dig_out_nid = ALC880_DIGOUT_NID,
  2572. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2573. .channel_mode = alc880_threestack_modes,
  2574. .need_dac_fix = 1,
  2575. .input_mux = &alc880_capture_source,
  2576. .unsol_event = alc880_uniwill_unsol_event,
  2577. .init_hook = alc880_uniwill_automute,
  2578. },
  2579. [ALC880_UNIWILL_P53] = {
  2580. .mixers = { alc880_uniwill_p53_mixer },
  2581. .init_verbs = { alc880_volume_init_verbs,
  2582. alc880_uniwill_p53_init_verbs },
  2583. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2584. .dac_nids = alc880_asus_dac_nids,
  2585. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2586. .channel_mode = alc880_threestack_modes,
  2587. .input_mux = &alc880_capture_source,
  2588. .unsol_event = alc880_uniwill_p53_unsol_event,
  2589. .init_hook = alc880_uniwill_p53_hp_automute,
  2590. },
  2591. [ALC880_FUJITSU] = {
  2592. .mixers = { alc880_fujitsu_mixer,
  2593. alc880_pcbeep_mixer, },
  2594. .init_verbs = { alc880_volume_init_verbs,
  2595. alc880_uniwill_p53_init_verbs,
  2596. alc880_beep_init_verbs },
  2597. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2598. .dac_nids = alc880_dac_nids,
  2599. .dig_out_nid = ALC880_DIGOUT_NID,
  2600. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2601. .channel_mode = alc880_2_jack_modes,
  2602. .input_mux = &alc880_capture_source,
  2603. .unsol_event = alc880_uniwill_p53_unsol_event,
  2604. .init_hook = alc880_uniwill_p53_hp_automute,
  2605. },
  2606. [ALC880_CLEVO] = {
  2607. .mixers = { alc880_three_stack_mixer },
  2608. .init_verbs = { alc880_volume_init_verbs,
  2609. alc880_pin_clevo_init_verbs },
  2610. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2611. .dac_nids = alc880_dac_nids,
  2612. .hp_nid = 0x03,
  2613. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2614. .channel_mode = alc880_threestack_modes,
  2615. .need_dac_fix = 1,
  2616. .input_mux = &alc880_capture_source,
  2617. },
  2618. [ALC880_LG] = {
  2619. .mixers = { alc880_lg_mixer },
  2620. .init_verbs = { alc880_volume_init_verbs,
  2621. alc880_lg_init_verbs },
  2622. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2623. .dac_nids = alc880_lg_dac_nids,
  2624. .dig_out_nid = ALC880_DIGOUT_NID,
  2625. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2626. .channel_mode = alc880_lg_ch_modes,
  2627. .need_dac_fix = 1,
  2628. .input_mux = &alc880_lg_capture_source,
  2629. .unsol_event = alc880_lg_unsol_event,
  2630. .init_hook = alc880_lg_automute,
  2631. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2632. .loopbacks = alc880_lg_loopbacks,
  2633. #endif
  2634. },
  2635. [ALC880_LG_LW] = {
  2636. .mixers = { alc880_lg_lw_mixer },
  2637. .init_verbs = { alc880_volume_init_verbs,
  2638. alc880_lg_lw_init_verbs },
  2639. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2640. .dac_nids = alc880_dac_nids,
  2641. .dig_out_nid = ALC880_DIGOUT_NID,
  2642. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2643. .channel_mode = alc880_lg_lw_modes,
  2644. .input_mux = &alc880_lg_lw_capture_source,
  2645. .unsol_event = alc880_lg_lw_unsol_event,
  2646. .init_hook = alc880_lg_lw_automute,
  2647. },
  2648. #ifdef CONFIG_SND_DEBUG
  2649. [ALC880_TEST] = {
  2650. .mixers = { alc880_test_mixer },
  2651. .init_verbs = { alc880_test_init_verbs },
  2652. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2653. .dac_nids = alc880_test_dac_nids,
  2654. .dig_out_nid = ALC880_DIGOUT_NID,
  2655. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2656. .channel_mode = alc880_test_modes,
  2657. .input_mux = &alc880_test_capture_source,
  2658. },
  2659. #endif
  2660. };
  2661. /*
  2662. * Automatic parse of I/O pins from the BIOS configuration
  2663. */
  2664. #define NUM_CONTROL_ALLOC 32
  2665. #define NUM_VERB_ALLOC 32
  2666. enum {
  2667. ALC_CTL_WIDGET_VOL,
  2668. ALC_CTL_WIDGET_MUTE,
  2669. ALC_CTL_BIND_MUTE,
  2670. };
  2671. static struct snd_kcontrol_new alc880_control_templates[] = {
  2672. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2673. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2674. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2675. };
  2676. /* add dynamic controls */
  2677. static int add_control(struct alc_spec *spec, int type, const char *name,
  2678. unsigned long val)
  2679. {
  2680. struct snd_kcontrol_new *knew;
  2681. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2682. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2683. /* array + terminator */
  2684. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2685. if (!knew)
  2686. return -ENOMEM;
  2687. if (spec->kctl_alloc) {
  2688. memcpy(knew, spec->kctl_alloc,
  2689. sizeof(*knew) * spec->num_kctl_alloc);
  2690. kfree(spec->kctl_alloc);
  2691. }
  2692. spec->kctl_alloc = knew;
  2693. spec->num_kctl_alloc = num;
  2694. }
  2695. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2696. *knew = alc880_control_templates[type];
  2697. knew->name = kstrdup(name, GFP_KERNEL);
  2698. if (!knew->name)
  2699. return -ENOMEM;
  2700. knew->private_value = val;
  2701. spec->num_kctl_used++;
  2702. return 0;
  2703. }
  2704. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2705. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2706. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2707. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2708. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2709. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2710. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2711. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2712. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2713. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2714. #define ALC880_PIN_CD_NID 0x1c
  2715. /* fill in the dac_nids table from the parsed pin configuration */
  2716. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2717. const struct auto_pin_cfg *cfg)
  2718. {
  2719. hda_nid_t nid;
  2720. int assigned[4];
  2721. int i, j;
  2722. memset(assigned, 0, sizeof(assigned));
  2723. spec->multiout.dac_nids = spec->private_dac_nids;
  2724. /* check the pins hardwired to audio widget */
  2725. for (i = 0; i < cfg->line_outs; i++) {
  2726. nid = cfg->line_out_pins[i];
  2727. if (alc880_is_fixed_pin(nid)) {
  2728. int idx = alc880_fixed_pin_idx(nid);
  2729. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2730. assigned[idx] = 1;
  2731. }
  2732. }
  2733. /* left pins can be connect to any audio widget */
  2734. for (i = 0; i < cfg->line_outs; i++) {
  2735. nid = cfg->line_out_pins[i];
  2736. if (alc880_is_fixed_pin(nid))
  2737. continue;
  2738. /* search for an empty channel */
  2739. for (j = 0; j < cfg->line_outs; j++) {
  2740. if (!assigned[j]) {
  2741. spec->multiout.dac_nids[i] =
  2742. alc880_idx_to_dac(j);
  2743. assigned[j] = 1;
  2744. break;
  2745. }
  2746. }
  2747. }
  2748. spec->multiout.num_dacs = cfg->line_outs;
  2749. return 0;
  2750. }
  2751. /* add playback controls from the parsed DAC table */
  2752. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2753. const struct auto_pin_cfg *cfg)
  2754. {
  2755. char name[32];
  2756. static const char *chname[4] = {
  2757. "Front", "Surround", NULL /*CLFE*/, "Side"
  2758. };
  2759. hda_nid_t nid;
  2760. int i, err;
  2761. for (i = 0; i < cfg->line_outs; i++) {
  2762. if (!spec->multiout.dac_nids[i])
  2763. continue;
  2764. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2765. if (i == 2) {
  2766. /* Center/LFE */
  2767. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2768. "Center Playback Volume",
  2769. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2770. HDA_OUTPUT));
  2771. if (err < 0)
  2772. return err;
  2773. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2774. "LFE Playback Volume",
  2775. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2776. HDA_OUTPUT));
  2777. if (err < 0)
  2778. return err;
  2779. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2780. "Center Playback Switch",
  2781. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2782. HDA_INPUT));
  2783. if (err < 0)
  2784. return err;
  2785. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2786. "LFE Playback Switch",
  2787. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2788. HDA_INPUT));
  2789. if (err < 0)
  2790. return err;
  2791. } else {
  2792. sprintf(name, "%s Playback Volume", chname[i]);
  2793. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2794. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2795. HDA_OUTPUT));
  2796. if (err < 0)
  2797. return err;
  2798. sprintf(name, "%s Playback Switch", chname[i]);
  2799. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2800. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2801. HDA_INPUT));
  2802. if (err < 0)
  2803. return err;
  2804. }
  2805. }
  2806. return 0;
  2807. }
  2808. /* add playback controls for speaker and HP outputs */
  2809. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2810. const char *pfx)
  2811. {
  2812. hda_nid_t nid;
  2813. int err;
  2814. char name[32];
  2815. if (!pin)
  2816. return 0;
  2817. if (alc880_is_fixed_pin(pin)) {
  2818. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2819. /* specify the DAC as the extra output */
  2820. if (!spec->multiout.hp_nid)
  2821. spec->multiout.hp_nid = nid;
  2822. else
  2823. spec->multiout.extra_out_nid[0] = nid;
  2824. /* control HP volume/switch on the output mixer amp */
  2825. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2826. sprintf(name, "%s Playback Volume", pfx);
  2827. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2828. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2829. if (err < 0)
  2830. return err;
  2831. sprintf(name, "%s Playback Switch", pfx);
  2832. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2833. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2834. if (err < 0)
  2835. return err;
  2836. } else if (alc880_is_multi_pin(pin)) {
  2837. /* set manual connection */
  2838. /* we have only a switch on HP-out PIN */
  2839. sprintf(name, "%s Playback Switch", pfx);
  2840. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2841. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2842. if (err < 0)
  2843. return err;
  2844. }
  2845. return 0;
  2846. }
  2847. /* create input playback/capture controls for the given pin */
  2848. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2849. const char *ctlname,
  2850. int idx, hda_nid_t mix_nid)
  2851. {
  2852. char name[32];
  2853. int err;
  2854. sprintf(name, "%s Playback Volume", ctlname);
  2855. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2856. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2857. if (err < 0)
  2858. return err;
  2859. sprintf(name, "%s Playback Switch", ctlname);
  2860. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2861. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2862. if (err < 0)
  2863. return err;
  2864. return 0;
  2865. }
  2866. /* create playback/capture controls for input pins */
  2867. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2868. const struct auto_pin_cfg *cfg)
  2869. {
  2870. struct hda_input_mux *imux = &spec->private_imux;
  2871. int i, err, idx;
  2872. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2873. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2874. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2875. err = new_analog_input(spec, cfg->input_pins[i],
  2876. auto_pin_cfg_labels[i],
  2877. idx, 0x0b);
  2878. if (err < 0)
  2879. return err;
  2880. imux->items[imux->num_items].label =
  2881. auto_pin_cfg_labels[i];
  2882. imux->items[imux->num_items].index =
  2883. alc880_input_pin_idx(cfg->input_pins[i]);
  2884. imux->num_items++;
  2885. }
  2886. }
  2887. return 0;
  2888. }
  2889. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2890. hda_nid_t nid, int pin_type,
  2891. int dac_idx)
  2892. {
  2893. /* set as output */
  2894. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2895. pin_type);
  2896. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2897. AMP_OUT_UNMUTE);
  2898. /* need the manual connection? */
  2899. if (alc880_is_multi_pin(nid)) {
  2900. struct alc_spec *spec = codec->spec;
  2901. int idx = alc880_multi_pin_idx(nid);
  2902. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2903. AC_VERB_SET_CONNECT_SEL,
  2904. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2905. }
  2906. }
  2907. static int get_pin_type(int line_out_type)
  2908. {
  2909. if (line_out_type == AUTO_PIN_HP_OUT)
  2910. return PIN_HP;
  2911. else
  2912. return PIN_OUT;
  2913. }
  2914. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2915. {
  2916. struct alc_spec *spec = codec->spec;
  2917. int i;
  2918. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2919. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2920. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2921. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2922. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2923. }
  2924. }
  2925. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2926. {
  2927. struct alc_spec *spec = codec->spec;
  2928. hda_nid_t pin;
  2929. pin = spec->autocfg.speaker_pins[0];
  2930. if (pin) /* connect to front */
  2931. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2932. pin = spec->autocfg.hp_pins[0];
  2933. if (pin) /* connect to front */
  2934. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2935. }
  2936. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2937. {
  2938. struct alc_spec *spec = codec->spec;
  2939. int i;
  2940. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2941. hda_nid_t nid = spec->autocfg.input_pins[i];
  2942. if (alc880_is_input_pin(nid)) {
  2943. snd_hda_codec_write(codec, nid, 0,
  2944. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2945. i <= AUTO_PIN_FRONT_MIC ?
  2946. PIN_VREF80 : PIN_IN);
  2947. if (nid != ALC880_PIN_CD_NID)
  2948. snd_hda_codec_write(codec, nid, 0,
  2949. AC_VERB_SET_AMP_GAIN_MUTE,
  2950. AMP_OUT_MUTE);
  2951. }
  2952. }
  2953. }
  2954. /* parse the BIOS configuration and set up the alc_spec */
  2955. /* return 1 if successful, 0 if the proper config is not found,
  2956. * or a negative error code
  2957. */
  2958. static int alc880_parse_auto_config(struct hda_codec *codec)
  2959. {
  2960. struct alc_spec *spec = codec->spec;
  2961. int err;
  2962. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2963. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2964. alc880_ignore);
  2965. if (err < 0)
  2966. return err;
  2967. if (!spec->autocfg.line_outs)
  2968. return 0; /* can't find valid BIOS pin config */
  2969. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2970. if (err < 0)
  2971. return err;
  2972. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2973. if (err < 0)
  2974. return err;
  2975. err = alc880_auto_create_extra_out(spec,
  2976. spec->autocfg.speaker_pins[0],
  2977. "Speaker");
  2978. if (err < 0)
  2979. return err;
  2980. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2981. "Headphone");
  2982. if (err < 0)
  2983. return err;
  2984. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2985. if (err < 0)
  2986. return err;
  2987. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2988. if (spec->autocfg.dig_out_pin)
  2989. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2990. if (spec->autocfg.dig_in_pin)
  2991. spec->dig_in_nid = ALC880_DIGIN_NID;
  2992. if (spec->kctl_alloc)
  2993. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2994. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2995. spec->num_mux_defs = 1;
  2996. spec->input_mux = &spec->private_imux;
  2997. return 1;
  2998. }
  2999. /* additional initialization for auto-configuration model */
  3000. static void alc880_auto_init(struct hda_codec *codec)
  3001. {
  3002. alc880_auto_init_multi_out(codec);
  3003. alc880_auto_init_extra_out(codec);
  3004. alc880_auto_init_analog_input(codec);
  3005. }
  3006. /*
  3007. * OK, here we have finally the patch for ALC880
  3008. */
  3009. static int patch_alc880(struct hda_codec *codec)
  3010. {
  3011. struct alc_spec *spec;
  3012. int board_config;
  3013. int err;
  3014. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3015. if (spec == NULL)
  3016. return -ENOMEM;
  3017. codec->spec = spec;
  3018. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3019. alc880_models,
  3020. alc880_cfg_tbl);
  3021. if (board_config < 0) {
  3022. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3023. "trying auto-probe from BIOS...\n");
  3024. board_config = ALC880_AUTO;
  3025. }
  3026. if (board_config == ALC880_AUTO) {
  3027. /* automatic parse from the BIOS config */
  3028. err = alc880_parse_auto_config(codec);
  3029. if (err < 0) {
  3030. alc_free(codec);
  3031. return err;
  3032. } else if (!err) {
  3033. printk(KERN_INFO
  3034. "hda_codec: Cannot set up configuration "
  3035. "from BIOS. Using 3-stack mode...\n");
  3036. board_config = ALC880_3ST;
  3037. }
  3038. }
  3039. if (board_config != ALC880_AUTO)
  3040. setup_preset(spec, &alc880_presets[board_config]);
  3041. spec->stream_name_analog = "ALC880 Analog";
  3042. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3043. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3044. spec->stream_name_digital = "ALC880 Digital";
  3045. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3046. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3047. if (!spec->adc_nids && spec->input_mux) {
  3048. /* check whether NID 0x07 is valid */
  3049. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3050. /* get type */
  3051. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3052. if (wcap != AC_WID_AUD_IN) {
  3053. spec->adc_nids = alc880_adc_nids_alt;
  3054. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3055. spec->mixers[spec->num_mixers] =
  3056. alc880_capture_alt_mixer;
  3057. spec->num_mixers++;
  3058. } else {
  3059. spec->adc_nids = alc880_adc_nids;
  3060. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3061. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3062. spec->num_mixers++;
  3063. }
  3064. }
  3065. codec->patch_ops = alc_patch_ops;
  3066. if (board_config == ALC880_AUTO)
  3067. spec->init_hook = alc880_auto_init;
  3068. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3069. if (!spec->loopback.amplist)
  3070. spec->loopback.amplist = alc880_loopbacks;
  3071. #endif
  3072. return 0;
  3073. }
  3074. /*
  3075. * ALC260 support
  3076. */
  3077. static hda_nid_t alc260_dac_nids[1] = {
  3078. /* front */
  3079. 0x02,
  3080. };
  3081. static hda_nid_t alc260_adc_nids[1] = {
  3082. /* ADC0 */
  3083. 0x04,
  3084. };
  3085. static hda_nid_t alc260_adc_nids_alt[1] = {
  3086. /* ADC1 */
  3087. 0x05,
  3088. };
  3089. static hda_nid_t alc260_hp_adc_nids[2] = {
  3090. /* ADC1, 0 */
  3091. 0x05, 0x04
  3092. };
  3093. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3094. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3095. */
  3096. static hda_nid_t alc260_dual_adc_nids[2] = {
  3097. /* ADC0, ADC1 */
  3098. 0x04, 0x05
  3099. };
  3100. #define ALC260_DIGOUT_NID 0x03
  3101. #define ALC260_DIGIN_NID 0x06
  3102. static struct hda_input_mux alc260_capture_source = {
  3103. .num_items = 4,
  3104. .items = {
  3105. { "Mic", 0x0 },
  3106. { "Front Mic", 0x1 },
  3107. { "Line", 0x2 },
  3108. { "CD", 0x4 },
  3109. },
  3110. };
  3111. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3112. * headphone jack and the internal CD lines since these are the only pins at
  3113. * which audio can appear. For flexibility, also allow the option of
  3114. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3115. * connection to the mixer output).
  3116. */
  3117. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3118. {
  3119. .num_items = 3,
  3120. .items = {
  3121. { "Mic/Line", 0x0 },
  3122. { "CD", 0x4 },
  3123. { "Headphone", 0x2 },
  3124. },
  3125. },
  3126. {
  3127. .num_items = 4,
  3128. .items = {
  3129. { "Mic/Line", 0x0 },
  3130. { "CD", 0x4 },
  3131. { "Headphone", 0x2 },
  3132. { "Mixer", 0x5 },
  3133. },
  3134. },
  3135. };
  3136. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3137. * the Fujitsu S702x, but jacks are marked differently.
  3138. */
  3139. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3140. {
  3141. .num_items = 4,
  3142. .items = {
  3143. { "Mic", 0x0 },
  3144. { "Line", 0x2 },
  3145. { "CD", 0x4 },
  3146. { "Headphone", 0x5 },
  3147. },
  3148. },
  3149. {
  3150. .num_items = 5,
  3151. .items = {
  3152. { "Mic", 0x0 },
  3153. { "Line", 0x2 },
  3154. { "CD", 0x4 },
  3155. { "Headphone", 0x6 },
  3156. { "Mixer", 0x5 },
  3157. },
  3158. },
  3159. };
  3160. /*
  3161. * This is just place-holder, so there's something for alc_build_pcms to look
  3162. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3163. * element which allows changing the channel mode, so the verb list is
  3164. * never used.
  3165. */
  3166. static struct hda_channel_mode alc260_modes[1] = {
  3167. { 2, NULL },
  3168. };
  3169. /* Mixer combinations
  3170. *
  3171. * basic: base_output + input + pc_beep + capture
  3172. * HP: base_output + input + capture_alt
  3173. * HP_3013: hp_3013 + input + capture
  3174. * fujitsu: fujitsu + capture
  3175. * acer: acer + capture
  3176. */
  3177. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3178. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3179. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3180. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3181. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3182. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3183. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3184. { } /* end */
  3185. };
  3186. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3187. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3191. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3193. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3195. { } /* end */
  3196. };
  3197. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3198. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3199. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3200. { } /* end */
  3201. };
  3202. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3203. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3207. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3210. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3211. { } /* end */
  3212. };
  3213. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3214. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3215. */
  3216. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3217. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3218. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3219. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3220. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3222. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3223. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3224. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3225. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3227. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3228. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3229. { } /* end */
  3230. };
  3231. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3232. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3233. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3234. * datasheet doesn't mention this restriction. At this stage it's not clear
  3235. * whether this behaviour is intentional or is a hardware bug in chip
  3236. * revisions available in early 2006. Therefore for now allow the
  3237. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3238. * that the lack of mic bias for this NID is intentional we could change the
  3239. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3240. *
  3241. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3242. * don't appear to make the mic bias available from the "line" jack, even
  3243. * though the NID used for this jack (0x14) can supply it. The theory is
  3244. * that perhaps Acer have included blocking capacitors between the ALC260
  3245. * and the output jack. If this turns out to be the case for all such
  3246. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3247. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3248. *
  3249. * The C20x Tablet series have a mono internal speaker which is controlled
  3250. * via the chip's Mono sum widget and pin complex, so include the necessary
  3251. * controls for such models. On models without a "mono speaker" the control
  3252. * won't do anything.
  3253. */
  3254. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3255. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3256. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3257. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3258. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3259. HDA_OUTPUT),
  3260. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3261. HDA_INPUT),
  3262. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3265. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3266. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3267. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3268. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3269. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3270. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3271. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3272. { } /* end */
  3273. };
  3274. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3275. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3276. */
  3277. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3278. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3279. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3282. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3283. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3284. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3285. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3286. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3288. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3289. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3290. { } /* end */
  3291. };
  3292. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3293. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3294. */
  3295. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3296. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3297. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3298. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3299. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3300. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3301. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3303. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3304. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3305. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3306. { } /* end */
  3307. };
  3308. /* capture mixer elements */
  3309. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3310. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3312. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3313. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3314. {
  3315. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3316. /* The multiple "Capture Source" controls confuse alsamixer
  3317. * So call somewhat different..
  3318. * FIXME: the controls appear in the "playback" view!
  3319. */
  3320. /* .name = "Capture Source", */
  3321. .name = "Input Source",
  3322. .count = 2,
  3323. .info = alc_mux_enum_info,
  3324. .get = alc_mux_enum_get,
  3325. .put = alc_mux_enum_put,
  3326. },
  3327. { } /* end */
  3328. };
  3329. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3330. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3331. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3332. {
  3333. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3334. /* The multiple "Capture Source" controls confuse alsamixer
  3335. * So call somewhat different..
  3336. * FIXME: the controls appear in the "playback" view!
  3337. */
  3338. /* .name = "Capture Source", */
  3339. .name = "Input Source",
  3340. .count = 1,
  3341. .info = alc_mux_enum_info,
  3342. .get = alc_mux_enum_get,
  3343. .put = alc_mux_enum_put,
  3344. },
  3345. { } /* end */
  3346. };
  3347. /*
  3348. * initialization verbs
  3349. */
  3350. static struct hda_verb alc260_init_verbs[] = {
  3351. /* Line In pin widget for input */
  3352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3353. /* CD pin widget for input */
  3354. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3355. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3356. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3357. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3358. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3359. /* LINE-2 is used for line-out in rear */
  3360. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3361. /* select line-out */
  3362. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3363. /* LINE-OUT pin */
  3364. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3365. /* enable HP */
  3366. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3367. /* enable Mono */
  3368. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3369. /* mute capture amp left and right */
  3370. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3371. /* set connection select to line in (default select for this ADC) */
  3372. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3373. /* mute capture amp left and right */
  3374. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3375. /* set connection select to line in (default select for this ADC) */
  3376. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3377. /* set vol=0 Line-Out mixer amp left and right */
  3378. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3379. /* unmute pin widget amp left and right (no gain on this amp) */
  3380. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3381. /* set vol=0 HP mixer amp left and right */
  3382. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3383. /* unmute pin widget amp left and right (no gain on this amp) */
  3384. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3385. /* set vol=0 Mono mixer amp left and right */
  3386. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3387. /* unmute pin widget amp left and right (no gain on this amp) */
  3388. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3389. /* unmute LINE-2 out pin */
  3390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3391. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3392. * Line In 2 = 0x03
  3393. */
  3394. /* mute analog inputs */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3399. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3400. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3401. /* mute Front out path */
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3403. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3404. /* mute Headphone out path */
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3406. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3407. /* mute Mono out path */
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3409. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3410. { }
  3411. };
  3412. #if 0 /* should be identical with alc260_init_verbs? */
  3413. static struct hda_verb alc260_hp_init_verbs[] = {
  3414. /* Headphone and output */
  3415. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3416. /* mono output */
  3417. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3418. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3419. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3421. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3422. /* Line In pin widget for input */
  3423. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3424. /* Line-2 pin widget for output */
  3425. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3426. /* CD pin widget for input */
  3427. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3428. /* unmute amp left and right */
  3429. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3430. /* set connection select to line in (default select for this ADC) */
  3431. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3432. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3433. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3434. /* mute pin widget amp left and right (no gain on this amp) */
  3435. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3436. /* unmute HP mixer amp left and right (volume = 0) */
  3437. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3438. /* mute pin widget amp left and right (no gain on this amp) */
  3439. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3440. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3441. * Line In 2 = 0x03
  3442. */
  3443. /* mute analog inputs */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3448. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3449. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3450. /* Unmute Front out path */
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3452. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3453. /* Unmute Headphone out path */
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3456. /* Unmute Mono out path */
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3458. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3459. { }
  3460. };
  3461. #endif
  3462. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3463. /* Line out and output */
  3464. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3465. /* mono output */
  3466. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3467. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3468. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3469. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3470. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3471. /* Line In pin widget for input */
  3472. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3473. /* Headphone pin widget for output */
  3474. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3475. /* CD pin widget for input */
  3476. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3477. /* unmute amp left and right */
  3478. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3479. /* set connection select to line in (default select for this ADC) */
  3480. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3481. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3482. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3483. /* mute pin widget amp left and right (no gain on this amp) */
  3484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3485. /* unmute HP mixer amp left and right (volume = 0) */
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3487. /* mute pin widget amp left and right (no gain on this amp) */
  3488. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3489. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3490. * Line In 2 = 0x03
  3491. */
  3492. /* mute analog inputs */
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3497. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3498. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3499. /* Unmute Front out path */
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3501. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3502. /* Unmute Headphone out path */
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3504. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3505. /* Unmute Mono out path */
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3507. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3508. { }
  3509. };
  3510. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3511. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3512. * audio = 0x16, internal speaker = 0x10.
  3513. */
  3514. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3515. /* Disable all GPIOs */
  3516. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3517. /* Internal speaker is connected to headphone pin */
  3518. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3519. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3521. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3522. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3523. /* Ensure all other unused pins are disabled and muted. */
  3524. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3527. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3529. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3530. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3531. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. /* Disable digital (SPDIF) pins */
  3533. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3535. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3536. * when acting as an output.
  3537. */
  3538. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3539. /* Start with output sum widgets muted and their output gains at min */
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3542. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3545. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3548. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3549. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3550. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3551. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3552. * If the pin mode is changed by the user the pin mode control will
  3553. * take care of enabling the pin's input/output buffers as needed.
  3554. * Therefore there's no need to enable the input buffer at this
  3555. * stage.
  3556. */
  3557. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3558. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3559. * mixer ctrl)
  3560. */
  3561. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3562. /* Mute capture amp left and right */
  3563. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3564. /* Set ADC connection select to match default mixer setting - line
  3565. * in (on mic1 pin)
  3566. */
  3567. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3568. /* Do the same for the second ADC: mute capture input amp and
  3569. * set ADC connection to line in (on mic1 pin)
  3570. */
  3571. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3572. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3573. /* Mute all inputs to mixer widget (even unconnected ones) */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3582. { }
  3583. };
  3584. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3585. * similar laptops (adapted from Fujitsu init verbs).
  3586. */
  3587. static struct hda_verb alc260_acer_init_verbs[] = {
  3588. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3589. * the headphone jack. Turn this on and rely on the standard mute
  3590. * methods whenever the user wants to turn these outputs off.
  3591. */
  3592. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3594. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3595. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3596. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3597. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3598. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3599. /* Line In jack is connected to Line1 pin */
  3600. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3601. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3603. /* Ensure all other unused pins are disabled and muted. */
  3604. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3605. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3606. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3607. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3610. /* Disable digital (SPDIF) pins */
  3611. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3613. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3614. * bus when acting as outputs.
  3615. */
  3616. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3617. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3618. /* Start with output sum widgets muted and their output gains at min */
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3621. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3624. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3627. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3628. /* Unmute Line-out pin widget amp left and right
  3629. * (no equiv mixer ctrl)
  3630. */
  3631. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3632. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3633. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3634. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3635. * inputs. If the pin mode is changed by the user the pin mode control
  3636. * will take care of enabling the pin's input/output buffers as needed.
  3637. * Therefore there's no need to enable the input buffer at this
  3638. * stage.
  3639. */
  3640. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3642. /* Mute capture amp left and right */
  3643. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3644. /* Set ADC connection select to match default mixer setting - mic
  3645. * (on mic1 pin)
  3646. */
  3647. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3648. /* Do similar with the second ADC: mute capture input amp and
  3649. * set ADC connection to mic to match ALSA's default state.
  3650. */
  3651. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3652. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3653. /* Mute all inputs to mixer widget (even unconnected ones) */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3661. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3662. { }
  3663. };
  3664. static struct hda_verb alc260_will_verbs[] = {
  3665. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3666. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3668. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3669. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3670. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3671. {}
  3672. };
  3673. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3674. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3675. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3676. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3677. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3679. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3680. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3681. {}
  3682. };
  3683. /* toggle speaker-output according to the hp-jack state */
  3684. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3685. {
  3686. unsigned int present;
  3687. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3688. present = snd_hda_codec_read(codec, 0x0f, 0,
  3689. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3690. if (present) {
  3691. snd_hda_codec_write_cache(codec, 0x01, 0,
  3692. AC_VERB_SET_GPIO_DATA, 1);
  3693. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3694. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3695. PIN_HP);
  3696. } else {
  3697. snd_hda_codec_write_cache(codec, 0x01, 0,
  3698. AC_VERB_SET_GPIO_DATA, 0);
  3699. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3700. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3701. PIN_OUT);
  3702. }
  3703. }
  3704. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3705. unsigned int res)
  3706. {
  3707. if ((res >> 26) == ALC880_HP_EVENT)
  3708. alc260_replacer_672v_automute(codec);
  3709. }
  3710. /* Test configuration for debugging, modelled after the ALC880 test
  3711. * configuration.
  3712. */
  3713. #ifdef CONFIG_SND_DEBUG
  3714. static hda_nid_t alc260_test_dac_nids[1] = {
  3715. 0x02,
  3716. };
  3717. static hda_nid_t alc260_test_adc_nids[2] = {
  3718. 0x04, 0x05,
  3719. };
  3720. /* For testing the ALC260, each input MUX needs its own definition since
  3721. * the signal assignments are different. This assumes that the first ADC
  3722. * is NID 0x04.
  3723. */
  3724. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3725. {
  3726. .num_items = 7,
  3727. .items = {
  3728. { "MIC1 pin", 0x0 },
  3729. { "MIC2 pin", 0x1 },
  3730. { "LINE1 pin", 0x2 },
  3731. { "LINE2 pin", 0x3 },
  3732. { "CD pin", 0x4 },
  3733. { "LINE-OUT pin", 0x5 },
  3734. { "HP-OUT pin", 0x6 },
  3735. },
  3736. },
  3737. {
  3738. .num_items = 8,
  3739. .items = {
  3740. { "MIC1 pin", 0x0 },
  3741. { "MIC2 pin", 0x1 },
  3742. { "LINE1 pin", 0x2 },
  3743. { "LINE2 pin", 0x3 },
  3744. { "CD pin", 0x4 },
  3745. { "Mixer", 0x5 },
  3746. { "LINE-OUT pin", 0x6 },
  3747. { "HP-OUT pin", 0x7 },
  3748. },
  3749. },
  3750. };
  3751. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3752. /* Output driver widgets */
  3753. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3754. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3755. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3756. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3757. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3758. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3759. /* Modes for retasking pin widgets
  3760. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3761. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3762. * mention this restriction. At this stage it's not clear whether
  3763. * this behaviour is intentional or is a hardware bug in chip
  3764. * revisions available at least up until early 2006. Therefore for
  3765. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3766. * choices, but if it turns out that the lack of mic bias for these
  3767. * NIDs is intentional we could change their modes from
  3768. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3769. */
  3770. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3775. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3776. /* Loopback mixer controls */
  3777. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3778. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3779. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3780. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3781. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3782. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3783. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3784. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3786. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3787. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3788. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3789. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3790. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3791. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3792. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3793. /* Controls for GPIO pins, assuming they are configured as outputs */
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3797. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3798. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3799. * is ambigious as to which NID is which; testing on laptops which
  3800. * make this output available should provide clarification.
  3801. */
  3802. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3803. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3804. { } /* end */
  3805. };
  3806. static struct hda_verb alc260_test_init_verbs[] = {
  3807. /* Enable all GPIOs as outputs with an initial value of 0 */
  3808. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3809. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3810. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3811. /* Enable retasking pins as output, initially without power amp */
  3812. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3818. /* Disable digital (SPDIF) pins initially, but users can enable
  3819. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3820. * payload also sets the generation to 0, output to be in "consumer"
  3821. * PCM format, copyright asserted, no pre-emphasis and no validity
  3822. * control.
  3823. */
  3824. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3825. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3826. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3827. * OUT1 sum bus when acting as an output.
  3828. */
  3829. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3830. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3832. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3833. /* Start with output sum widgets muted and their output gains at min */
  3834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3836. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3837. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3839. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3840. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3842. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3843. /* Unmute retasking pin widget output buffers since the default
  3844. * state appears to be output. As the pin mode is changed by the
  3845. * user the pin mode control will take care of enabling the pin's
  3846. * input/output buffers as needed.
  3847. */
  3848. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3854. /* Also unmute the mono-out pin widget */
  3855. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3856. /* Mute capture amp left and right */
  3857. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3858. /* Set ADC connection select to match default mixer setting (mic1
  3859. * pin)
  3860. */
  3861. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* Do the same for the second ADC: mute capture input amp and
  3863. * set ADC connection to mic1 pin
  3864. */
  3865. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3866. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3867. /* Mute all inputs to mixer widget (even unconnected ones) */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3875. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3876. { }
  3877. };
  3878. #endif
  3879. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3880. .substreams = 1,
  3881. .channels_min = 2,
  3882. .channels_max = 2,
  3883. };
  3884. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3885. .substreams = 1,
  3886. .channels_min = 2,
  3887. .channels_max = 2,
  3888. };
  3889. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3890. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3891. /*
  3892. * for BIOS auto-configuration
  3893. */
  3894. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3895. const char *pfx)
  3896. {
  3897. hda_nid_t nid_vol;
  3898. unsigned long vol_val, sw_val;
  3899. char name[32];
  3900. int err;
  3901. if (nid >= 0x0f && nid < 0x11) {
  3902. nid_vol = nid - 0x7;
  3903. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3904. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3905. } else if (nid == 0x11) {
  3906. nid_vol = nid - 0x7;
  3907. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3908. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3909. } else if (nid >= 0x12 && nid <= 0x15) {
  3910. nid_vol = 0x08;
  3911. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3912. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3913. } else
  3914. return 0; /* N/A */
  3915. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3916. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3917. if (err < 0)
  3918. return err;
  3919. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3920. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3921. if (err < 0)
  3922. return err;
  3923. return 1;
  3924. }
  3925. /* add playback controls from the parsed DAC table */
  3926. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3927. const struct auto_pin_cfg *cfg)
  3928. {
  3929. hda_nid_t nid;
  3930. int err;
  3931. spec->multiout.num_dacs = 1;
  3932. spec->multiout.dac_nids = spec->private_dac_nids;
  3933. spec->multiout.dac_nids[0] = 0x02;
  3934. nid = cfg->line_out_pins[0];
  3935. if (nid) {
  3936. err = alc260_add_playback_controls(spec, nid, "Front");
  3937. if (err < 0)
  3938. return err;
  3939. }
  3940. nid = cfg->speaker_pins[0];
  3941. if (nid) {
  3942. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3943. if (err < 0)
  3944. return err;
  3945. }
  3946. nid = cfg->hp_pins[0];
  3947. if (nid) {
  3948. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3949. if (err < 0)
  3950. return err;
  3951. }
  3952. return 0;
  3953. }
  3954. /* create playback/capture controls for input pins */
  3955. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3956. const struct auto_pin_cfg *cfg)
  3957. {
  3958. struct hda_input_mux *imux = &spec->private_imux;
  3959. int i, err, idx;
  3960. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3961. if (cfg->input_pins[i] >= 0x12) {
  3962. idx = cfg->input_pins[i] - 0x12;
  3963. err = new_analog_input(spec, cfg->input_pins[i],
  3964. auto_pin_cfg_labels[i], idx,
  3965. 0x07);
  3966. if (err < 0)
  3967. return err;
  3968. imux->items[imux->num_items].label =
  3969. auto_pin_cfg_labels[i];
  3970. imux->items[imux->num_items].index = idx;
  3971. imux->num_items++;
  3972. }
  3973. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3974. idx = cfg->input_pins[i] - 0x09;
  3975. err = new_analog_input(spec, cfg->input_pins[i],
  3976. auto_pin_cfg_labels[i], idx,
  3977. 0x07);
  3978. if (err < 0)
  3979. return err;
  3980. imux->items[imux->num_items].label =
  3981. auto_pin_cfg_labels[i];
  3982. imux->items[imux->num_items].index = idx;
  3983. imux->num_items++;
  3984. }
  3985. }
  3986. return 0;
  3987. }
  3988. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3989. hda_nid_t nid, int pin_type,
  3990. int sel_idx)
  3991. {
  3992. /* set as output */
  3993. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3994. pin_type);
  3995. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3996. AMP_OUT_UNMUTE);
  3997. /* need the manual connection? */
  3998. if (nid >= 0x12) {
  3999. int idx = nid - 0x12;
  4000. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4001. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4002. }
  4003. }
  4004. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4005. {
  4006. struct alc_spec *spec = codec->spec;
  4007. hda_nid_t nid;
  4008. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4009. nid = spec->autocfg.line_out_pins[0];
  4010. if (nid) {
  4011. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4012. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4013. }
  4014. nid = spec->autocfg.speaker_pins[0];
  4015. if (nid)
  4016. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4017. nid = spec->autocfg.hp_pins[0];
  4018. if (nid)
  4019. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4020. }
  4021. #define ALC260_PIN_CD_NID 0x16
  4022. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4023. {
  4024. struct alc_spec *spec = codec->spec;
  4025. int i;
  4026. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4027. hda_nid_t nid = spec->autocfg.input_pins[i];
  4028. if (nid >= 0x12) {
  4029. snd_hda_codec_write(codec, nid, 0,
  4030. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4031. i <= AUTO_PIN_FRONT_MIC ?
  4032. PIN_VREF80 : PIN_IN);
  4033. if (nid != ALC260_PIN_CD_NID)
  4034. snd_hda_codec_write(codec, nid, 0,
  4035. AC_VERB_SET_AMP_GAIN_MUTE,
  4036. AMP_OUT_MUTE);
  4037. }
  4038. }
  4039. }
  4040. /*
  4041. * generic initialization of ADC, input mixers and output mixers
  4042. */
  4043. static struct hda_verb alc260_volume_init_verbs[] = {
  4044. /*
  4045. * Unmute ADC0-1 and set the default input to mic-in
  4046. */
  4047. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4048. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4049. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4050. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4051. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4052. * mixer widget
  4053. * Note: PASD motherboards uses the Line In 2 as the input for
  4054. * front panel mic (mic 2)
  4055. */
  4056. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4057. /* mute analog inputs */
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4063. /*
  4064. * Set up output mixers (0x08 - 0x0a)
  4065. */
  4066. /* set vol=0 to output mixers */
  4067. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4070. /* set up input amps for analog loopback */
  4071. /* Amp Indices: DAC = 0, mixer = 1 */
  4072. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4074. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4075. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4076. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4077. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4078. { }
  4079. };
  4080. static int alc260_parse_auto_config(struct hda_codec *codec)
  4081. {
  4082. struct alc_spec *spec = codec->spec;
  4083. unsigned int wcap;
  4084. int err;
  4085. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4086. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4087. alc260_ignore);
  4088. if (err < 0)
  4089. return err;
  4090. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4091. if (err < 0)
  4092. return err;
  4093. if (!spec->kctl_alloc)
  4094. return 0; /* can't find valid BIOS pin config */
  4095. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4096. if (err < 0)
  4097. return err;
  4098. spec->multiout.max_channels = 2;
  4099. if (spec->autocfg.dig_out_pin)
  4100. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4101. if (spec->kctl_alloc)
  4102. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4103. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4104. spec->num_mux_defs = 1;
  4105. spec->input_mux = &spec->private_imux;
  4106. /* check whether NID 0x04 is valid */
  4107. wcap = get_wcaps(codec, 0x04);
  4108. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4109. if (wcap != AC_WID_AUD_IN) {
  4110. spec->adc_nids = alc260_adc_nids_alt;
  4111. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4112. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4113. } else {
  4114. spec->adc_nids = alc260_adc_nids;
  4115. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4116. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4117. }
  4118. spec->num_mixers++;
  4119. return 1;
  4120. }
  4121. /* additional initialization for auto-configuration model */
  4122. static void alc260_auto_init(struct hda_codec *codec)
  4123. {
  4124. alc260_auto_init_multi_out(codec);
  4125. alc260_auto_init_analog_input(codec);
  4126. }
  4127. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4128. static struct hda_amp_list alc260_loopbacks[] = {
  4129. { 0x07, HDA_INPUT, 0 },
  4130. { 0x07, HDA_INPUT, 1 },
  4131. { 0x07, HDA_INPUT, 2 },
  4132. { 0x07, HDA_INPUT, 3 },
  4133. { 0x07, HDA_INPUT, 4 },
  4134. { } /* end */
  4135. };
  4136. #endif
  4137. /*
  4138. * ALC260 configurations
  4139. */
  4140. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4141. [ALC260_BASIC] = "basic",
  4142. [ALC260_HP] = "hp",
  4143. [ALC260_HP_3013] = "hp-3013",
  4144. [ALC260_FUJITSU_S702X] = "fujitsu",
  4145. [ALC260_ACER] = "acer",
  4146. [ALC260_WILL] = "will",
  4147. [ALC260_REPLACER_672V] = "replacer",
  4148. #ifdef CONFIG_SND_DEBUG
  4149. [ALC260_TEST] = "test",
  4150. #endif
  4151. [ALC260_AUTO] = "auto",
  4152. };
  4153. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4154. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4155. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4156. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4159. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4160. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4161. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4162. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4163. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4165. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4168. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4169. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4170. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4171. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4172. {}
  4173. };
  4174. static struct alc_config_preset alc260_presets[] = {
  4175. [ALC260_BASIC] = {
  4176. .mixers = { alc260_base_output_mixer,
  4177. alc260_input_mixer,
  4178. alc260_pc_beep_mixer,
  4179. alc260_capture_mixer },
  4180. .init_verbs = { alc260_init_verbs },
  4181. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4182. .dac_nids = alc260_dac_nids,
  4183. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4184. .adc_nids = alc260_adc_nids,
  4185. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4186. .channel_mode = alc260_modes,
  4187. .input_mux = &alc260_capture_source,
  4188. },
  4189. [ALC260_HP] = {
  4190. .mixers = { alc260_base_output_mixer,
  4191. alc260_input_mixer,
  4192. alc260_capture_alt_mixer },
  4193. .init_verbs = { alc260_init_verbs },
  4194. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4195. .dac_nids = alc260_dac_nids,
  4196. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4197. .adc_nids = alc260_hp_adc_nids,
  4198. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4199. .channel_mode = alc260_modes,
  4200. .input_mux = &alc260_capture_source,
  4201. },
  4202. [ALC260_HP_3013] = {
  4203. .mixers = { alc260_hp_3013_mixer,
  4204. alc260_input_mixer,
  4205. alc260_capture_alt_mixer },
  4206. .init_verbs = { alc260_hp_3013_init_verbs },
  4207. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4208. .dac_nids = alc260_dac_nids,
  4209. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4210. .adc_nids = alc260_hp_adc_nids,
  4211. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4212. .channel_mode = alc260_modes,
  4213. .input_mux = &alc260_capture_source,
  4214. },
  4215. [ALC260_FUJITSU_S702X] = {
  4216. .mixers = { alc260_fujitsu_mixer,
  4217. alc260_capture_mixer },
  4218. .init_verbs = { alc260_fujitsu_init_verbs },
  4219. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4220. .dac_nids = alc260_dac_nids,
  4221. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4222. .adc_nids = alc260_dual_adc_nids,
  4223. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4224. .channel_mode = alc260_modes,
  4225. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4226. .input_mux = alc260_fujitsu_capture_sources,
  4227. },
  4228. [ALC260_ACER] = {
  4229. .mixers = { alc260_acer_mixer,
  4230. alc260_capture_mixer },
  4231. .init_verbs = { alc260_acer_init_verbs },
  4232. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4233. .dac_nids = alc260_dac_nids,
  4234. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4235. .adc_nids = alc260_dual_adc_nids,
  4236. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4237. .channel_mode = alc260_modes,
  4238. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4239. .input_mux = alc260_acer_capture_sources,
  4240. },
  4241. [ALC260_WILL] = {
  4242. .mixers = { alc260_will_mixer,
  4243. alc260_capture_mixer },
  4244. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4245. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4246. .dac_nids = alc260_dac_nids,
  4247. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4248. .adc_nids = alc260_adc_nids,
  4249. .dig_out_nid = ALC260_DIGOUT_NID,
  4250. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4251. .channel_mode = alc260_modes,
  4252. .input_mux = &alc260_capture_source,
  4253. },
  4254. [ALC260_REPLACER_672V] = {
  4255. .mixers = { alc260_replacer_672v_mixer,
  4256. alc260_capture_mixer },
  4257. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4258. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4259. .dac_nids = alc260_dac_nids,
  4260. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4261. .adc_nids = alc260_adc_nids,
  4262. .dig_out_nid = ALC260_DIGOUT_NID,
  4263. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4264. .channel_mode = alc260_modes,
  4265. .input_mux = &alc260_capture_source,
  4266. .unsol_event = alc260_replacer_672v_unsol_event,
  4267. .init_hook = alc260_replacer_672v_automute,
  4268. },
  4269. #ifdef CONFIG_SND_DEBUG
  4270. [ALC260_TEST] = {
  4271. .mixers = { alc260_test_mixer,
  4272. alc260_capture_mixer },
  4273. .init_verbs = { alc260_test_init_verbs },
  4274. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4275. .dac_nids = alc260_test_dac_nids,
  4276. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4277. .adc_nids = alc260_test_adc_nids,
  4278. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4279. .channel_mode = alc260_modes,
  4280. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4281. .input_mux = alc260_test_capture_sources,
  4282. },
  4283. #endif
  4284. };
  4285. static int patch_alc260(struct hda_codec *codec)
  4286. {
  4287. struct alc_spec *spec;
  4288. int err, board_config;
  4289. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4290. if (spec == NULL)
  4291. return -ENOMEM;
  4292. codec->spec = spec;
  4293. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4294. alc260_models,
  4295. alc260_cfg_tbl);
  4296. if (board_config < 0) {
  4297. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4298. "trying auto-probe from BIOS...\n");
  4299. board_config = ALC260_AUTO;
  4300. }
  4301. if (board_config == ALC260_AUTO) {
  4302. /* automatic parse from the BIOS config */
  4303. err = alc260_parse_auto_config(codec);
  4304. if (err < 0) {
  4305. alc_free(codec);
  4306. return err;
  4307. } else if (!err) {
  4308. printk(KERN_INFO
  4309. "hda_codec: Cannot set up configuration "
  4310. "from BIOS. Using base mode...\n");
  4311. board_config = ALC260_BASIC;
  4312. }
  4313. }
  4314. if (board_config != ALC260_AUTO)
  4315. setup_preset(spec, &alc260_presets[board_config]);
  4316. spec->stream_name_analog = "ALC260 Analog";
  4317. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4318. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4319. spec->stream_name_digital = "ALC260 Digital";
  4320. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4321. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4322. codec->patch_ops = alc_patch_ops;
  4323. if (board_config == ALC260_AUTO)
  4324. spec->init_hook = alc260_auto_init;
  4325. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4326. if (!spec->loopback.amplist)
  4327. spec->loopback.amplist = alc260_loopbacks;
  4328. #endif
  4329. return 0;
  4330. }
  4331. /*
  4332. * ALC882 support
  4333. *
  4334. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4335. * configuration. Each pin widget can choose any input DACs and a mixer.
  4336. * Each ADC is connected from a mixer of all inputs. This makes possible
  4337. * 6-channel independent captures.
  4338. *
  4339. * In addition, an independent DAC for the multi-playback (not used in this
  4340. * driver yet).
  4341. */
  4342. #define ALC882_DIGOUT_NID 0x06
  4343. #define ALC882_DIGIN_NID 0x0a
  4344. static struct hda_channel_mode alc882_ch_modes[1] = {
  4345. { 8, NULL }
  4346. };
  4347. static hda_nid_t alc882_dac_nids[4] = {
  4348. /* front, rear, clfe, rear_surr */
  4349. 0x02, 0x03, 0x04, 0x05
  4350. };
  4351. /* identical with ALC880 */
  4352. #define alc882_adc_nids alc880_adc_nids
  4353. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4354. /* input MUX */
  4355. /* FIXME: should be a matrix-type input source selection */
  4356. static struct hda_input_mux alc882_capture_source = {
  4357. .num_items = 4,
  4358. .items = {
  4359. { "Mic", 0x0 },
  4360. { "Front Mic", 0x1 },
  4361. { "Line", 0x2 },
  4362. { "CD", 0x4 },
  4363. },
  4364. };
  4365. #define alc882_mux_enum_info alc_mux_enum_info
  4366. #define alc882_mux_enum_get alc_mux_enum_get
  4367. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4368. struct snd_ctl_elem_value *ucontrol)
  4369. {
  4370. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4371. struct alc_spec *spec = codec->spec;
  4372. const struct hda_input_mux *imux = spec->input_mux;
  4373. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4374. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4375. hda_nid_t nid = capture_mixers[adc_idx];
  4376. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4377. unsigned int i, idx;
  4378. idx = ucontrol->value.enumerated.item[0];
  4379. if (idx >= imux->num_items)
  4380. idx = imux->num_items - 1;
  4381. if (*cur_val == idx)
  4382. return 0;
  4383. for (i = 0; i < imux->num_items; i++) {
  4384. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4385. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4386. imux->items[i].index,
  4387. HDA_AMP_MUTE, v);
  4388. }
  4389. *cur_val = idx;
  4390. return 1;
  4391. }
  4392. /*
  4393. * 2ch mode
  4394. */
  4395. static struct hda_verb alc882_3ST_ch2_init[] = {
  4396. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4397. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4398. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4399. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4400. { } /* end */
  4401. };
  4402. /*
  4403. * 6ch mode
  4404. */
  4405. static struct hda_verb alc882_3ST_ch6_init[] = {
  4406. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4407. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4408. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4409. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4410. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4411. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4412. { } /* end */
  4413. };
  4414. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4415. { 2, alc882_3ST_ch2_init },
  4416. { 6, alc882_3ST_ch6_init },
  4417. };
  4418. /*
  4419. * 6ch mode
  4420. */
  4421. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4422. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4423. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4424. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4426. { } /* end */
  4427. };
  4428. /*
  4429. * 8ch mode
  4430. */
  4431. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4432. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4436. { } /* end */
  4437. };
  4438. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4439. { 6, alc882_sixstack_ch6_init },
  4440. { 8, alc882_sixstack_ch8_init },
  4441. };
  4442. /*
  4443. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4444. */
  4445. /*
  4446. * 2ch mode
  4447. */
  4448. static struct hda_verb alc885_mbp_ch2_init[] = {
  4449. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4450. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4451. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4452. { } /* end */
  4453. };
  4454. /*
  4455. * 6ch mode
  4456. */
  4457. static struct hda_verb alc885_mbp_ch6_init[] = {
  4458. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4459. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4460. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4461. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4462. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4463. { } /* end */
  4464. };
  4465. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4466. { 2, alc885_mbp_ch2_init },
  4467. { 6, alc885_mbp_ch6_init },
  4468. };
  4469. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4470. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4471. */
  4472. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4473. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4474. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4475. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4476. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4477. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4478. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4479. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4480. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4481. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4482. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4485. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4486. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4487. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4490. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4492. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4493. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4494. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4495. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4496. { } /* end */
  4497. };
  4498. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4499. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4500. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4501. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4502. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4503. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4505. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4506. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4508. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4509. { } /* end */
  4510. };
  4511. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4512. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4513. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4514. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4515. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4516. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4517. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4519. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4520. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4521. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4522. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4523. { } /* end */
  4524. };
  4525. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4526. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4527. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4528. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4529. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4530. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4531. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4532. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4533. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4534. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4535. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4536. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4537. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4538. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4539. { } /* end */
  4540. };
  4541. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4542. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4543. */
  4544. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4545. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4546. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4547. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4548. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4549. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4550. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4551. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4552. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4553. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4554. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4557. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4558. { } /* end */
  4559. };
  4560. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4561. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4562. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4563. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4564. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4565. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4566. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4567. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4568. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4569. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4570. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4571. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4572. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4573. { } /* end */
  4574. };
  4575. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4576. {
  4577. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4578. .name = "Channel Mode",
  4579. .info = alc_ch_mode_info,
  4580. .get = alc_ch_mode_get,
  4581. .put = alc_ch_mode_put,
  4582. },
  4583. { } /* end */
  4584. };
  4585. static struct hda_verb alc882_init_verbs[] = {
  4586. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4587. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4588. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4590. /* Rear mixer */
  4591. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4592. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4593. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4594. /* CLFE mixer */
  4595. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4596. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4597. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4598. /* Side mixer */
  4599. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4600. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4601. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4602. /* Front Pin: output 0 (0x0c) */
  4603. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4604. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4605. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4606. /* Rear Pin: output 1 (0x0d) */
  4607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4609. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4610. /* CLFE Pin: output 2 (0x0e) */
  4611. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4612. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4613. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4614. /* Side Pin: output 3 (0x0f) */
  4615. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4616. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4617. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4618. /* Mic (rear) pin: input vref at 80% */
  4619. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4620. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4621. /* Front Mic pin: input vref at 80% */
  4622. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4623. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4624. /* Line In pin: input */
  4625. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4626. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4627. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4628. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4629. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4630. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4631. /* CD pin widget for input */
  4632. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4633. /* FIXME: use matrix-type input source selection */
  4634. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4635. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4636. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4637. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4638. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4640. /* Input mixer2 */
  4641. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4642. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4643. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4645. /* Input mixer3 */
  4646. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4647. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4648. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4650. /* ADC1: mute amp left and right */
  4651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4652. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4653. /* ADC2: mute amp left and right */
  4654. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4655. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4656. /* ADC3: mute amp left and right */
  4657. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4658. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4659. { }
  4660. };
  4661. static struct hda_verb alc882_eapd_verbs[] = {
  4662. /* change to EAPD mode */
  4663. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4664. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4665. { }
  4666. };
  4667. /* Mac Pro test */
  4668. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4669. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4670. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4671. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4672. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4673. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4674. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4675. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4676. { } /* end */
  4677. };
  4678. static struct hda_verb alc882_macpro_init_verbs[] = {
  4679. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4680. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4683. /* Front Pin: output 0 (0x0c) */
  4684. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4685. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4686. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4687. /* Front Mic pin: input vref at 80% */
  4688. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4689. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4690. /* Speaker: output */
  4691. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4692. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4693. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4694. /* Headphone output (output 0 - 0x0c) */
  4695. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4696. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4697. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4698. /* FIXME: use matrix-type input source selection */
  4699. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4700. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4701. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4702. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4703. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4704. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4705. /* Input mixer2 */
  4706. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4707. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4708. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4709. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4710. /* Input mixer3 */
  4711. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4712. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4713. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4714. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4715. /* ADC1: mute amp left and right */
  4716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4717. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4718. /* ADC2: mute amp left and right */
  4719. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4720. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4721. /* ADC3: mute amp left and right */
  4722. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4723. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4724. { }
  4725. };
  4726. /* Macbook Pro rev3 */
  4727. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4728. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4729. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4730. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4731. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4732. /* Rear mixer */
  4733. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4734. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4735. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4736. /* Front Pin: output 0 (0x0c) */
  4737. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4738. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4739. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4740. /* HP Pin: output 0 (0x0d) */
  4741. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4742. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4743. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4744. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4745. /* Mic (rear) pin: input vref at 80% */
  4746. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4747. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4748. /* Front Mic pin: input vref at 80% */
  4749. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4750. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4751. /* Line In pin: use output 1 when in LineOut mode */
  4752. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4753. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4754. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4755. /* FIXME: use matrix-type input source selection */
  4756. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4757. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4758. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4759. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4760. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4761. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4762. /* Input mixer2 */
  4763. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4764. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4765. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4766. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4767. /* Input mixer3 */
  4768. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4769. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4770. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4771. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4772. /* ADC1: mute amp left and right */
  4773. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4774. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4775. /* ADC2: mute amp left and right */
  4776. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4777. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4778. /* ADC3: mute amp left and right */
  4779. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4780. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4781. { }
  4782. };
  4783. /* iMac 24 mixer. */
  4784. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4785. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4786. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4787. { } /* end */
  4788. };
  4789. /* iMac 24 init verbs. */
  4790. static struct hda_verb alc885_imac24_init_verbs[] = {
  4791. /* Internal speakers: output 0 (0x0c) */
  4792. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4793. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4794. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4795. /* Internal speakers: output 0 (0x0c) */
  4796. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4797. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4798. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4799. /* Headphone: output 0 (0x0c) */
  4800. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4801. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4802. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4803. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4804. /* Front Mic: input vref at 80% */
  4805. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4806. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4807. { }
  4808. };
  4809. /* Toggle speaker-output according to the hp-jack state */
  4810. static void alc885_imac24_automute(struct hda_codec *codec)
  4811. {
  4812. unsigned int present;
  4813. present = snd_hda_codec_read(codec, 0x14, 0,
  4814. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4815. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4816. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4817. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4818. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4819. }
  4820. /* Processes unsolicited events. */
  4821. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4822. unsigned int res)
  4823. {
  4824. /* Headphone insertion or removal. */
  4825. if ((res >> 26) == ALC880_HP_EVENT)
  4826. alc885_imac24_automute(codec);
  4827. }
  4828. static void alc885_mbp3_automute(struct hda_codec *codec)
  4829. {
  4830. unsigned int present;
  4831. present = snd_hda_codec_read(codec, 0x15, 0,
  4832. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4833. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4834. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4835. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4836. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4837. }
  4838. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4839. unsigned int res)
  4840. {
  4841. /* Headphone insertion or removal. */
  4842. if ((res >> 26) == ALC880_HP_EVENT)
  4843. alc885_mbp3_automute(codec);
  4844. }
  4845. static struct hda_verb alc882_targa_verbs[] = {
  4846. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4847. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4848. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4849. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4850. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4851. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4852. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4853. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4854. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4855. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4856. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4857. { } /* end */
  4858. };
  4859. /* toggle speaker-output according to the hp-jack state */
  4860. static void alc882_targa_automute(struct hda_codec *codec)
  4861. {
  4862. unsigned int present;
  4863. present = snd_hda_codec_read(codec, 0x14, 0,
  4864. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4865. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4866. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4867. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4868. present ? 1 : 3);
  4869. }
  4870. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4871. {
  4872. /* Looks like the unsol event is incompatible with the standard
  4873. * definition. 4bit tag is placed at 26 bit!
  4874. */
  4875. if (((res >> 26) == ALC880_HP_EVENT)) {
  4876. alc882_targa_automute(codec);
  4877. }
  4878. }
  4879. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4880. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4881. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4882. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4883. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4884. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4885. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4886. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4887. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4888. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4889. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4890. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4891. { } /* end */
  4892. };
  4893. static struct hda_verb alc882_asus_a7m_verbs[] = {
  4894. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4896. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4897. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4898. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4899. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4900. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4901. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4902. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4903. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4904. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4905. { } /* end */
  4906. };
  4907. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4908. {
  4909. unsigned int gpiostate, gpiomask, gpiodir;
  4910. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4911. AC_VERB_GET_GPIO_DATA, 0);
  4912. if (!muted)
  4913. gpiostate |= (1 << pin);
  4914. else
  4915. gpiostate &= ~(1 << pin);
  4916. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4917. AC_VERB_GET_GPIO_MASK, 0);
  4918. gpiomask |= (1 << pin);
  4919. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4920. AC_VERB_GET_GPIO_DIRECTION, 0);
  4921. gpiodir |= (1 << pin);
  4922. snd_hda_codec_write(codec, codec->afg, 0,
  4923. AC_VERB_SET_GPIO_MASK, gpiomask);
  4924. snd_hda_codec_write(codec, codec->afg, 0,
  4925. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4926. msleep(1);
  4927. snd_hda_codec_write(codec, codec->afg, 0,
  4928. AC_VERB_SET_GPIO_DATA, gpiostate);
  4929. }
  4930. /* set up GPIO at initialization */
  4931. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4932. {
  4933. alc882_gpio_mute(codec, 0, 0);
  4934. alc882_gpio_mute(codec, 1, 0);
  4935. }
  4936. /* set up GPIO and update auto-muting at initialization */
  4937. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4938. {
  4939. alc885_macpro_init_hook(codec);
  4940. alc885_imac24_automute(codec);
  4941. }
  4942. /*
  4943. * generic initialization of ADC, input mixers and output mixers
  4944. */
  4945. static struct hda_verb alc882_auto_init_verbs[] = {
  4946. /*
  4947. * Unmute ADC0-2 and set the default input to mic-in
  4948. */
  4949. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4950. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4951. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4952. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4953. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4954. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4955. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4956. * mixer widget
  4957. * Note: PASD motherboards uses the Line In 2 as the input for
  4958. * front panel mic (mic 2)
  4959. */
  4960. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4961. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4965. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4966. /*
  4967. * Set up output mixers (0x0c - 0x0f)
  4968. */
  4969. /* set vol=0 to output mixers */
  4970. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4971. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4974. /* set up input amps for analog loopback */
  4975. /* Amp Indices: DAC = 0, mixer = 1 */
  4976. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4977. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4978. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4979. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4980. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4981. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4982. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4983. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4984. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4985. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4986. /* FIXME: use matrix-type input source selection */
  4987. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4988. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4989. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4990. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4991. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4992. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4993. /* Input mixer2 */
  4994. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4995. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4996. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4997. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4998. /* Input mixer3 */
  4999. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5000. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5001. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5002. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5003. { }
  5004. };
  5005. /* capture mixer elements */
  5006. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5007. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5008. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5009. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5010. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5011. {
  5012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5013. /* The multiple "Capture Source" controls confuse alsamixer
  5014. * So call somewhat different..
  5015. * FIXME: the controls appear in the "playback" view!
  5016. */
  5017. /* .name = "Capture Source", */
  5018. .name = "Input Source",
  5019. .count = 2,
  5020. .info = alc882_mux_enum_info,
  5021. .get = alc882_mux_enum_get,
  5022. .put = alc882_mux_enum_put,
  5023. },
  5024. { } /* end */
  5025. };
  5026. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5027. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5028. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5029. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5030. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5031. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5032. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5033. {
  5034. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5035. /* The multiple "Capture Source" controls confuse alsamixer
  5036. * So call somewhat different..
  5037. * FIXME: the controls appear in the "playback" view!
  5038. */
  5039. /* .name = "Capture Source", */
  5040. .name = "Input Source",
  5041. .count = 3,
  5042. .info = alc882_mux_enum_info,
  5043. .get = alc882_mux_enum_get,
  5044. .put = alc882_mux_enum_put,
  5045. },
  5046. { } /* end */
  5047. };
  5048. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5049. #define alc882_loopbacks alc880_loopbacks
  5050. #endif
  5051. /* pcm configuration: identiacal with ALC880 */
  5052. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5053. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5054. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5055. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5056. /*
  5057. * configuration and preset
  5058. */
  5059. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5060. [ALC882_3ST_DIG] = "3stack-dig",
  5061. [ALC882_6ST_DIG] = "6stack-dig",
  5062. [ALC882_ARIMA] = "arima",
  5063. [ALC882_W2JC] = "w2jc",
  5064. [ALC882_TARGA] = "targa",
  5065. [ALC882_ASUS_A7J] = "asus-a7j",
  5066. [ALC882_ASUS_A7M] = "asus-a7m",
  5067. [ALC885_MACPRO] = "macpro",
  5068. [ALC885_MBP3] = "mbp3",
  5069. [ALC885_IMAC24] = "imac24",
  5070. [ALC882_AUTO] = "auto",
  5071. };
  5072. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5073. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5074. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5075. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5076. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5077. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5078. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5079. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5080. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5081. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5082. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5083. {}
  5084. };
  5085. static struct alc_config_preset alc882_presets[] = {
  5086. [ALC882_3ST_DIG] = {
  5087. .mixers = { alc882_base_mixer },
  5088. .init_verbs = { alc882_init_verbs },
  5089. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5090. .dac_nids = alc882_dac_nids,
  5091. .dig_out_nid = ALC882_DIGOUT_NID,
  5092. .dig_in_nid = ALC882_DIGIN_NID,
  5093. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5094. .channel_mode = alc882_ch_modes,
  5095. .need_dac_fix = 1,
  5096. .input_mux = &alc882_capture_source,
  5097. },
  5098. [ALC882_6ST_DIG] = {
  5099. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5100. .init_verbs = { alc882_init_verbs },
  5101. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5102. .dac_nids = alc882_dac_nids,
  5103. .dig_out_nid = ALC882_DIGOUT_NID,
  5104. .dig_in_nid = ALC882_DIGIN_NID,
  5105. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5106. .channel_mode = alc882_sixstack_modes,
  5107. .input_mux = &alc882_capture_source,
  5108. },
  5109. [ALC882_ARIMA] = {
  5110. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5111. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5112. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5113. .dac_nids = alc882_dac_nids,
  5114. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5115. .channel_mode = alc882_sixstack_modes,
  5116. .input_mux = &alc882_capture_source,
  5117. },
  5118. [ALC882_W2JC] = {
  5119. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5120. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5121. alc880_gpio1_init_verbs },
  5122. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5123. .dac_nids = alc882_dac_nids,
  5124. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5125. .channel_mode = alc880_threestack_modes,
  5126. .need_dac_fix = 1,
  5127. .input_mux = &alc882_capture_source,
  5128. .dig_out_nid = ALC882_DIGOUT_NID,
  5129. },
  5130. [ALC885_MBP3] = {
  5131. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5132. .init_verbs = { alc885_mbp3_init_verbs,
  5133. alc880_gpio1_init_verbs },
  5134. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5135. .dac_nids = alc882_dac_nids,
  5136. .channel_mode = alc885_mbp_6ch_modes,
  5137. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5138. .input_mux = &alc882_capture_source,
  5139. .dig_out_nid = ALC882_DIGOUT_NID,
  5140. .dig_in_nid = ALC882_DIGIN_NID,
  5141. .unsol_event = alc885_mbp3_unsol_event,
  5142. .init_hook = alc885_mbp3_automute,
  5143. },
  5144. [ALC885_MACPRO] = {
  5145. .mixers = { alc882_macpro_mixer },
  5146. .init_verbs = { alc882_macpro_init_verbs },
  5147. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5148. .dac_nids = alc882_dac_nids,
  5149. .dig_out_nid = ALC882_DIGOUT_NID,
  5150. .dig_in_nid = ALC882_DIGIN_NID,
  5151. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5152. .channel_mode = alc882_ch_modes,
  5153. .input_mux = &alc882_capture_source,
  5154. .init_hook = alc885_macpro_init_hook,
  5155. },
  5156. [ALC885_IMAC24] = {
  5157. .mixers = { alc885_imac24_mixer },
  5158. .init_verbs = { alc885_imac24_init_verbs },
  5159. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5160. .dac_nids = alc882_dac_nids,
  5161. .dig_out_nid = ALC882_DIGOUT_NID,
  5162. .dig_in_nid = ALC882_DIGIN_NID,
  5163. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5164. .channel_mode = alc882_ch_modes,
  5165. .input_mux = &alc882_capture_source,
  5166. .unsol_event = alc885_imac24_unsol_event,
  5167. .init_hook = alc885_imac24_init_hook,
  5168. },
  5169. [ALC882_TARGA] = {
  5170. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5171. alc882_capture_mixer },
  5172. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5173. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5174. .dac_nids = alc882_dac_nids,
  5175. .dig_out_nid = ALC882_DIGOUT_NID,
  5176. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5177. .adc_nids = alc882_adc_nids,
  5178. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5179. .channel_mode = alc882_3ST_6ch_modes,
  5180. .need_dac_fix = 1,
  5181. .input_mux = &alc882_capture_source,
  5182. .unsol_event = alc882_targa_unsol_event,
  5183. .init_hook = alc882_targa_automute,
  5184. },
  5185. [ALC882_ASUS_A7J] = {
  5186. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5187. alc882_capture_mixer },
  5188. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5189. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5190. .dac_nids = alc882_dac_nids,
  5191. .dig_out_nid = ALC882_DIGOUT_NID,
  5192. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5193. .adc_nids = alc882_adc_nids,
  5194. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5195. .channel_mode = alc882_3ST_6ch_modes,
  5196. .need_dac_fix = 1,
  5197. .input_mux = &alc882_capture_source,
  5198. },
  5199. [ALC882_ASUS_A7M] = {
  5200. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5201. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5202. alc880_gpio1_init_verbs,
  5203. alc882_asus_a7m_verbs },
  5204. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5205. .dac_nids = alc882_dac_nids,
  5206. .dig_out_nid = ALC882_DIGOUT_NID,
  5207. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5208. .channel_mode = alc880_threestack_modes,
  5209. .need_dac_fix = 1,
  5210. .input_mux = &alc882_capture_source,
  5211. },
  5212. };
  5213. /*
  5214. * Pin config fixes
  5215. */
  5216. enum {
  5217. PINFIX_ABIT_AW9D_MAX
  5218. };
  5219. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5220. { 0x15, 0x01080104 }, /* side */
  5221. { 0x16, 0x01011012 }, /* rear */
  5222. { 0x17, 0x01016011 }, /* clfe */
  5223. { }
  5224. };
  5225. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5226. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5227. };
  5228. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5229. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5230. {}
  5231. };
  5232. /*
  5233. * BIOS auto configuration
  5234. */
  5235. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5236. hda_nid_t nid, int pin_type,
  5237. int dac_idx)
  5238. {
  5239. /* set as output */
  5240. struct alc_spec *spec = codec->spec;
  5241. int idx;
  5242. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5243. idx = 4;
  5244. else
  5245. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5246. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5247. pin_type);
  5248. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5249. AMP_OUT_UNMUTE);
  5250. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5251. }
  5252. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5253. {
  5254. struct alc_spec *spec = codec->spec;
  5255. int i;
  5256. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5257. for (i = 0; i <= HDA_SIDE; i++) {
  5258. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5259. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5260. if (nid)
  5261. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5262. i);
  5263. }
  5264. }
  5265. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5266. {
  5267. struct alc_spec *spec = codec->spec;
  5268. hda_nid_t pin;
  5269. pin = spec->autocfg.hp_pins[0];
  5270. if (pin) /* connect to front */
  5271. /* use dac 0 */
  5272. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5273. }
  5274. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5275. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5276. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5277. {
  5278. struct alc_spec *spec = codec->spec;
  5279. int i;
  5280. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5281. hda_nid_t nid = spec->autocfg.input_pins[i];
  5282. if (alc882_is_input_pin(nid)) {
  5283. snd_hda_codec_write(codec, nid, 0,
  5284. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5285. i <= AUTO_PIN_FRONT_MIC ?
  5286. PIN_VREF80 : PIN_IN);
  5287. if (nid != ALC882_PIN_CD_NID)
  5288. snd_hda_codec_write(codec, nid, 0,
  5289. AC_VERB_SET_AMP_GAIN_MUTE,
  5290. AMP_OUT_MUTE);
  5291. }
  5292. }
  5293. }
  5294. /* add mic boosts if needed */
  5295. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5296. {
  5297. struct alc_spec *spec = codec->spec;
  5298. int err;
  5299. hda_nid_t nid;
  5300. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5301. if (nid) {
  5302. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5303. "Mic Boost",
  5304. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5305. if (err < 0)
  5306. return err;
  5307. }
  5308. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5309. if (nid) {
  5310. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5311. "Front Mic Boost",
  5312. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5313. if (err < 0)
  5314. return err;
  5315. }
  5316. return 0;
  5317. }
  5318. /* almost identical with ALC880 parser... */
  5319. static int alc882_parse_auto_config(struct hda_codec *codec)
  5320. {
  5321. struct alc_spec *spec = codec->spec;
  5322. int err = alc880_parse_auto_config(codec);
  5323. if (err < 0)
  5324. return err;
  5325. else if (!err)
  5326. return 0; /* no config found */
  5327. err = alc_auto_add_mic_boost(codec);
  5328. if (err < 0)
  5329. return err;
  5330. /* hack - override the init verbs */
  5331. spec->init_verbs[0] = alc882_auto_init_verbs;
  5332. return 1; /* config found */
  5333. }
  5334. /* additional initialization for auto-configuration model */
  5335. static void alc882_auto_init(struct hda_codec *codec)
  5336. {
  5337. alc882_auto_init_multi_out(codec);
  5338. alc882_auto_init_hp_out(codec);
  5339. alc882_auto_init_analog_input(codec);
  5340. }
  5341. static int patch_alc882(struct hda_codec *codec)
  5342. {
  5343. struct alc_spec *spec;
  5344. int err, board_config;
  5345. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5346. if (spec == NULL)
  5347. return -ENOMEM;
  5348. codec->spec = spec;
  5349. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5350. alc882_models,
  5351. alc882_cfg_tbl);
  5352. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5353. /* Pick up systems that don't supply PCI SSID */
  5354. switch (codec->subsystem_id) {
  5355. case 0x106b0c00: /* Mac Pro */
  5356. board_config = ALC885_MACPRO;
  5357. break;
  5358. case 0x106b1000: /* iMac 24 */
  5359. board_config = ALC885_IMAC24;
  5360. break;
  5361. case 0x106b2c00: /* Macbook Pro rev3 */
  5362. board_config = ALC885_MBP3;
  5363. break;
  5364. default:
  5365. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5366. "trying auto-probe from BIOS...\n");
  5367. board_config = ALC882_AUTO;
  5368. }
  5369. }
  5370. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5371. if (board_config == ALC882_AUTO) {
  5372. /* automatic parse from the BIOS config */
  5373. err = alc882_parse_auto_config(codec);
  5374. if (err < 0) {
  5375. alc_free(codec);
  5376. return err;
  5377. } else if (!err) {
  5378. printk(KERN_INFO
  5379. "hda_codec: Cannot set up configuration "
  5380. "from BIOS. Using base mode...\n");
  5381. board_config = ALC882_3ST_DIG;
  5382. }
  5383. }
  5384. if (board_config != ALC882_AUTO)
  5385. setup_preset(spec, &alc882_presets[board_config]);
  5386. spec->stream_name_analog = "ALC882 Analog";
  5387. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5388. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5389. spec->stream_name_digital = "ALC882 Digital";
  5390. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5391. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5392. if (!spec->adc_nids && spec->input_mux) {
  5393. /* check whether NID 0x07 is valid */
  5394. unsigned int wcap = get_wcaps(codec, 0x07);
  5395. /* get type */
  5396. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5397. if (wcap != AC_WID_AUD_IN) {
  5398. spec->adc_nids = alc882_adc_nids_alt;
  5399. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5400. spec->mixers[spec->num_mixers] =
  5401. alc882_capture_alt_mixer;
  5402. spec->num_mixers++;
  5403. } else {
  5404. spec->adc_nids = alc882_adc_nids;
  5405. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5406. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5407. spec->num_mixers++;
  5408. }
  5409. }
  5410. codec->patch_ops = alc_patch_ops;
  5411. if (board_config == ALC882_AUTO)
  5412. spec->init_hook = alc882_auto_init;
  5413. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5414. if (!spec->loopback.amplist)
  5415. spec->loopback.amplist = alc882_loopbacks;
  5416. #endif
  5417. return 0;
  5418. }
  5419. /*
  5420. * ALC883 support
  5421. *
  5422. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5423. * configuration. Each pin widget can choose any input DACs and a mixer.
  5424. * Each ADC is connected from a mixer of all inputs. This makes possible
  5425. * 6-channel independent captures.
  5426. *
  5427. * In addition, an independent DAC for the multi-playback (not used in this
  5428. * driver yet).
  5429. */
  5430. #define ALC883_DIGOUT_NID 0x06
  5431. #define ALC883_DIGIN_NID 0x0a
  5432. static hda_nid_t alc883_dac_nids[4] = {
  5433. /* front, rear, clfe, rear_surr */
  5434. 0x02, 0x04, 0x03, 0x05
  5435. };
  5436. static hda_nid_t alc883_adc_nids[2] = {
  5437. /* ADC1-2 */
  5438. 0x08, 0x09,
  5439. };
  5440. /* input MUX */
  5441. /* FIXME: should be a matrix-type input source selection */
  5442. static struct hda_input_mux alc883_capture_source = {
  5443. .num_items = 4,
  5444. .items = {
  5445. { "Mic", 0x0 },
  5446. { "Front Mic", 0x1 },
  5447. { "Line", 0x2 },
  5448. { "CD", 0x4 },
  5449. },
  5450. };
  5451. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5452. .num_items = 2,
  5453. .items = {
  5454. { "Mic", 0x1 },
  5455. { "Line", 0x2 },
  5456. },
  5457. };
  5458. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5459. .num_items = 4,
  5460. .items = {
  5461. { "Mic", 0x0 },
  5462. { "iMic", 0x1 },
  5463. { "Line", 0x2 },
  5464. { "CD", 0x4 },
  5465. },
  5466. };
  5467. #define alc883_mux_enum_info alc_mux_enum_info
  5468. #define alc883_mux_enum_get alc_mux_enum_get
  5469. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5470. struct snd_ctl_elem_value *ucontrol)
  5471. {
  5472. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5473. struct alc_spec *spec = codec->spec;
  5474. const struct hda_input_mux *imux = spec->input_mux;
  5475. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5476. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5477. hda_nid_t nid = capture_mixers[adc_idx];
  5478. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5479. unsigned int i, idx;
  5480. idx = ucontrol->value.enumerated.item[0];
  5481. if (idx >= imux->num_items)
  5482. idx = imux->num_items - 1;
  5483. if (*cur_val == idx)
  5484. return 0;
  5485. for (i = 0; i < imux->num_items; i++) {
  5486. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5487. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5488. imux->items[i].index,
  5489. HDA_AMP_MUTE, v);
  5490. }
  5491. *cur_val = idx;
  5492. return 1;
  5493. }
  5494. /*
  5495. * 2ch mode
  5496. */
  5497. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5498. { 2, NULL }
  5499. };
  5500. /*
  5501. * 2ch mode
  5502. */
  5503. static struct hda_verb alc883_3ST_ch2_init[] = {
  5504. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5505. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5506. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5507. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5508. { } /* end */
  5509. };
  5510. /*
  5511. * 4ch mode
  5512. */
  5513. static struct hda_verb alc883_3ST_ch4_init[] = {
  5514. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5515. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5516. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5517. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5518. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5519. { } /* end */
  5520. };
  5521. /*
  5522. * 6ch mode
  5523. */
  5524. static struct hda_verb alc883_3ST_ch6_init[] = {
  5525. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5526. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5527. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5528. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5529. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5530. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5531. { } /* end */
  5532. };
  5533. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5534. { 2, alc883_3ST_ch2_init },
  5535. { 4, alc883_3ST_ch4_init },
  5536. { 6, alc883_3ST_ch6_init },
  5537. };
  5538. /*
  5539. * 6ch mode
  5540. */
  5541. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5542. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5543. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5544. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5545. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5546. { } /* end */
  5547. };
  5548. /*
  5549. * 8ch mode
  5550. */
  5551. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5552. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5553. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5554. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5555. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5556. { } /* end */
  5557. };
  5558. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5559. { 6, alc883_sixstack_ch6_init },
  5560. { 8, alc883_sixstack_ch8_init },
  5561. };
  5562. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5563. /* eanable EAPD on medion laptop */
  5564. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5565. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5566. { }
  5567. };
  5568. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5569. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5570. */
  5571. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5572. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5573. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5574. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5575. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5576. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5577. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5578. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5579. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5580. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5581. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5582. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5583. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5584. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5585. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5586. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5587. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5588. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5589. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5590. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5592. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5594. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5595. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5596. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5597. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5598. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5599. {
  5600. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5601. /* .name = "Capture Source", */
  5602. .name = "Input Source",
  5603. .count = 2,
  5604. .info = alc883_mux_enum_info,
  5605. .get = alc883_mux_enum_get,
  5606. .put = alc883_mux_enum_put,
  5607. },
  5608. { } /* end */
  5609. };
  5610. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5611. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5612. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5613. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5614. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5615. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5616. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5617. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5619. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5620. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5621. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5622. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5623. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5624. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5625. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5627. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5628. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5629. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5630. {
  5631. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5632. /* .name = "Capture Source", */
  5633. .name = "Input Source",
  5634. .count = 2,
  5635. .info = alc883_mux_enum_info,
  5636. .get = alc883_mux_enum_get,
  5637. .put = alc883_mux_enum_put,
  5638. },
  5639. { } /* end */
  5640. };
  5641. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5642. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5643. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5644. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5645. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5646. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5647. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5648. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5649. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5650. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5651. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5652. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5655. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5656. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5657. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5659. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5660. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5662. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5664. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5665. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5666. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5667. {
  5668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5669. /* .name = "Capture Source", */
  5670. .name = "Input Source",
  5671. .count = 2,
  5672. .info = alc883_mux_enum_info,
  5673. .get = alc883_mux_enum_get,
  5674. .put = alc883_mux_enum_put,
  5675. },
  5676. { } /* end */
  5677. };
  5678. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5679. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5680. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5681. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5682. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5683. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5684. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5686. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5687. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5688. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5689. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5690. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5691. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5692. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5693. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5694. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5695. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5696. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5697. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5698. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5699. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5700. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5701. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5702. {
  5703. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5704. /* .name = "Capture Source", */
  5705. .name = "Input Source",
  5706. .count = 1,
  5707. .info = alc883_mux_enum_info,
  5708. .get = alc883_mux_enum_get,
  5709. .put = alc883_mux_enum_put,
  5710. },
  5711. { } /* end */
  5712. };
  5713. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5714. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5715. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5716. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5717. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5718. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5719. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5720. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5721. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5722. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5723. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5724. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5726. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5728. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5729. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5732. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5734. {
  5735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5736. /* .name = "Capture Source", */
  5737. .name = "Input Source",
  5738. .count = 2,
  5739. .info = alc883_mux_enum_info,
  5740. .get = alc883_mux_enum_get,
  5741. .put = alc883_mux_enum_put,
  5742. },
  5743. { } /* end */
  5744. };
  5745. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5746. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5747. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5748. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5749. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5750. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5752. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5753. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5754. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5755. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5757. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5758. {
  5759. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5760. /* .name = "Capture Source", */
  5761. .name = "Input Source",
  5762. .count = 2,
  5763. .info = alc883_mux_enum_info,
  5764. .get = alc883_mux_enum_get,
  5765. .put = alc883_mux_enum_put,
  5766. },
  5767. { } /* end */
  5768. };
  5769. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5770. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5771. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5772. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5773. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5774. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5775. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5776. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5777. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5778. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5779. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5780. {
  5781. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5782. /* .name = "Capture Source", */
  5783. .name = "Input Source",
  5784. .count = 1,
  5785. .info = alc883_mux_enum_info,
  5786. .get = alc883_mux_enum_get,
  5787. .put = alc883_mux_enum_put,
  5788. },
  5789. { } /* end */
  5790. };
  5791. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5792. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5793. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5795. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5796. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5797. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5798. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5800. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5802. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5803. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5804. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5805. {
  5806. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5807. /* .name = "Capture Source", */
  5808. .name = "Input Source",
  5809. .count = 2,
  5810. .info = alc883_mux_enum_info,
  5811. .get = alc883_mux_enum_get,
  5812. .put = alc883_mux_enum_put,
  5813. },
  5814. { } /* end */
  5815. };
  5816. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5817. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5818. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5821. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5822. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5823. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5824. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5825. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5826. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5827. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5828. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5829. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5830. {
  5831. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5832. /* .name = "Capture Source", */
  5833. .name = "Input Source",
  5834. .count = 2,
  5835. .info = alc883_mux_enum_info,
  5836. .get = alc883_mux_enum_get,
  5837. .put = alc883_mux_enum_put,
  5838. },
  5839. { } /* end */
  5840. };
  5841. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5842. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5843. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5844. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5845. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5846. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5847. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5848. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5849. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5850. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5851. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5855. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5856. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5857. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5858. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5859. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5860. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5861. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5862. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5863. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5864. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5866. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5867. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5868. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5869. {
  5870. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5871. /* .name = "Capture Source", */
  5872. .name = "Input Source",
  5873. .count = 2,
  5874. .info = alc883_mux_enum_info,
  5875. .get = alc883_mux_enum_get,
  5876. .put = alc883_mux_enum_put,
  5877. },
  5878. { } /* end */
  5879. };
  5880. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5881. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5882. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5883. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5884. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5885. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5887. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5888. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5889. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5890. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5891. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5892. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5893. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5894. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5895. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5896. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5897. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5898. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5899. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5900. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5901. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5902. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5903. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5904. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5905. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5906. {
  5907. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5908. /* .name = "Capture Source", */
  5909. .name = "Input Source",
  5910. .count = 2,
  5911. .info = alc883_mux_enum_info,
  5912. .get = alc883_mux_enum_get,
  5913. .put = alc883_mux_enum_put,
  5914. },
  5915. { } /* end */
  5916. };
  5917. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5918. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5919. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5920. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5921. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5922. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5923. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5924. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5925. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5926. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5927. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5928. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5929. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5930. {
  5931. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5932. /* .name = "Capture Source", */
  5933. .name = "Input Source",
  5934. .count = 2,
  5935. .info = alc883_mux_enum_info,
  5936. .get = alc883_mux_enum_get,
  5937. .put = alc883_mux_enum_put,
  5938. },
  5939. { } /* end */
  5940. };
  5941. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5942. {
  5943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5944. .name = "Channel Mode",
  5945. .info = alc_ch_mode_info,
  5946. .get = alc_ch_mode_get,
  5947. .put = alc_ch_mode_put,
  5948. },
  5949. { } /* end */
  5950. };
  5951. static struct hda_verb alc883_init_verbs[] = {
  5952. /* ADC1: mute amp left and right */
  5953. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5954. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5955. /* ADC2: mute amp left and right */
  5956. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5957. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5958. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5959. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5960. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5962. /* Rear mixer */
  5963. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5964. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5965. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5966. /* CLFE mixer */
  5967. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5968. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5969. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5970. /* Side mixer */
  5971. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5972. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5974. /* mute analog input loopbacks */
  5975. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5976. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5980. /* Front Pin: output 0 (0x0c) */
  5981. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5982. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5983. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5984. /* Rear Pin: output 1 (0x0d) */
  5985. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5986. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5987. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5988. /* CLFE Pin: output 2 (0x0e) */
  5989. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5990. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5991. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5992. /* Side Pin: output 3 (0x0f) */
  5993. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5994. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5995. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5996. /* Mic (rear) pin: input vref at 80% */
  5997. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5998. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5999. /* Front Mic pin: input vref at 80% */
  6000. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6001. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6002. /* Line In pin: input */
  6003. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6004. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6005. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6006. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6007. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6008. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6009. /* CD pin widget for input */
  6010. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6011. /* FIXME: use matrix-type input source selection */
  6012. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6013. /* Input mixer2 */
  6014. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6015. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6016. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6017. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6018. /* Input mixer3 */
  6019. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6020. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6021. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6022. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6023. { }
  6024. };
  6025. static struct hda_verb alc883_tagra_verbs[] = {
  6026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6027. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6028. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6029. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6030. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6031. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6032. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6033. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6034. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6035. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6036. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6037. { } /* end */
  6038. };
  6039. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6040. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6041. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6042. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6043. { } /* end */
  6044. };
  6045. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6046. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6047. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6048. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6049. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6050. { } /* end */
  6051. };
  6052. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6053. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6055. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6056. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6057. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6058. { } /* end */
  6059. };
  6060. static struct hda_verb alc883_haier_w66_verbs[] = {
  6061. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6062. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6063. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6064. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6065. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6066. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6067. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6068. { } /* end */
  6069. };
  6070. static struct hda_verb alc888_6st_hp_verbs[] = {
  6071. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6072. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6073. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6074. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6075. { }
  6076. };
  6077. static struct hda_verb alc888_3st_hp_verbs[] = {
  6078. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6079. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6080. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6081. { }
  6082. };
  6083. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6084. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6085. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6086. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6087. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6088. { }
  6089. };
  6090. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6091. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6092. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6093. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6094. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6095. { }
  6096. };
  6097. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6098. { 2, alc888_3st_hp_2ch_init },
  6099. { 6, alc888_3st_hp_6ch_init },
  6100. };
  6101. /* toggle front-jack and RCA according to the hp-jack state */
  6102. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6103. {
  6104. unsigned int present;
  6105. present = snd_hda_codec_read(codec, 0x1b, 0,
  6106. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6107. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6108. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6109. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6110. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6111. }
  6112. /* toggle RCA according to the front-jack state */
  6113. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6114. {
  6115. unsigned int present;
  6116. present = snd_hda_codec_read(codec, 0x14, 0,
  6117. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6118. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6119. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6120. }
  6121. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6122. unsigned int res)
  6123. {
  6124. if ((res >> 26) == ALC880_HP_EVENT)
  6125. alc888_lenovo_ms7195_front_automute(codec);
  6126. if ((res >> 26) == ALC880_FRONT_EVENT)
  6127. alc888_lenovo_ms7195_rca_automute(codec);
  6128. }
  6129. static struct hda_verb alc883_medion_md2_verbs[] = {
  6130. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6131. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6132. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6133. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6134. { } /* end */
  6135. };
  6136. /* toggle speaker-output according to the hp-jack state */
  6137. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6138. {
  6139. unsigned int present;
  6140. present = snd_hda_codec_read(codec, 0x14, 0,
  6141. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6142. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6143. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6144. }
  6145. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6146. unsigned int res)
  6147. {
  6148. if ((res >> 26) == ALC880_HP_EVENT)
  6149. alc883_medion_md2_automute(codec);
  6150. }
  6151. /* toggle speaker-output according to the hp-jack state */
  6152. static void alc883_tagra_automute(struct hda_codec *codec)
  6153. {
  6154. unsigned int present;
  6155. unsigned char bits;
  6156. present = snd_hda_codec_read(codec, 0x14, 0,
  6157. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6158. bits = present ? HDA_AMP_MUTE : 0;
  6159. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6160. HDA_AMP_MUTE, bits);
  6161. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6162. present ? 1 : 3);
  6163. }
  6164. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6165. {
  6166. if ((res >> 26) == ALC880_HP_EVENT)
  6167. alc883_tagra_automute(codec);
  6168. }
  6169. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6170. {
  6171. unsigned int present;
  6172. unsigned char bits;
  6173. present = snd_hda_codec_read(codec, 0x1b, 0,
  6174. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6175. bits = present ? 0x80 : 0;
  6176. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6177. 0x80, bits);
  6178. }
  6179. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6180. unsigned int res)
  6181. {
  6182. if ((res >> 26) == ALC880_HP_EVENT)
  6183. alc883_haier_w66_automute(codec);
  6184. }
  6185. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6186. {
  6187. unsigned int present;
  6188. unsigned char bits;
  6189. present = snd_hda_codec_read(codec, 0x14, 0,
  6190. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6191. bits = present ? HDA_AMP_MUTE : 0;
  6192. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6193. HDA_AMP_MUTE, bits);
  6194. }
  6195. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6196. {
  6197. unsigned int present;
  6198. unsigned char bits;
  6199. present = snd_hda_codec_read(codec, 0x1b, 0,
  6200. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6201. bits = present ? HDA_AMP_MUTE : 0;
  6202. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6203. HDA_AMP_MUTE, bits);
  6204. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6205. HDA_AMP_MUTE, bits);
  6206. }
  6207. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6208. unsigned int res)
  6209. {
  6210. if ((res >> 26) == ALC880_HP_EVENT)
  6211. alc883_lenovo_101e_all_automute(codec);
  6212. if ((res >> 26) == ALC880_FRONT_EVENT)
  6213. alc883_lenovo_101e_ispeaker_automute(codec);
  6214. }
  6215. /* toggle speaker-output according to the hp-jack state */
  6216. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6217. {
  6218. unsigned int present;
  6219. present = snd_hda_codec_read(codec, 0x14, 0,
  6220. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6221. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6222. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6223. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6224. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6225. }
  6226. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6227. unsigned int res)
  6228. {
  6229. if ((res >> 26) == ALC880_HP_EVENT)
  6230. alc883_acer_aspire_automute(codec);
  6231. }
  6232. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6233. /* HP Pin: output 0 (0x0c) */
  6234. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6235. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6236. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6237. /* Front Pin: output 0 (0x0c) */
  6238. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6239. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6240. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6241. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6242. /* eanable EAPD on medion laptop */
  6243. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6244. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6245. /* enable unsolicited event */
  6246. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6247. { }
  6248. };
  6249. /*
  6250. * generic initialization of ADC, input mixers and output mixers
  6251. */
  6252. static struct hda_verb alc883_auto_init_verbs[] = {
  6253. /*
  6254. * Unmute ADC0-2 and set the default input to mic-in
  6255. */
  6256. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6257. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6258. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6259. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6260. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6261. * mixer widget
  6262. * Note: PASD motherboards uses the Line In 2 as the input for
  6263. * front panel mic (mic 2)
  6264. */
  6265. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6266. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6267. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6268. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6271. /*
  6272. * Set up output mixers (0x0c - 0x0f)
  6273. */
  6274. /* set vol=0 to output mixers */
  6275. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6276. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6277. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6278. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6279. /* set up input amps for analog loopback */
  6280. /* Amp Indices: DAC = 0, mixer = 1 */
  6281. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6282. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6283. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6284. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6285. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6286. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6287. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6288. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6289. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6290. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6291. /* FIXME: use matrix-type input source selection */
  6292. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6293. /* Input mixer1 */
  6294. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6295. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6297. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6299. /* Input mixer2 */
  6300. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6301. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6303. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6304. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6305. { }
  6306. };
  6307. /* capture mixer elements */
  6308. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6309. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6310. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6313. {
  6314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6315. /* The multiple "Capture Source" controls confuse alsamixer
  6316. * So call somewhat different..
  6317. * FIXME: the controls appear in the "playback" view!
  6318. */
  6319. /* .name = "Capture Source", */
  6320. .name = "Input Source",
  6321. .count = 2,
  6322. .info = alc882_mux_enum_info,
  6323. .get = alc882_mux_enum_get,
  6324. .put = alc882_mux_enum_put,
  6325. },
  6326. { } /* end */
  6327. };
  6328. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6329. #define alc883_loopbacks alc880_loopbacks
  6330. #endif
  6331. /* pcm configuration: identiacal with ALC880 */
  6332. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6333. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6334. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6335. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6336. /*
  6337. * configuration and preset
  6338. */
  6339. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6340. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6341. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6342. [ALC883_3ST_6ch] = "3stack-6ch",
  6343. [ALC883_6ST_DIG] = "6stack-dig",
  6344. [ALC883_TARGA_DIG] = "targa-dig",
  6345. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6346. [ALC883_ACER] = "acer",
  6347. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6348. [ALC883_MEDION] = "medion",
  6349. [ALC883_MEDION_MD2] = "medion-md2",
  6350. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6351. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6352. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6353. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6354. [ALC883_HAIER_W66] = "haier-w66",
  6355. [ALC888_6ST_HP] = "6stack-hp",
  6356. [ALC888_3ST_HP] = "3stack-hp",
  6357. [ALC883_AUTO] = "auto",
  6358. };
  6359. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6360. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6361. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6362. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6363. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6364. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6365. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6366. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6367. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6368. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6369. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6370. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6371. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6372. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6373. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6374. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6375. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6376. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6377. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6378. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6379. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6380. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6381. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6382. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6383. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6384. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6385. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6386. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6387. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6388. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6389. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6390. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6391. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6392. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6393. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6394. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6395. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6396. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6397. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6398. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6399. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6400. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6401. {}
  6402. };
  6403. static struct alc_config_preset alc883_presets[] = {
  6404. [ALC883_3ST_2ch_DIG] = {
  6405. .mixers = { alc883_3ST_2ch_mixer },
  6406. .init_verbs = { alc883_init_verbs },
  6407. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6408. .dac_nids = alc883_dac_nids,
  6409. .dig_out_nid = ALC883_DIGOUT_NID,
  6410. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6411. .adc_nids = alc883_adc_nids,
  6412. .dig_in_nid = ALC883_DIGIN_NID,
  6413. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6414. .channel_mode = alc883_3ST_2ch_modes,
  6415. .input_mux = &alc883_capture_source,
  6416. },
  6417. [ALC883_3ST_6ch_DIG] = {
  6418. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6419. .init_verbs = { alc883_init_verbs },
  6420. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6421. .dac_nids = alc883_dac_nids,
  6422. .dig_out_nid = ALC883_DIGOUT_NID,
  6423. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6424. .adc_nids = alc883_adc_nids,
  6425. .dig_in_nid = ALC883_DIGIN_NID,
  6426. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6427. .channel_mode = alc883_3ST_6ch_modes,
  6428. .need_dac_fix = 1,
  6429. .input_mux = &alc883_capture_source,
  6430. },
  6431. [ALC883_3ST_6ch] = {
  6432. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6433. .init_verbs = { alc883_init_verbs },
  6434. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6435. .dac_nids = alc883_dac_nids,
  6436. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6437. .adc_nids = alc883_adc_nids,
  6438. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6439. .channel_mode = alc883_3ST_6ch_modes,
  6440. .need_dac_fix = 1,
  6441. .input_mux = &alc883_capture_source,
  6442. },
  6443. [ALC883_6ST_DIG] = {
  6444. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6445. .init_verbs = { alc883_init_verbs },
  6446. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6447. .dac_nids = alc883_dac_nids,
  6448. .dig_out_nid = ALC883_DIGOUT_NID,
  6449. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6450. .adc_nids = alc883_adc_nids,
  6451. .dig_in_nid = ALC883_DIGIN_NID,
  6452. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6453. .channel_mode = alc883_sixstack_modes,
  6454. .input_mux = &alc883_capture_source,
  6455. },
  6456. [ALC883_TARGA_DIG] = {
  6457. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6458. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6459. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6460. .dac_nids = alc883_dac_nids,
  6461. .dig_out_nid = ALC883_DIGOUT_NID,
  6462. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6463. .adc_nids = alc883_adc_nids,
  6464. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6465. .channel_mode = alc883_3ST_6ch_modes,
  6466. .need_dac_fix = 1,
  6467. .input_mux = &alc883_capture_source,
  6468. .unsol_event = alc883_tagra_unsol_event,
  6469. .init_hook = alc883_tagra_automute,
  6470. },
  6471. [ALC883_TARGA_2ch_DIG] = {
  6472. .mixers = { alc883_tagra_2ch_mixer},
  6473. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6474. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6475. .dac_nids = alc883_dac_nids,
  6476. .dig_out_nid = ALC883_DIGOUT_NID,
  6477. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6478. .adc_nids = alc883_adc_nids,
  6479. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6480. .channel_mode = alc883_3ST_2ch_modes,
  6481. .input_mux = &alc883_capture_source,
  6482. .unsol_event = alc883_tagra_unsol_event,
  6483. .init_hook = alc883_tagra_automute,
  6484. },
  6485. [ALC883_ACER] = {
  6486. .mixers = { alc883_base_mixer },
  6487. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6488. * and the headphone jack. Turn this on and rely on the
  6489. * standard mute methods whenever the user wants to turn
  6490. * these outputs off.
  6491. */
  6492. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6493. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6494. .dac_nids = alc883_dac_nids,
  6495. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6496. .adc_nids = alc883_adc_nids,
  6497. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6498. .channel_mode = alc883_3ST_2ch_modes,
  6499. .input_mux = &alc883_capture_source,
  6500. },
  6501. [ALC883_ACER_ASPIRE] = {
  6502. .mixers = { alc883_acer_aspire_mixer },
  6503. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6504. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6505. .dac_nids = alc883_dac_nids,
  6506. .dig_out_nid = ALC883_DIGOUT_NID,
  6507. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6508. .adc_nids = alc883_adc_nids,
  6509. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6510. .channel_mode = alc883_3ST_2ch_modes,
  6511. .input_mux = &alc883_capture_source,
  6512. .unsol_event = alc883_acer_aspire_unsol_event,
  6513. .init_hook = alc883_acer_aspire_automute,
  6514. },
  6515. [ALC883_MEDION] = {
  6516. .mixers = { alc883_fivestack_mixer,
  6517. alc883_chmode_mixer },
  6518. .init_verbs = { alc883_init_verbs,
  6519. alc883_medion_eapd_verbs },
  6520. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6521. .dac_nids = alc883_dac_nids,
  6522. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6523. .adc_nids = alc883_adc_nids,
  6524. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6525. .channel_mode = alc883_sixstack_modes,
  6526. .input_mux = &alc883_capture_source,
  6527. },
  6528. [ALC883_MEDION_MD2] = {
  6529. .mixers = { alc883_medion_md2_mixer},
  6530. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6531. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6532. .dac_nids = alc883_dac_nids,
  6533. .dig_out_nid = ALC883_DIGOUT_NID,
  6534. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6535. .adc_nids = alc883_adc_nids,
  6536. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6537. .channel_mode = alc883_3ST_2ch_modes,
  6538. .input_mux = &alc883_capture_source,
  6539. .unsol_event = alc883_medion_md2_unsol_event,
  6540. .init_hook = alc883_medion_md2_automute,
  6541. },
  6542. [ALC883_LAPTOP_EAPD] = {
  6543. .mixers = { alc883_base_mixer },
  6544. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6545. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6546. .dac_nids = alc883_dac_nids,
  6547. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6548. .adc_nids = alc883_adc_nids,
  6549. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6550. .channel_mode = alc883_3ST_2ch_modes,
  6551. .input_mux = &alc883_capture_source,
  6552. },
  6553. [ALC883_LENOVO_101E_2ch] = {
  6554. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6555. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6556. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6557. .dac_nids = alc883_dac_nids,
  6558. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6559. .adc_nids = alc883_adc_nids,
  6560. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6561. .channel_mode = alc883_3ST_2ch_modes,
  6562. .input_mux = &alc883_lenovo_101e_capture_source,
  6563. .unsol_event = alc883_lenovo_101e_unsol_event,
  6564. .init_hook = alc883_lenovo_101e_all_automute,
  6565. },
  6566. [ALC883_LENOVO_NB0763] = {
  6567. .mixers = { alc883_lenovo_nb0763_mixer },
  6568. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6569. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6570. .dac_nids = alc883_dac_nids,
  6571. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6572. .adc_nids = alc883_adc_nids,
  6573. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6574. .channel_mode = alc883_3ST_2ch_modes,
  6575. .need_dac_fix = 1,
  6576. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6577. .unsol_event = alc883_medion_md2_unsol_event,
  6578. .init_hook = alc883_medion_md2_automute,
  6579. },
  6580. [ALC888_LENOVO_MS7195_DIG] = {
  6581. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6582. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6583. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6584. .dac_nids = alc883_dac_nids,
  6585. .dig_out_nid = ALC883_DIGOUT_NID,
  6586. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6587. .adc_nids = alc883_adc_nids,
  6588. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6589. .channel_mode = alc883_3ST_6ch_modes,
  6590. .need_dac_fix = 1,
  6591. .input_mux = &alc883_capture_source,
  6592. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6593. .init_hook = alc888_lenovo_ms7195_front_automute,
  6594. },
  6595. [ALC883_HAIER_W66] = {
  6596. .mixers = { alc883_tagra_2ch_mixer},
  6597. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6598. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6599. .dac_nids = alc883_dac_nids,
  6600. .dig_out_nid = ALC883_DIGOUT_NID,
  6601. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6602. .adc_nids = alc883_adc_nids,
  6603. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6604. .channel_mode = alc883_3ST_2ch_modes,
  6605. .input_mux = &alc883_capture_source,
  6606. .unsol_event = alc883_haier_w66_unsol_event,
  6607. .init_hook = alc883_haier_w66_automute,
  6608. },
  6609. [ALC888_6ST_HP] = {
  6610. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6611. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6612. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6613. .dac_nids = alc883_dac_nids,
  6614. .dig_out_nid = ALC883_DIGOUT_NID,
  6615. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6616. .adc_nids = alc883_adc_nids,
  6617. .dig_in_nid = ALC883_DIGIN_NID,
  6618. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6619. .channel_mode = alc883_sixstack_modes,
  6620. .input_mux = &alc883_capture_source,
  6621. },
  6622. [ALC888_3ST_HP] = {
  6623. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6624. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6625. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6626. .dac_nids = alc883_dac_nids,
  6627. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6628. .adc_nids = alc883_adc_nids,
  6629. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6630. .channel_mode = alc888_3st_hp_modes,
  6631. .need_dac_fix = 1,
  6632. .input_mux = &alc883_capture_source,
  6633. },
  6634. };
  6635. /*
  6636. * BIOS auto configuration
  6637. */
  6638. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6639. hda_nid_t nid, int pin_type,
  6640. int dac_idx)
  6641. {
  6642. /* set as output */
  6643. struct alc_spec *spec = codec->spec;
  6644. int idx;
  6645. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6646. idx = 4;
  6647. else
  6648. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6649. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6650. pin_type);
  6651. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6652. AMP_OUT_UNMUTE);
  6653. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6654. }
  6655. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6656. {
  6657. struct alc_spec *spec = codec->spec;
  6658. int i;
  6659. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6660. for (i = 0; i <= HDA_SIDE; i++) {
  6661. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6662. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6663. if (nid)
  6664. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6665. i);
  6666. }
  6667. }
  6668. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6669. {
  6670. struct alc_spec *spec = codec->spec;
  6671. hda_nid_t pin;
  6672. pin = spec->autocfg.hp_pins[0];
  6673. if (pin) /* connect to front */
  6674. /* use dac 0 */
  6675. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6676. }
  6677. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6678. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6679. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6680. {
  6681. struct alc_spec *spec = codec->spec;
  6682. int i;
  6683. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6684. hda_nid_t nid = spec->autocfg.input_pins[i];
  6685. if (alc883_is_input_pin(nid)) {
  6686. snd_hda_codec_write(codec, nid, 0,
  6687. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6688. (i <= AUTO_PIN_FRONT_MIC ?
  6689. PIN_VREF80 : PIN_IN));
  6690. if (nid != ALC883_PIN_CD_NID)
  6691. snd_hda_codec_write(codec, nid, 0,
  6692. AC_VERB_SET_AMP_GAIN_MUTE,
  6693. AMP_OUT_MUTE);
  6694. }
  6695. }
  6696. }
  6697. /* almost identical with ALC880 parser... */
  6698. static int alc883_parse_auto_config(struct hda_codec *codec)
  6699. {
  6700. struct alc_spec *spec = codec->spec;
  6701. int err = alc880_parse_auto_config(codec);
  6702. if (err < 0)
  6703. return err;
  6704. else if (!err)
  6705. return 0; /* no config found */
  6706. err = alc_auto_add_mic_boost(codec);
  6707. if (err < 0)
  6708. return err;
  6709. /* hack - override the init verbs */
  6710. spec->init_verbs[0] = alc883_auto_init_verbs;
  6711. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6712. spec->num_mixers++;
  6713. return 1; /* config found */
  6714. }
  6715. /* additional initialization for auto-configuration model */
  6716. static void alc883_auto_init(struct hda_codec *codec)
  6717. {
  6718. alc883_auto_init_multi_out(codec);
  6719. alc883_auto_init_hp_out(codec);
  6720. alc883_auto_init_analog_input(codec);
  6721. }
  6722. static int patch_alc883(struct hda_codec *codec)
  6723. {
  6724. struct alc_spec *spec;
  6725. int err, board_config;
  6726. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6727. if (spec == NULL)
  6728. return -ENOMEM;
  6729. codec->spec = spec;
  6730. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6731. alc883_models,
  6732. alc883_cfg_tbl);
  6733. if (board_config < 0) {
  6734. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6735. "trying auto-probe from BIOS...\n");
  6736. board_config = ALC883_AUTO;
  6737. }
  6738. if (board_config == ALC883_AUTO) {
  6739. /* automatic parse from the BIOS config */
  6740. err = alc883_parse_auto_config(codec);
  6741. if (err < 0) {
  6742. alc_free(codec);
  6743. return err;
  6744. } else if (!err) {
  6745. printk(KERN_INFO
  6746. "hda_codec: Cannot set up configuration "
  6747. "from BIOS. Using base mode...\n");
  6748. board_config = ALC883_3ST_2ch_DIG;
  6749. }
  6750. }
  6751. if (board_config != ALC883_AUTO)
  6752. setup_preset(spec, &alc883_presets[board_config]);
  6753. spec->stream_name_analog = "ALC883 Analog";
  6754. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6755. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6756. spec->stream_name_digital = "ALC883 Digital";
  6757. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6758. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6759. if (!spec->adc_nids && spec->input_mux) {
  6760. spec->adc_nids = alc883_adc_nids;
  6761. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6762. }
  6763. codec->patch_ops = alc_patch_ops;
  6764. if (board_config == ALC883_AUTO)
  6765. spec->init_hook = alc883_auto_init;
  6766. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6767. if (!spec->loopback.amplist)
  6768. spec->loopback.amplist = alc883_loopbacks;
  6769. #endif
  6770. return 0;
  6771. }
  6772. /*
  6773. * ALC262 support
  6774. */
  6775. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6776. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6777. #define alc262_dac_nids alc260_dac_nids
  6778. #define alc262_adc_nids alc882_adc_nids
  6779. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6780. #define alc262_modes alc260_modes
  6781. #define alc262_capture_source alc882_capture_source
  6782. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6783. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6784. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6785. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6786. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6787. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6788. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6789. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6790. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6791. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6792. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6793. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6794. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6795. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6796. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6797. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6798. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6799. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6800. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6801. { } /* end */
  6802. };
  6803. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6804. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6805. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6806. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6807. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6808. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6809. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6810. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6811. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6812. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6813. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6814. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6815. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6816. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6817. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6818. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6819. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6820. { } /* end */
  6821. };
  6822. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6823. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6824. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6825. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6826. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6827. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6828. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6829. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6830. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6831. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6832. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6833. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6834. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6835. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6836. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6837. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6838. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6839. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6840. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6841. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6842. { } /* end */
  6843. };
  6844. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6845. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6846. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6847. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6848. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6849. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6850. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6851. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6852. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6853. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6854. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6855. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6856. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6857. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6858. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6859. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6860. { } /* end */
  6861. };
  6862. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6863. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6864. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6865. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6866. { } /* end */
  6867. };
  6868. /* bind hp and internal speaker mute (with plug check) */
  6869. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6870. struct snd_ctl_elem_value *ucontrol)
  6871. {
  6872. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6873. long *valp = ucontrol->value.integer.value;
  6874. int change;
  6875. /* change hp mute */
  6876. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6877. HDA_AMP_MUTE,
  6878. valp[0] ? 0 : HDA_AMP_MUTE);
  6879. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6880. HDA_AMP_MUTE,
  6881. valp[1] ? 0 : HDA_AMP_MUTE);
  6882. if (change) {
  6883. /* change speaker according to HP jack state */
  6884. struct alc_spec *spec = codec->spec;
  6885. unsigned int mute;
  6886. if (spec->jack_present)
  6887. mute = HDA_AMP_MUTE;
  6888. else
  6889. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6890. HDA_OUTPUT, 0);
  6891. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6892. HDA_AMP_MUTE, mute);
  6893. }
  6894. return change;
  6895. }
  6896. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6897. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6898. {
  6899. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6900. .name = "Master Playback Switch",
  6901. .info = snd_hda_mixer_amp_switch_info,
  6902. .get = snd_hda_mixer_amp_switch_get,
  6903. .put = alc262_sony_master_sw_put,
  6904. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6905. },
  6906. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6907. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6908. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6909. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6910. { } /* end */
  6911. };
  6912. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6913. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6914. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6915. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6916. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6917. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6918. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6919. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6920. { } /* end */
  6921. };
  6922. #define alc262_capture_mixer alc882_capture_mixer
  6923. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6924. /*
  6925. * generic initialization of ADC, input mixers and output mixers
  6926. */
  6927. static struct hda_verb alc262_init_verbs[] = {
  6928. /*
  6929. * Unmute ADC0-2 and set the default input to mic-in
  6930. */
  6931. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6932. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6933. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6934. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6935. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6936. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6937. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6938. * mixer widget
  6939. * Note: PASD motherboards uses the Line In 2 as the input for
  6940. * front panel mic (mic 2)
  6941. */
  6942. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6943. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6944. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6945. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6946. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6948. /*
  6949. * Set up output mixers (0x0c - 0x0e)
  6950. */
  6951. /* set vol=0 to output mixers */
  6952. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6953. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6954. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6955. /* set up input amps for analog loopback */
  6956. /* Amp Indices: DAC = 0, mixer = 1 */
  6957. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6958. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6959. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6960. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6961. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6962. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6963. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6964. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6965. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6966. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6967. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6968. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6969. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6970. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6971. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6972. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6973. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6974. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6975. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6976. /* FIXME: use matrix-type input source selection */
  6977. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6978. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6979. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6980. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6981. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6982. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6983. /* Input mixer2 */
  6984. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6985. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6986. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6987. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6988. /* Input mixer3 */
  6989. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6993. { }
  6994. };
  6995. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6996. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6997. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6998. {}
  6999. };
  7000. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7001. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7002. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7003. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7004. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7005. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7006. {}
  7007. };
  7008. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7009. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7010. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7011. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7012. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7013. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7014. };
  7015. /* mute/unmute internal speaker according to the hp jack and mute state */
  7016. static void alc262_hippo_automute(struct hda_codec *codec)
  7017. {
  7018. struct alc_spec *spec = codec->spec;
  7019. unsigned int mute;
  7020. unsigned int present;
  7021. /* need to execute and sync at first */
  7022. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7023. present = snd_hda_codec_read(codec, 0x15, 0,
  7024. AC_VERB_GET_PIN_SENSE, 0);
  7025. spec->jack_present = (present & 0x80000000) != 0;
  7026. if (spec->jack_present) {
  7027. /* mute internal speaker */
  7028. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7029. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7030. } else {
  7031. /* unmute internal speaker if necessary */
  7032. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7033. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7034. HDA_AMP_MUTE, mute);
  7035. }
  7036. }
  7037. /* unsolicited event for HP jack sensing */
  7038. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7039. unsigned int res)
  7040. {
  7041. if ((res >> 26) != ALC880_HP_EVENT)
  7042. return;
  7043. alc262_hippo_automute(codec);
  7044. }
  7045. static void alc262_hippo1_automute(struct hda_codec *codec)
  7046. {
  7047. unsigned int mute;
  7048. unsigned int present;
  7049. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7050. present = snd_hda_codec_read(codec, 0x1b, 0,
  7051. AC_VERB_GET_PIN_SENSE, 0);
  7052. present = (present & 0x80000000) != 0;
  7053. if (present) {
  7054. /* mute internal speaker */
  7055. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7056. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7057. } else {
  7058. /* unmute internal speaker if necessary */
  7059. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7060. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7061. HDA_AMP_MUTE, mute);
  7062. }
  7063. }
  7064. /* unsolicited event for HP jack sensing */
  7065. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7066. unsigned int res)
  7067. {
  7068. if ((res >> 26) != ALC880_HP_EVENT)
  7069. return;
  7070. alc262_hippo1_automute(codec);
  7071. }
  7072. /*
  7073. * fujitsu model
  7074. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7075. */
  7076. #define ALC_HP_EVENT 0x37
  7077. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7078. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7079. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7080. {}
  7081. };
  7082. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7083. .num_items = 2,
  7084. .items = {
  7085. { "Mic", 0x0 },
  7086. { "CD", 0x4 },
  7087. },
  7088. };
  7089. static struct hda_input_mux alc262_HP_capture_source = {
  7090. .num_items = 5,
  7091. .items = {
  7092. { "Mic", 0x0 },
  7093. { "Front Mic", 0x1 },
  7094. { "Line", 0x2 },
  7095. { "CD", 0x4 },
  7096. { "AUX IN", 0x6 },
  7097. },
  7098. };
  7099. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7100. .num_items = 4,
  7101. .items = {
  7102. { "Mic", 0x0 },
  7103. { "Front Mic", 0x2 },
  7104. { "Line", 0x1 },
  7105. { "CD", 0x4 },
  7106. },
  7107. };
  7108. /* mute/unmute internal speaker according to the hp jack and mute state */
  7109. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7110. {
  7111. struct alc_spec *spec = codec->spec;
  7112. unsigned int mute;
  7113. if (force || !spec->sense_updated) {
  7114. unsigned int present;
  7115. /* need to execute and sync at first */
  7116. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7117. present = snd_hda_codec_read(codec, 0x14, 0,
  7118. AC_VERB_GET_PIN_SENSE, 0);
  7119. spec->jack_present = (present & 0x80000000) != 0;
  7120. spec->sense_updated = 1;
  7121. }
  7122. if (spec->jack_present) {
  7123. /* mute internal speaker */
  7124. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7125. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7126. } else {
  7127. /* unmute internal speaker if necessary */
  7128. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7129. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7130. HDA_AMP_MUTE, mute);
  7131. }
  7132. }
  7133. /* unsolicited event for HP jack sensing */
  7134. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7135. unsigned int res)
  7136. {
  7137. if ((res >> 26) != ALC_HP_EVENT)
  7138. return;
  7139. alc262_fujitsu_automute(codec, 1);
  7140. }
  7141. /* bind volumes of both NID 0x0c and 0x0d */
  7142. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7143. .ops = &snd_hda_bind_vol,
  7144. .values = {
  7145. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7146. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7147. 0
  7148. },
  7149. };
  7150. /* bind hp and internal speaker mute (with plug check) */
  7151. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7152. struct snd_ctl_elem_value *ucontrol)
  7153. {
  7154. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7155. long *valp = ucontrol->value.integer.value;
  7156. int change;
  7157. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7158. HDA_AMP_MUTE,
  7159. valp[0] ? 0 : HDA_AMP_MUTE);
  7160. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7161. HDA_AMP_MUTE,
  7162. valp[1] ? 0 : HDA_AMP_MUTE);
  7163. if (change)
  7164. alc262_fujitsu_automute(codec, 0);
  7165. return change;
  7166. }
  7167. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7168. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7169. {
  7170. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7171. .name = "Master Playback Switch",
  7172. .info = snd_hda_mixer_amp_switch_info,
  7173. .get = snd_hda_mixer_amp_switch_get,
  7174. .put = alc262_fujitsu_master_sw_put,
  7175. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7176. },
  7177. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7178. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7179. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7180. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7181. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7182. { } /* end */
  7183. };
  7184. /* additional init verbs for Benq laptops */
  7185. static struct hda_verb alc262_EAPD_verbs[] = {
  7186. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7187. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7188. {}
  7189. };
  7190. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7191. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7192. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7193. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7194. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7195. {}
  7196. };
  7197. /* add playback controls from the parsed DAC table */
  7198. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7199. const struct auto_pin_cfg *cfg)
  7200. {
  7201. hda_nid_t nid;
  7202. int err;
  7203. spec->multiout.num_dacs = 1; /* only use one dac */
  7204. spec->multiout.dac_nids = spec->private_dac_nids;
  7205. spec->multiout.dac_nids[0] = 2;
  7206. nid = cfg->line_out_pins[0];
  7207. if (nid) {
  7208. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7209. "Front Playback Volume",
  7210. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7211. if (err < 0)
  7212. return err;
  7213. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7214. "Front Playback Switch",
  7215. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7216. if (err < 0)
  7217. return err;
  7218. }
  7219. nid = cfg->speaker_pins[0];
  7220. if (nid) {
  7221. if (nid == 0x16) {
  7222. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7223. "Speaker Playback Volume",
  7224. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7225. HDA_OUTPUT));
  7226. if (err < 0)
  7227. return err;
  7228. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7229. "Speaker Playback Switch",
  7230. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7231. HDA_OUTPUT));
  7232. if (err < 0)
  7233. return err;
  7234. } else {
  7235. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7236. "Speaker Playback Switch",
  7237. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7238. HDA_OUTPUT));
  7239. if (err < 0)
  7240. return err;
  7241. }
  7242. }
  7243. nid = cfg->hp_pins[0];
  7244. if (nid) {
  7245. /* spec->multiout.hp_nid = 2; */
  7246. if (nid == 0x16) {
  7247. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7248. "Headphone Playback Volume",
  7249. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7250. HDA_OUTPUT));
  7251. if (err < 0)
  7252. return err;
  7253. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7254. "Headphone Playback Switch",
  7255. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7256. HDA_OUTPUT));
  7257. if (err < 0)
  7258. return err;
  7259. } else {
  7260. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7261. "Headphone Playback Switch",
  7262. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7263. HDA_OUTPUT));
  7264. if (err < 0)
  7265. return err;
  7266. }
  7267. }
  7268. return 0;
  7269. }
  7270. /* identical with ALC880 */
  7271. #define alc262_auto_create_analog_input_ctls \
  7272. alc880_auto_create_analog_input_ctls
  7273. /*
  7274. * generic initialization of ADC, input mixers and output mixers
  7275. */
  7276. static struct hda_verb alc262_volume_init_verbs[] = {
  7277. /*
  7278. * Unmute ADC0-2 and set the default input to mic-in
  7279. */
  7280. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7281. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7282. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7283. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7284. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7285. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7286. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7287. * mixer widget
  7288. * Note: PASD motherboards uses the Line In 2 as the input for
  7289. * front panel mic (mic 2)
  7290. */
  7291. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7292. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7293. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7294. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7296. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7297. /*
  7298. * Set up output mixers (0x0c - 0x0f)
  7299. */
  7300. /* set vol=0 to output mixers */
  7301. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7302. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7303. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7304. /* set up input amps for analog loopback */
  7305. /* Amp Indices: DAC = 0, mixer = 1 */
  7306. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7307. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7308. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7309. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7310. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7311. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7312. /* FIXME: use matrix-type input source selection */
  7313. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7314. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7315. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7316. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7317. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7318. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7319. /* Input mixer2 */
  7320. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7321. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7322. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7323. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7324. /* Input mixer3 */
  7325. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7326. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7327. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7328. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7329. { }
  7330. };
  7331. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7332. /*
  7333. * Unmute ADC0-2 and set the default input to mic-in
  7334. */
  7335. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7336. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7337. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7338. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7339. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7340. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7341. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7342. * mixer widget
  7343. * Note: PASD motherboards uses the Line In 2 as the input for
  7344. * front panel mic (mic 2)
  7345. */
  7346. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7347. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7348. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7349. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7350. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7351. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7352. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7353. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7354. /*
  7355. * Set up output mixers (0x0c - 0x0e)
  7356. */
  7357. /* set vol=0 to output mixers */
  7358. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7359. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7360. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7361. /* set up input amps for analog loopback */
  7362. /* Amp Indices: DAC = 0, mixer = 1 */
  7363. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7364. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7365. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7366. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7367. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7368. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7369. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7370. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7371. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7372. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7374. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7375. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7376. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7377. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7378. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7379. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7380. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7381. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7382. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7384. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7385. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7386. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7387. /* FIXME: use matrix-type input source selection */
  7388. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7389. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7390. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7391. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7394. /* Input mixer2 */
  7395. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7396. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7397. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7398. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7399. /* Input mixer3 */
  7400. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7401. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7402. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7403. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7404. { }
  7405. };
  7406. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7407. /*
  7408. * Unmute ADC0-2 and set the default input to mic-in
  7409. */
  7410. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7411. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7412. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7413. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7414. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7415. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7416. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7417. * mixer widget
  7418. * Note: PASD motherboards uses the Line In 2 as the input for front
  7419. * panel mic (mic 2)
  7420. */
  7421. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7422. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7423. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7424. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7425. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7426. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7427. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7428. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7429. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7430. /*
  7431. * Set up output mixers (0x0c - 0x0e)
  7432. */
  7433. /* set vol=0 to output mixers */
  7434. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7435. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7436. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7437. /* set up input amps for analog loopback */
  7438. /* Amp Indices: DAC = 0, mixer = 1 */
  7439. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7440. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7441. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7442. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7443. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7444. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7445. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7446. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7447. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7448. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7449. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7450. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7451. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7452. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7453. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7454. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7455. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7456. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7457. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7458. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7459. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7460. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7461. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7462. /* FIXME: use matrix-type input source selection */
  7463. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7464. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7465. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7466. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7467. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7468. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7469. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7470. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7471. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7472. /* Input mixer2 */
  7473. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7474. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7475. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7476. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7477. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7478. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7479. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7480. /* Input mixer3 */
  7481. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7482. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7483. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7484. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7485. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7486. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7487. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7488. { }
  7489. };
  7490. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7491. #define alc262_loopbacks alc880_loopbacks
  7492. #endif
  7493. /* pcm configuration: identiacal with ALC880 */
  7494. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7495. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7496. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7497. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7498. /*
  7499. * BIOS auto configuration
  7500. */
  7501. static int alc262_parse_auto_config(struct hda_codec *codec)
  7502. {
  7503. struct alc_spec *spec = codec->spec;
  7504. int err;
  7505. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7506. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7507. alc262_ignore);
  7508. if (err < 0)
  7509. return err;
  7510. if (!spec->autocfg.line_outs)
  7511. return 0; /* can't find valid BIOS pin config */
  7512. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7513. if (err < 0)
  7514. return err;
  7515. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7516. if (err < 0)
  7517. return err;
  7518. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7519. if (spec->autocfg.dig_out_pin)
  7520. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7521. if (spec->autocfg.dig_in_pin)
  7522. spec->dig_in_nid = ALC262_DIGIN_NID;
  7523. if (spec->kctl_alloc)
  7524. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7525. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7526. spec->num_mux_defs = 1;
  7527. spec->input_mux = &spec->private_imux;
  7528. err = alc_auto_add_mic_boost(codec);
  7529. if (err < 0)
  7530. return err;
  7531. return 1;
  7532. }
  7533. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7534. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7535. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7536. /* init callback for auto-configuration model -- overriding the default init */
  7537. static void alc262_auto_init(struct hda_codec *codec)
  7538. {
  7539. alc262_auto_init_multi_out(codec);
  7540. alc262_auto_init_hp_out(codec);
  7541. alc262_auto_init_analog_input(codec);
  7542. }
  7543. /*
  7544. * configuration and preset
  7545. */
  7546. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7547. [ALC262_BASIC] = "basic",
  7548. [ALC262_HIPPO] = "hippo",
  7549. [ALC262_HIPPO_1] = "hippo_1",
  7550. [ALC262_FUJITSU] = "fujitsu",
  7551. [ALC262_HP_BPC] = "hp-bpc",
  7552. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7553. [ALC262_BENQ_ED8] = "benq",
  7554. [ALC262_BENQ_T31] = "benq-t31",
  7555. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7556. [ALC262_AUTO] = "auto",
  7557. };
  7558. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7559. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7560. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7561. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7562. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7563. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7564. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7565. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7566. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7567. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7568. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7569. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7570. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7571. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7572. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7573. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7574. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7575. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7576. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7577. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7578. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7579. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7580. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7581. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7582. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7583. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7584. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7585. {}
  7586. };
  7587. static struct alc_config_preset alc262_presets[] = {
  7588. [ALC262_BASIC] = {
  7589. .mixers = { alc262_base_mixer },
  7590. .init_verbs = { alc262_init_verbs },
  7591. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7592. .dac_nids = alc262_dac_nids,
  7593. .hp_nid = 0x03,
  7594. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7595. .channel_mode = alc262_modes,
  7596. .input_mux = &alc262_capture_source,
  7597. },
  7598. [ALC262_HIPPO] = {
  7599. .mixers = { alc262_base_mixer },
  7600. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7601. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7602. .dac_nids = alc262_dac_nids,
  7603. .hp_nid = 0x03,
  7604. .dig_out_nid = ALC262_DIGOUT_NID,
  7605. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7606. .channel_mode = alc262_modes,
  7607. .input_mux = &alc262_capture_source,
  7608. .unsol_event = alc262_hippo_unsol_event,
  7609. .init_hook = alc262_hippo_automute,
  7610. },
  7611. [ALC262_HIPPO_1] = {
  7612. .mixers = { alc262_hippo1_mixer },
  7613. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7614. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7615. .dac_nids = alc262_dac_nids,
  7616. .hp_nid = 0x02,
  7617. .dig_out_nid = ALC262_DIGOUT_NID,
  7618. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7619. .channel_mode = alc262_modes,
  7620. .input_mux = &alc262_capture_source,
  7621. .unsol_event = alc262_hippo1_unsol_event,
  7622. .init_hook = alc262_hippo1_automute,
  7623. },
  7624. [ALC262_FUJITSU] = {
  7625. .mixers = { alc262_fujitsu_mixer },
  7626. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7627. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7628. .dac_nids = alc262_dac_nids,
  7629. .hp_nid = 0x03,
  7630. .dig_out_nid = ALC262_DIGOUT_NID,
  7631. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7632. .channel_mode = alc262_modes,
  7633. .input_mux = &alc262_fujitsu_capture_source,
  7634. .unsol_event = alc262_fujitsu_unsol_event,
  7635. },
  7636. [ALC262_HP_BPC] = {
  7637. .mixers = { alc262_HP_BPC_mixer },
  7638. .init_verbs = { alc262_HP_BPC_init_verbs },
  7639. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7640. .dac_nids = alc262_dac_nids,
  7641. .hp_nid = 0x03,
  7642. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7643. .channel_mode = alc262_modes,
  7644. .input_mux = &alc262_HP_capture_source,
  7645. },
  7646. [ALC262_HP_BPC_D7000_WF] = {
  7647. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7648. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7649. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7650. .dac_nids = alc262_dac_nids,
  7651. .hp_nid = 0x03,
  7652. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7653. .channel_mode = alc262_modes,
  7654. .input_mux = &alc262_HP_D7000_capture_source,
  7655. },
  7656. [ALC262_HP_BPC_D7000_WL] = {
  7657. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7658. alc262_HP_BPC_WildWest_option_mixer },
  7659. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7660. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7661. .dac_nids = alc262_dac_nids,
  7662. .hp_nid = 0x03,
  7663. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7664. .channel_mode = alc262_modes,
  7665. .input_mux = &alc262_HP_D7000_capture_source,
  7666. },
  7667. [ALC262_BENQ_ED8] = {
  7668. .mixers = { alc262_base_mixer },
  7669. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7670. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7671. .dac_nids = alc262_dac_nids,
  7672. .hp_nid = 0x03,
  7673. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7674. .channel_mode = alc262_modes,
  7675. .input_mux = &alc262_capture_source,
  7676. },
  7677. [ALC262_SONY_ASSAMD] = {
  7678. .mixers = { alc262_sony_mixer },
  7679. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7680. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7681. .dac_nids = alc262_dac_nids,
  7682. .hp_nid = 0x02,
  7683. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7684. .channel_mode = alc262_modes,
  7685. .input_mux = &alc262_capture_source,
  7686. .unsol_event = alc262_hippo_unsol_event,
  7687. .init_hook = alc262_hippo_automute,
  7688. },
  7689. [ALC262_BENQ_T31] = {
  7690. .mixers = { alc262_benq_t31_mixer },
  7691. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7692. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7693. .dac_nids = alc262_dac_nids,
  7694. .hp_nid = 0x03,
  7695. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7696. .channel_mode = alc262_modes,
  7697. .input_mux = &alc262_capture_source,
  7698. .unsol_event = alc262_hippo_unsol_event,
  7699. .init_hook = alc262_hippo_automute,
  7700. },
  7701. };
  7702. static int patch_alc262(struct hda_codec *codec)
  7703. {
  7704. struct alc_spec *spec;
  7705. int board_config;
  7706. int err;
  7707. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7708. if (spec == NULL)
  7709. return -ENOMEM;
  7710. codec->spec = spec;
  7711. #if 0
  7712. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7713. * under-run
  7714. */
  7715. {
  7716. int tmp;
  7717. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7718. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7719. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7720. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7721. }
  7722. #endif
  7723. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7724. alc262_models,
  7725. alc262_cfg_tbl);
  7726. if (board_config < 0) {
  7727. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7728. "trying auto-probe from BIOS...\n");
  7729. board_config = ALC262_AUTO;
  7730. }
  7731. if (board_config == ALC262_AUTO) {
  7732. /* automatic parse from the BIOS config */
  7733. err = alc262_parse_auto_config(codec);
  7734. if (err < 0) {
  7735. alc_free(codec);
  7736. return err;
  7737. } else if (!err) {
  7738. printk(KERN_INFO
  7739. "hda_codec: Cannot set up configuration "
  7740. "from BIOS. Using base mode...\n");
  7741. board_config = ALC262_BASIC;
  7742. }
  7743. }
  7744. if (board_config != ALC262_AUTO)
  7745. setup_preset(spec, &alc262_presets[board_config]);
  7746. spec->stream_name_analog = "ALC262 Analog";
  7747. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7748. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7749. spec->stream_name_digital = "ALC262 Digital";
  7750. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7751. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7752. if (!spec->adc_nids && spec->input_mux) {
  7753. /* check whether NID 0x07 is valid */
  7754. unsigned int wcap = get_wcaps(codec, 0x07);
  7755. /* get type */
  7756. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7757. if (wcap != AC_WID_AUD_IN) {
  7758. spec->adc_nids = alc262_adc_nids_alt;
  7759. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7760. spec->mixers[spec->num_mixers] =
  7761. alc262_capture_alt_mixer;
  7762. spec->num_mixers++;
  7763. } else {
  7764. spec->adc_nids = alc262_adc_nids;
  7765. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7766. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7767. spec->num_mixers++;
  7768. }
  7769. }
  7770. codec->patch_ops = alc_patch_ops;
  7771. if (board_config == ALC262_AUTO)
  7772. spec->init_hook = alc262_auto_init;
  7773. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7774. if (!spec->loopback.amplist)
  7775. spec->loopback.amplist = alc262_loopbacks;
  7776. #endif
  7777. return 0;
  7778. }
  7779. /*
  7780. * ALC268 channel source setting (2 channel)
  7781. */
  7782. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7783. #define alc268_modes alc260_modes
  7784. static hda_nid_t alc268_dac_nids[2] = {
  7785. /* front, hp */
  7786. 0x02, 0x03
  7787. };
  7788. static hda_nid_t alc268_adc_nids[2] = {
  7789. /* ADC0-1 */
  7790. 0x08, 0x07
  7791. };
  7792. static hda_nid_t alc268_adc_nids_alt[1] = {
  7793. /* ADC0 */
  7794. 0x08
  7795. };
  7796. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7797. /* output mixer control */
  7798. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7799. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7800. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7801. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7802. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7803. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7804. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7805. { }
  7806. };
  7807. static struct hda_verb alc268_eapd_verbs[] = {
  7808. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7809. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7810. { }
  7811. };
  7812. /* Toshiba specific */
  7813. #define alc268_toshiba_automute alc262_hippo_automute
  7814. static struct hda_verb alc268_toshiba_verbs[] = {
  7815. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7816. { } /* end */
  7817. };
  7818. /* Acer specific */
  7819. /* bind volumes of both NID 0x02 and 0x03 */
  7820. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7821. .ops = &snd_hda_bind_vol,
  7822. .values = {
  7823. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7824. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7825. 0
  7826. },
  7827. };
  7828. /* mute/unmute internal speaker according to the hp jack and mute state */
  7829. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7830. {
  7831. struct alc_spec *spec = codec->spec;
  7832. unsigned int mute;
  7833. if (force || !spec->sense_updated) {
  7834. unsigned int present;
  7835. present = snd_hda_codec_read(codec, 0x14, 0,
  7836. AC_VERB_GET_PIN_SENSE, 0);
  7837. spec->jack_present = (present & 0x80000000) != 0;
  7838. spec->sense_updated = 1;
  7839. }
  7840. if (spec->jack_present)
  7841. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7842. else /* unmute internal speaker if necessary */
  7843. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7844. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7845. HDA_AMP_MUTE, mute);
  7846. }
  7847. /* bind hp and internal speaker mute (with plug check) */
  7848. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7849. struct snd_ctl_elem_value *ucontrol)
  7850. {
  7851. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7852. long *valp = ucontrol->value.integer.value;
  7853. int change;
  7854. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7855. HDA_AMP_MUTE,
  7856. valp[0] ? 0 : HDA_AMP_MUTE);
  7857. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7858. HDA_AMP_MUTE,
  7859. valp[1] ? 0 : HDA_AMP_MUTE);
  7860. if (change)
  7861. alc268_acer_automute(codec, 0);
  7862. return change;
  7863. }
  7864. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7865. /* output mixer control */
  7866. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7867. {
  7868. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7869. .name = "Master Playback Switch",
  7870. .info = snd_hda_mixer_amp_switch_info,
  7871. .get = snd_hda_mixer_amp_switch_get,
  7872. .put = alc268_acer_master_sw_put,
  7873. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7874. },
  7875. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7876. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7877. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7878. { }
  7879. };
  7880. static struct hda_verb alc268_acer_verbs[] = {
  7881. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7882. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7883. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7884. { }
  7885. };
  7886. /* unsolicited event for HP jack sensing */
  7887. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7888. unsigned int res)
  7889. {
  7890. if ((res >> 26) != ALC880_HP_EVENT)
  7891. return;
  7892. alc268_toshiba_automute(codec);
  7893. }
  7894. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7895. unsigned int res)
  7896. {
  7897. if ((res >> 26) != ALC880_HP_EVENT)
  7898. return;
  7899. alc268_acer_automute(codec, 1);
  7900. }
  7901. static void alc268_acer_init_hook(struct hda_codec *codec)
  7902. {
  7903. alc268_acer_automute(codec, 1);
  7904. }
  7905. /*
  7906. * generic initialization of ADC, input mixers and output mixers
  7907. */
  7908. static struct hda_verb alc268_base_init_verbs[] = {
  7909. /* Unmute DAC0-1 and set vol = 0 */
  7910. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7911. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7912. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7913. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7914. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7915. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7916. /*
  7917. * Set up output mixers (0x0c - 0x0e)
  7918. */
  7919. /* set vol=0 to output mixers */
  7920. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7921. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7922. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7923. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7924. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7925. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7926. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7927. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7928. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7929. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7930. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7931. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7932. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7933. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7934. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7935. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7936. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7937. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7938. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7939. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7940. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7941. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7942. /* FIXME: use matrix-type input source selection */
  7943. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7944. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7945. /* Input mixer2 */
  7946. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7947. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7948. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7949. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7950. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7951. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7952. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7953. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7954. { }
  7955. };
  7956. /*
  7957. * generic initialization of ADC, input mixers and output mixers
  7958. */
  7959. static struct hda_verb alc268_volume_init_verbs[] = {
  7960. /* set output DAC */
  7961. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7962. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7963. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7964. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7965. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7966. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7967. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7968. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7969. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7970. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7971. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7974. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7975. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7976. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7977. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7978. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7979. /* set PCBEEP vol = 0 */
  7980. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7981. { }
  7982. };
  7983. #define alc268_mux_enum_info alc_mux_enum_info
  7984. #define alc268_mux_enum_get alc_mux_enum_get
  7985. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7986. struct snd_ctl_elem_value *ucontrol)
  7987. {
  7988. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7989. struct alc_spec *spec = codec->spec;
  7990. const struct hda_input_mux *imux = spec->input_mux;
  7991. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7992. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7993. hda_nid_t nid = capture_mixers[adc_idx];
  7994. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7995. unsigned int i, idx;
  7996. idx = ucontrol->value.enumerated.item[0];
  7997. if (idx >= imux->num_items)
  7998. idx = imux->num_items - 1;
  7999. if (*cur_val == idx)
  8000. return 0;
  8001. for (i = 0; i < imux->num_items; i++) {
  8002. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8003. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8004. imux->items[i].index,
  8005. HDA_AMP_MUTE, v);
  8006. snd_hda_codec_write_cache(codec, nid, 0,
  8007. AC_VERB_SET_CONNECT_SEL,
  8008. idx );
  8009. }
  8010. *cur_val = idx;
  8011. return 1;
  8012. }
  8013. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8014. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8015. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8016. {
  8017. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8018. /* The multiple "Capture Source" controls confuse alsamixer
  8019. * So call somewhat different..
  8020. * FIXME: the controls appear in the "playback" view!
  8021. */
  8022. /* .name = "Capture Source", */
  8023. .name = "Input Source",
  8024. .count = 1,
  8025. .info = alc268_mux_enum_info,
  8026. .get = alc268_mux_enum_get,
  8027. .put = alc268_mux_enum_put,
  8028. },
  8029. { } /* end */
  8030. };
  8031. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8032. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8033. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8034. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8035. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8036. {
  8037. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8038. /* The multiple "Capture Source" controls confuse alsamixer
  8039. * So call somewhat different..
  8040. * FIXME: the controls appear in the "playback" view!
  8041. */
  8042. /* .name = "Capture Source", */
  8043. .name = "Input Source",
  8044. .count = 2,
  8045. .info = alc268_mux_enum_info,
  8046. .get = alc268_mux_enum_get,
  8047. .put = alc268_mux_enum_put,
  8048. },
  8049. { } /* end */
  8050. };
  8051. static struct hda_input_mux alc268_capture_source = {
  8052. .num_items = 4,
  8053. .items = {
  8054. { "Mic", 0x0 },
  8055. { "Front Mic", 0x1 },
  8056. { "Line", 0x2 },
  8057. { "CD", 0x3 },
  8058. },
  8059. };
  8060. /* create input playback/capture controls for the given pin */
  8061. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8062. const char *ctlname, int idx)
  8063. {
  8064. char name[32];
  8065. int err;
  8066. sprintf(name, "%s Playback Volume", ctlname);
  8067. if (nid == 0x14) {
  8068. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8069. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8070. HDA_OUTPUT));
  8071. if (err < 0)
  8072. return err;
  8073. } else if (nid == 0x15) {
  8074. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8075. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8076. HDA_OUTPUT));
  8077. if (err < 0)
  8078. return err;
  8079. } else
  8080. return -1;
  8081. sprintf(name, "%s Playback Switch", ctlname);
  8082. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8083. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8084. if (err < 0)
  8085. return err;
  8086. return 0;
  8087. }
  8088. /* add playback controls from the parsed DAC table */
  8089. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8090. const struct auto_pin_cfg *cfg)
  8091. {
  8092. hda_nid_t nid;
  8093. int err;
  8094. spec->multiout.num_dacs = 2; /* only use one dac */
  8095. spec->multiout.dac_nids = spec->private_dac_nids;
  8096. spec->multiout.dac_nids[0] = 2;
  8097. spec->multiout.dac_nids[1] = 3;
  8098. nid = cfg->line_out_pins[0];
  8099. if (nid)
  8100. alc268_new_analog_output(spec, nid, "Front", 0);
  8101. nid = cfg->speaker_pins[0];
  8102. if (nid == 0x1d) {
  8103. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8104. "Speaker Playback Volume",
  8105. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8106. if (err < 0)
  8107. return err;
  8108. }
  8109. nid = cfg->hp_pins[0];
  8110. if (nid)
  8111. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8112. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8113. if (nid == 0x16) {
  8114. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8115. "Mono Playback Switch",
  8116. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8117. if (err < 0)
  8118. return err;
  8119. }
  8120. return 0;
  8121. }
  8122. /* create playback/capture controls for input pins */
  8123. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8124. const struct auto_pin_cfg *cfg)
  8125. {
  8126. struct hda_input_mux *imux = &spec->private_imux;
  8127. int i, idx1;
  8128. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8129. switch(cfg->input_pins[i]) {
  8130. case 0x18:
  8131. idx1 = 0; /* Mic 1 */
  8132. break;
  8133. case 0x19:
  8134. idx1 = 1; /* Mic 2 */
  8135. break;
  8136. case 0x1a:
  8137. idx1 = 2; /* Line In */
  8138. break;
  8139. case 0x1c:
  8140. idx1 = 3; /* CD */
  8141. break;
  8142. default:
  8143. continue;
  8144. }
  8145. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8146. imux->items[imux->num_items].index = idx1;
  8147. imux->num_items++;
  8148. }
  8149. return 0;
  8150. }
  8151. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8152. {
  8153. struct alc_spec *spec = codec->spec;
  8154. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8155. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8156. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8157. unsigned int dac_vol1, dac_vol2;
  8158. if (speaker_nid) {
  8159. snd_hda_codec_write(codec, speaker_nid, 0,
  8160. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8161. snd_hda_codec_write(codec, 0x0f, 0,
  8162. AC_VERB_SET_AMP_GAIN_MUTE,
  8163. AMP_IN_UNMUTE(1));
  8164. snd_hda_codec_write(codec, 0x10, 0,
  8165. AC_VERB_SET_AMP_GAIN_MUTE,
  8166. AMP_IN_UNMUTE(1));
  8167. } else {
  8168. snd_hda_codec_write(codec, 0x0f, 0,
  8169. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8170. snd_hda_codec_write(codec, 0x10, 0,
  8171. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8172. }
  8173. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8174. if (line_nid == 0x14)
  8175. dac_vol2 = AMP_OUT_ZERO;
  8176. else if (line_nid == 0x15)
  8177. dac_vol1 = AMP_OUT_ZERO;
  8178. if (hp_nid == 0x14)
  8179. dac_vol2 = AMP_OUT_ZERO;
  8180. else if (hp_nid == 0x15)
  8181. dac_vol1 = AMP_OUT_ZERO;
  8182. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8183. spec->autocfg.line_out_pins[1] != 0x16 ||
  8184. spec->autocfg.line_out_pins[2] != 0x16)
  8185. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8186. snd_hda_codec_write(codec, 0x02, 0,
  8187. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8188. snd_hda_codec_write(codec, 0x03, 0,
  8189. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8190. }
  8191. /* pcm configuration: identiacal with ALC880 */
  8192. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8193. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8194. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8195. /*
  8196. * BIOS auto configuration
  8197. */
  8198. static int alc268_parse_auto_config(struct hda_codec *codec)
  8199. {
  8200. struct alc_spec *spec = codec->spec;
  8201. int err;
  8202. static hda_nid_t alc268_ignore[] = { 0 };
  8203. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8204. alc268_ignore);
  8205. if (err < 0)
  8206. return err;
  8207. if (!spec->autocfg.line_outs)
  8208. return 0; /* can't find valid BIOS pin config */
  8209. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8210. if (err < 0)
  8211. return err;
  8212. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8213. if (err < 0)
  8214. return err;
  8215. spec->multiout.max_channels = 2;
  8216. /* digital only support output */
  8217. if (spec->autocfg.dig_out_pin)
  8218. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8219. if (spec->kctl_alloc)
  8220. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8221. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8222. spec->num_mux_defs = 1;
  8223. spec->input_mux = &spec->private_imux;
  8224. err = alc_auto_add_mic_boost(codec);
  8225. if (err < 0)
  8226. return err;
  8227. return 1;
  8228. }
  8229. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8230. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8231. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8232. /* init callback for auto-configuration model -- overriding the default init */
  8233. static void alc268_auto_init(struct hda_codec *codec)
  8234. {
  8235. alc268_auto_init_multi_out(codec);
  8236. alc268_auto_init_hp_out(codec);
  8237. alc268_auto_init_mono_speaker_out(codec);
  8238. alc268_auto_init_analog_input(codec);
  8239. }
  8240. /*
  8241. * configuration and preset
  8242. */
  8243. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8244. [ALC268_3ST] = "3stack",
  8245. [ALC268_TOSHIBA] = "toshiba",
  8246. [ALC268_ACER] = "acer",
  8247. [ALC268_AUTO] = "auto",
  8248. };
  8249. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8250. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8251. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8252. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8253. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8254. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8255. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8256. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8257. {}
  8258. };
  8259. static struct alc_config_preset alc268_presets[] = {
  8260. [ALC268_3ST] = {
  8261. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8262. .init_verbs = { alc268_base_init_verbs },
  8263. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8264. .dac_nids = alc268_dac_nids,
  8265. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8266. .adc_nids = alc268_adc_nids_alt,
  8267. .hp_nid = 0x03,
  8268. .dig_out_nid = ALC268_DIGOUT_NID,
  8269. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8270. .channel_mode = alc268_modes,
  8271. .input_mux = &alc268_capture_source,
  8272. },
  8273. [ALC268_TOSHIBA] = {
  8274. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8275. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8276. alc268_toshiba_verbs },
  8277. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8278. .dac_nids = alc268_dac_nids,
  8279. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8280. .adc_nids = alc268_adc_nids_alt,
  8281. .hp_nid = 0x03,
  8282. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8283. .channel_mode = alc268_modes,
  8284. .input_mux = &alc268_capture_source,
  8285. .input_mux = &alc268_capture_source,
  8286. .unsol_event = alc268_toshiba_unsol_event,
  8287. .init_hook = alc268_toshiba_automute,
  8288. },
  8289. [ALC268_ACER] = {
  8290. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8291. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8292. alc268_acer_verbs },
  8293. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8294. .dac_nids = alc268_dac_nids,
  8295. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8296. .adc_nids = alc268_adc_nids_alt,
  8297. .hp_nid = 0x02,
  8298. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8299. .channel_mode = alc268_modes,
  8300. .input_mux = &alc268_capture_source,
  8301. .unsol_event = alc268_acer_unsol_event,
  8302. .init_hook = alc268_acer_init_hook,
  8303. },
  8304. };
  8305. static int patch_alc268(struct hda_codec *codec)
  8306. {
  8307. struct alc_spec *spec;
  8308. int board_config;
  8309. int err;
  8310. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8311. if (spec == NULL)
  8312. return -ENOMEM;
  8313. codec->spec = spec;
  8314. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8315. alc268_models,
  8316. alc268_cfg_tbl);
  8317. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8318. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8319. "trying auto-probe from BIOS...\n");
  8320. board_config = ALC268_AUTO;
  8321. }
  8322. if (board_config == ALC268_AUTO) {
  8323. /* automatic parse from the BIOS config */
  8324. err = alc268_parse_auto_config(codec);
  8325. if (err < 0) {
  8326. alc_free(codec);
  8327. return err;
  8328. } else if (!err) {
  8329. printk(KERN_INFO
  8330. "hda_codec: Cannot set up configuration "
  8331. "from BIOS. Using base mode...\n");
  8332. board_config = ALC268_3ST;
  8333. }
  8334. }
  8335. if (board_config != ALC268_AUTO)
  8336. setup_preset(spec, &alc268_presets[board_config]);
  8337. spec->stream_name_analog = "ALC268 Analog";
  8338. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8339. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8340. spec->stream_name_digital = "ALC268 Digital";
  8341. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8342. if (board_config == ALC268_AUTO) {
  8343. if (!spec->adc_nids && spec->input_mux) {
  8344. /* check whether NID 0x07 is valid */
  8345. unsigned int wcap = get_wcaps(codec, 0x07);
  8346. /* get type */
  8347. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8348. if (wcap != AC_WID_AUD_IN) {
  8349. spec->adc_nids = alc268_adc_nids_alt;
  8350. spec->num_adc_nids =
  8351. ARRAY_SIZE(alc268_adc_nids_alt);
  8352. spec->mixers[spec->num_mixers] =
  8353. alc268_capture_alt_mixer;
  8354. spec->num_mixers++;
  8355. } else {
  8356. spec->adc_nids = alc268_adc_nids;
  8357. spec->num_adc_nids =
  8358. ARRAY_SIZE(alc268_adc_nids);
  8359. spec->mixers[spec->num_mixers] =
  8360. alc268_capture_mixer;
  8361. spec->num_mixers++;
  8362. }
  8363. }
  8364. }
  8365. codec->patch_ops = alc_patch_ops;
  8366. if (board_config == ALC268_AUTO)
  8367. spec->init_hook = alc268_auto_init;
  8368. return 0;
  8369. }
  8370. /*
  8371. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8372. */
  8373. /*
  8374. * set the path ways for 2 channel output
  8375. * need to set the codec line out and mic 1 pin widgets to inputs
  8376. */
  8377. static struct hda_verb alc861_threestack_ch2_init[] = {
  8378. /* set pin widget 1Ah (line in) for input */
  8379. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8380. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8381. * the vref
  8382. */
  8383. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8384. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8385. #if 0
  8386. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8387. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8388. #endif
  8389. { } /* end */
  8390. };
  8391. /*
  8392. * 6ch mode
  8393. * need to set the codec line out and mic 1 pin widgets to outputs
  8394. */
  8395. static struct hda_verb alc861_threestack_ch6_init[] = {
  8396. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8397. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8398. /* set pin widget 18h (mic1) for output (CLFE)*/
  8399. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8400. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8401. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8402. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8403. #if 0
  8404. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8405. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8406. #endif
  8407. { } /* end */
  8408. };
  8409. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8410. { 2, alc861_threestack_ch2_init },
  8411. { 6, alc861_threestack_ch6_init },
  8412. };
  8413. /* Set mic1 as input and unmute the mixer */
  8414. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8415. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8416. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8417. { } /* end */
  8418. };
  8419. /* Set mic1 as output and mute mixer */
  8420. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8421. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8422. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8423. { } /* end */
  8424. };
  8425. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8426. { 2, alc861_uniwill_m31_ch2_init },
  8427. { 4, alc861_uniwill_m31_ch4_init },
  8428. };
  8429. /* Set mic1 and line-in as input and unmute the mixer */
  8430. static struct hda_verb alc861_asus_ch2_init[] = {
  8431. /* set pin widget 1Ah (line in) for input */
  8432. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8433. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8434. * the vref
  8435. */
  8436. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8437. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8438. #if 0
  8439. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8440. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8441. #endif
  8442. { } /* end */
  8443. };
  8444. /* Set mic1 nad line-in as output and mute mixer */
  8445. static struct hda_verb alc861_asus_ch6_init[] = {
  8446. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8447. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8448. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8449. /* set pin widget 18h (mic1) for output (CLFE)*/
  8450. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8451. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8452. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8453. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8454. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8455. #if 0
  8456. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8457. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8458. #endif
  8459. { } /* end */
  8460. };
  8461. static struct hda_channel_mode alc861_asus_modes[2] = {
  8462. { 2, alc861_asus_ch2_init },
  8463. { 6, alc861_asus_ch6_init },
  8464. };
  8465. /* patch-ALC861 */
  8466. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8467. /* output mixer control */
  8468. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8469. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8470. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8471. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8472. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8473. /*Input mixer control */
  8474. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8475. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8476. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8477. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8478. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8479. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8480. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8481. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8482. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8484. /* Capture mixer control */
  8485. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8486. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8487. {
  8488. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8489. .name = "Capture Source",
  8490. .count = 1,
  8491. .info = alc_mux_enum_info,
  8492. .get = alc_mux_enum_get,
  8493. .put = alc_mux_enum_put,
  8494. },
  8495. { } /* end */
  8496. };
  8497. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8498. /* output mixer control */
  8499. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8500. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8501. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8502. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8503. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8504. /* Input mixer control */
  8505. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8506. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8507. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8508. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8509. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8510. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8511. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8512. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8513. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8514. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8515. /* Capture mixer control */
  8516. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8517. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8518. {
  8519. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8520. .name = "Capture Source",
  8521. .count = 1,
  8522. .info = alc_mux_enum_info,
  8523. .get = alc_mux_enum_get,
  8524. .put = alc_mux_enum_put,
  8525. },
  8526. {
  8527. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8528. .name = "Channel Mode",
  8529. .info = alc_ch_mode_info,
  8530. .get = alc_ch_mode_get,
  8531. .put = alc_ch_mode_put,
  8532. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8533. },
  8534. { } /* end */
  8535. };
  8536. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8537. /* output mixer control */
  8538. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8539. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8540. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8541. /*Capture mixer control */
  8542. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8543. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8544. {
  8545. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8546. .name = "Capture Source",
  8547. .count = 1,
  8548. .info = alc_mux_enum_info,
  8549. .get = alc_mux_enum_get,
  8550. .put = alc_mux_enum_put,
  8551. },
  8552. { } /* end */
  8553. };
  8554. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8555. /* output mixer control */
  8556. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8557. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8558. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8559. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8560. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8561. /* Input mixer control */
  8562. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8563. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8564. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8565. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8566. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8567. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8568. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8569. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8570. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8571. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8572. /* Capture mixer control */
  8573. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8574. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8575. {
  8576. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8577. .name = "Capture Source",
  8578. .count = 1,
  8579. .info = alc_mux_enum_info,
  8580. .get = alc_mux_enum_get,
  8581. .put = alc_mux_enum_put,
  8582. },
  8583. {
  8584. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8585. .name = "Channel Mode",
  8586. .info = alc_ch_mode_info,
  8587. .get = alc_ch_mode_get,
  8588. .put = alc_ch_mode_put,
  8589. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8590. },
  8591. { } /* end */
  8592. };
  8593. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8594. /* output mixer control */
  8595. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8596. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8597. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8598. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8599. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8600. /* Input mixer control */
  8601. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8602. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8603. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8604. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8605. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8606. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8607. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8608. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8609. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8610. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8611. /* Capture mixer control */
  8612. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8613. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8614. {
  8615. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8616. .name = "Capture Source",
  8617. .count = 1,
  8618. .info = alc_mux_enum_info,
  8619. .get = alc_mux_enum_get,
  8620. .put = alc_mux_enum_put,
  8621. },
  8622. {
  8623. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8624. .name = "Channel Mode",
  8625. .info = alc_ch_mode_info,
  8626. .get = alc_ch_mode_get,
  8627. .put = alc_ch_mode_put,
  8628. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8629. },
  8630. { }
  8631. };
  8632. /* additional mixer */
  8633. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8634. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8635. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8636. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8637. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8638. { }
  8639. };
  8640. /*
  8641. * generic initialization of ADC, input mixers and output mixers
  8642. */
  8643. static struct hda_verb alc861_base_init_verbs[] = {
  8644. /*
  8645. * Unmute ADC0 and set the default input to mic-in
  8646. */
  8647. /* port-A for surround (rear panel) */
  8648. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8649. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8650. /* port-B for mic-in (rear panel) with vref */
  8651. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8652. /* port-C for line-in (rear panel) */
  8653. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8654. /* port-D for Front */
  8655. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8656. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8657. /* port-E for HP out (front panel) */
  8658. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8659. /* route front PCM to HP */
  8660. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8661. /* port-F for mic-in (front panel) with vref */
  8662. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8663. /* port-G for CLFE (rear panel) */
  8664. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8665. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8666. /* port-H for side (rear panel) */
  8667. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8668. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8669. /* CD-in */
  8670. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8671. /* route front mic to ADC1*/
  8672. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8673. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8674. /* Unmute DAC0~3 & spdif out*/
  8675. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8676. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8677. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8678. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8679. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8680. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8681. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8682. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8683. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8684. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8685. /* Unmute Stereo Mixer 15 */
  8686. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8687. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8688. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8690. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8691. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8692. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8693. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8694. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8695. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8696. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8697. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8698. /* hp used DAC 3 (Front) */
  8699. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8700. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8701. { }
  8702. };
  8703. static struct hda_verb alc861_threestack_init_verbs[] = {
  8704. /*
  8705. * Unmute ADC0 and set the default input to mic-in
  8706. */
  8707. /* port-A for surround (rear panel) */
  8708. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8709. /* port-B for mic-in (rear panel) with vref */
  8710. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8711. /* port-C for line-in (rear panel) */
  8712. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8713. /* port-D for Front */
  8714. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8715. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8716. /* port-E for HP out (front panel) */
  8717. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8718. /* route front PCM to HP */
  8719. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8720. /* port-F for mic-in (front panel) with vref */
  8721. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8722. /* port-G for CLFE (rear panel) */
  8723. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8724. /* port-H for side (rear panel) */
  8725. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8726. /* CD-in */
  8727. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8728. /* route front mic to ADC1*/
  8729. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8730. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8731. /* Unmute DAC0~3 & spdif out*/
  8732. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8733. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8734. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8735. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8736. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8737. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8738. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8739. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8740. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8741. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8742. /* Unmute Stereo Mixer 15 */
  8743. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8744. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8747. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8748. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8749. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8750. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8751. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8752. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8753. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8754. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8755. /* hp used DAC 3 (Front) */
  8756. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8758. { }
  8759. };
  8760. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8761. /*
  8762. * Unmute ADC0 and set the default input to mic-in
  8763. */
  8764. /* port-A for surround (rear panel) */
  8765. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8766. /* port-B for mic-in (rear panel) with vref */
  8767. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8768. /* port-C for line-in (rear panel) */
  8769. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8770. /* port-D for Front */
  8771. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8772. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8773. /* port-E for HP out (front panel) */
  8774. /* this has to be set to VREF80 */
  8775. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8776. /* route front PCM to HP */
  8777. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8778. /* port-F for mic-in (front panel) with vref */
  8779. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8780. /* port-G for CLFE (rear panel) */
  8781. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8782. /* port-H for side (rear panel) */
  8783. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8784. /* CD-in */
  8785. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8786. /* route front mic to ADC1*/
  8787. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8788. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8789. /* Unmute DAC0~3 & spdif out*/
  8790. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8791. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8792. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8793. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8795. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8796. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8797. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8798. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8799. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8800. /* Unmute Stereo Mixer 15 */
  8801. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8802. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8804. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8805. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8806. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8807. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8808. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8809. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8810. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8811. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8812. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8813. /* hp used DAC 3 (Front) */
  8814. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8815. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8816. { }
  8817. };
  8818. static struct hda_verb alc861_asus_init_verbs[] = {
  8819. /*
  8820. * Unmute ADC0 and set the default input to mic-in
  8821. */
  8822. /* port-A for surround (rear panel)
  8823. * according to codec#0 this is the HP jack
  8824. */
  8825. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8826. /* route front PCM to HP */
  8827. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8828. /* port-B for mic-in (rear panel) with vref */
  8829. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8830. /* port-C for line-in (rear panel) */
  8831. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8832. /* port-D for Front */
  8833. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8834. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8835. /* port-E for HP out (front panel) */
  8836. /* this has to be set to VREF80 */
  8837. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8838. /* route front PCM to HP */
  8839. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8840. /* port-F for mic-in (front panel) with vref */
  8841. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8842. /* port-G for CLFE (rear panel) */
  8843. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8844. /* port-H for side (rear panel) */
  8845. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8846. /* CD-in */
  8847. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8848. /* route front mic to ADC1*/
  8849. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8850. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8851. /* Unmute DAC0~3 & spdif out*/
  8852. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8853. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8854. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8855. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8856. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8857. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8858. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8859. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8860. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8861. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8862. /* Unmute Stereo Mixer 15 */
  8863. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8864. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8865. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8866. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8867. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8868. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8869. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8870. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8871. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8872. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8873. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8874. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8875. /* hp used DAC 3 (Front) */
  8876. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8877. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8878. { }
  8879. };
  8880. /* additional init verbs for ASUS laptops */
  8881. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8882. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8883. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8884. { }
  8885. };
  8886. /*
  8887. * generic initialization of ADC, input mixers and output mixers
  8888. */
  8889. static struct hda_verb alc861_auto_init_verbs[] = {
  8890. /*
  8891. * Unmute ADC0 and set the default input to mic-in
  8892. */
  8893. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8894. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8895. /* Unmute DAC0~3 & spdif out*/
  8896. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8897. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8898. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8899. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8900. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8901. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8902. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8903. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8904. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8905. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8906. /* Unmute Stereo Mixer 15 */
  8907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8908. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8909. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8910. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8911. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8912. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8913. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8914. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8915. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8916. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8917. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8918. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8919. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8920. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8921. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8922. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8923. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8924. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8925. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8926. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8927. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8928. { }
  8929. };
  8930. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8931. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8932. { }
  8933. };
  8934. /* toggle speaker-output according to the hp-jack state */
  8935. static void alc861_toshiba_automute(struct hda_codec *codec)
  8936. {
  8937. unsigned int present;
  8938. present = snd_hda_codec_read(codec, 0x0f, 0,
  8939. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8940. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8941. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8942. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8943. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8944. }
  8945. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8946. unsigned int res)
  8947. {
  8948. if ((res >> 26) == ALC880_HP_EVENT)
  8949. alc861_toshiba_automute(codec);
  8950. }
  8951. /* pcm configuration: identiacal with ALC880 */
  8952. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8953. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8954. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8955. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8956. #define ALC861_DIGOUT_NID 0x07
  8957. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8958. { 8, NULL }
  8959. };
  8960. static hda_nid_t alc861_dac_nids[4] = {
  8961. /* front, surround, clfe, side */
  8962. 0x03, 0x06, 0x05, 0x04
  8963. };
  8964. static hda_nid_t alc660_dac_nids[3] = {
  8965. /* front, clfe, surround */
  8966. 0x03, 0x05, 0x06
  8967. };
  8968. static hda_nid_t alc861_adc_nids[1] = {
  8969. /* ADC0-2 */
  8970. 0x08,
  8971. };
  8972. static struct hda_input_mux alc861_capture_source = {
  8973. .num_items = 5,
  8974. .items = {
  8975. { "Mic", 0x0 },
  8976. { "Front Mic", 0x3 },
  8977. { "Line", 0x1 },
  8978. { "CD", 0x4 },
  8979. { "Mixer", 0x5 },
  8980. },
  8981. };
  8982. /* fill in the dac_nids table from the parsed pin configuration */
  8983. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8984. const struct auto_pin_cfg *cfg)
  8985. {
  8986. int i;
  8987. hda_nid_t nid;
  8988. spec->multiout.dac_nids = spec->private_dac_nids;
  8989. for (i = 0; i < cfg->line_outs; i++) {
  8990. nid = cfg->line_out_pins[i];
  8991. if (nid) {
  8992. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8993. continue;
  8994. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8995. }
  8996. }
  8997. spec->multiout.num_dacs = cfg->line_outs;
  8998. return 0;
  8999. }
  9000. /* add playback controls from the parsed DAC table */
  9001. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9002. const struct auto_pin_cfg *cfg)
  9003. {
  9004. char name[32];
  9005. static const char *chname[4] = {
  9006. "Front", "Surround", NULL /*CLFE*/, "Side"
  9007. };
  9008. hda_nid_t nid;
  9009. int i, idx, err;
  9010. for (i = 0; i < cfg->line_outs; i++) {
  9011. nid = spec->multiout.dac_nids[i];
  9012. if (!nid)
  9013. continue;
  9014. if (nid == 0x05) {
  9015. /* Center/LFE */
  9016. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9017. "Center Playback Switch",
  9018. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9019. HDA_OUTPUT));
  9020. if (err < 0)
  9021. return err;
  9022. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9023. "LFE Playback Switch",
  9024. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9025. HDA_OUTPUT));
  9026. if (err < 0)
  9027. return err;
  9028. } else {
  9029. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9030. idx++)
  9031. if (nid == alc861_dac_nids[idx])
  9032. break;
  9033. sprintf(name, "%s Playback Switch", chname[idx]);
  9034. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9035. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9036. HDA_OUTPUT));
  9037. if (err < 0)
  9038. return err;
  9039. }
  9040. }
  9041. return 0;
  9042. }
  9043. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9044. {
  9045. int err;
  9046. hda_nid_t nid;
  9047. if (!pin)
  9048. return 0;
  9049. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9050. nid = 0x03;
  9051. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9052. "Headphone Playback Switch",
  9053. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9054. if (err < 0)
  9055. return err;
  9056. spec->multiout.hp_nid = nid;
  9057. }
  9058. return 0;
  9059. }
  9060. /* create playback/capture controls for input pins */
  9061. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9062. const struct auto_pin_cfg *cfg)
  9063. {
  9064. struct hda_input_mux *imux = &spec->private_imux;
  9065. int i, err, idx, idx1;
  9066. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9067. switch (cfg->input_pins[i]) {
  9068. case 0x0c:
  9069. idx1 = 1;
  9070. idx = 2; /* Line In */
  9071. break;
  9072. case 0x0f:
  9073. idx1 = 2;
  9074. idx = 2; /* Line In */
  9075. break;
  9076. case 0x0d:
  9077. idx1 = 0;
  9078. idx = 1; /* Mic In */
  9079. break;
  9080. case 0x10:
  9081. idx1 = 3;
  9082. idx = 1; /* Mic In */
  9083. break;
  9084. case 0x11:
  9085. idx1 = 4;
  9086. idx = 0; /* CD */
  9087. break;
  9088. default:
  9089. continue;
  9090. }
  9091. err = new_analog_input(spec, cfg->input_pins[i],
  9092. auto_pin_cfg_labels[i], idx, 0x15);
  9093. if (err < 0)
  9094. return err;
  9095. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9096. imux->items[imux->num_items].index = idx1;
  9097. imux->num_items++;
  9098. }
  9099. return 0;
  9100. }
  9101. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9102. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9103. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9104. {
  9105. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9106. /* The multiple "Capture Source" controls confuse alsamixer
  9107. * So call somewhat different..
  9108. *FIXME: the controls appear in the "playback" view!
  9109. */
  9110. /* .name = "Capture Source", */
  9111. .name = "Input Source",
  9112. .count = 1,
  9113. .info = alc_mux_enum_info,
  9114. .get = alc_mux_enum_get,
  9115. .put = alc_mux_enum_put,
  9116. },
  9117. { } /* end */
  9118. };
  9119. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9120. hda_nid_t nid,
  9121. int pin_type, int dac_idx)
  9122. {
  9123. /* set as output */
  9124. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9125. pin_type);
  9126. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9127. AMP_OUT_UNMUTE);
  9128. }
  9129. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9130. {
  9131. struct alc_spec *spec = codec->spec;
  9132. int i;
  9133. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9134. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9135. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9136. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9137. if (nid)
  9138. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9139. spec->multiout.dac_nids[i]);
  9140. }
  9141. }
  9142. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9143. {
  9144. struct alc_spec *spec = codec->spec;
  9145. hda_nid_t pin;
  9146. pin = spec->autocfg.hp_pins[0];
  9147. if (pin) /* connect to front */
  9148. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9149. spec->multiout.dac_nids[0]);
  9150. }
  9151. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9152. {
  9153. struct alc_spec *spec = codec->spec;
  9154. int i;
  9155. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9156. hda_nid_t nid = spec->autocfg.input_pins[i];
  9157. if (nid >= 0x0c && nid <= 0x11) {
  9158. snd_hda_codec_write(codec, nid, 0,
  9159. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9160. i <= AUTO_PIN_FRONT_MIC ?
  9161. PIN_VREF80 : PIN_IN);
  9162. }
  9163. }
  9164. }
  9165. /* parse the BIOS configuration and set up the alc_spec */
  9166. /* return 1 if successful, 0 if the proper config is not found,
  9167. * or a negative error code
  9168. */
  9169. static int alc861_parse_auto_config(struct hda_codec *codec)
  9170. {
  9171. struct alc_spec *spec = codec->spec;
  9172. int err;
  9173. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9174. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9175. alc861_ignore);
  9176. if (err < 0)
  9177. return err;
  9178. if (!spec->autocfg.line_outs)
  9179. return 0; /* can't find valid BIOS pin config */
  9180. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9181. if (err < 0)
  9182. return err;
  9183. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9184. if (err < 0)
  9185. return err;
  9186. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9187. if (err < 0)
  9188. return err;
  9189. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9190. if (err < 0)
  9191. return err;
  9192. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9193. if (spec->autocfg.dig_out_pin)
  9194. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9195. if (spec->kctl_alloc)
  9196. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9197. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9198. spec->num_mux_defs = 1;
  9199. spec->input_mux = &spec->private_imux;
  9200. spec->adc_nids = alc861_adc_nids;
  9201. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9202. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9203. spec->num_mixers++;
  9204. return 1;
  9205. }
  9206. /* additional initialization for auto-configuration model */
  9207. static void alc861_auto_init(struct hda_codec *codec)
  9208. {
  9209. alc861_auto_init_multi_out(codec);
  9210. alc861_auto_init_hp_out(codec);
  9211. alc861_auto_init_analog_input(codec);
  9212. }
  9213. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9214. static struct hda_amp_list alc861_loopbacks[] = {
  9215. { 0x15, HDA_INPUT, 0 },
  9216. { 0x15, HDA_INPUT, 1 },
  9217. { 0x15, HDA_INPUT, 2 },
  9218. { 0x15, HDA_INPUT, 3 },
  9219. { } /* end */
  9220. };
  9221. #endif
  9222. /*
  9223. * configuration and preset
  9224. */
  9225. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9226. [ALC861_3ST] = "3stack",
  9227. [ALC660_3ST] = "3stack-660",
  9228. [ALC861_3ST_DIG] = "3stack-dig",
  9229. [ALC861_6ST_DIG] = "6stack-dig",
  9230. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9231. [ALC861_TOSHIBA] = "toshiba",
  9232. [ALC861_ASUS] = "asus",
  9233. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9234. [ALC861_AUTO] = "auto",
  9235. };
  9236. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9237. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9238. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9239. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9240. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9241. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9242. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9243. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9244. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9245. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9246. * Any other models that need this preset?
  9247. */
  9248. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9249. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9250. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9251. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9252. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9253. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9254. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9255. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9256. {}
  9257. };
  9258. static struct alc_config_preset alc861_presets[] = {
  9259. [ALC861_3ST] = {
  9260. .mixers = { alc861_3ST_mixer },
  9261. .init_verbs = { alc861_threestack_init_verbs },
  9262. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9263. .dac_nids = alc861_dac_nids,
  9264. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9265. .channel_mode = alc861_threestack_modes,
  9266. .need_dac_fix = 1,
  9267. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9268. .adc_nids = alc861_adc_nids,
  9269. .input_mux = &alc861_capture_source,
  9270. },
  9271. [ALC861_3ST_DIG] = {
  9272. .mixers = { alc861_base_mixer },
  9273. .init_verbs = { alc861_threestack_init_verbs },
  9274. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9275. .dac_nids = alc861_dac_nids,
  9276. .dig_out_nid = ALC861_DIGOUT_NID,
  9277. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9278. .channel_mode = alc861_threestack_modes,
  9279. .need_dac_fix = 1,
  9280. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9281. .adc_nids = alc861_adc_nids,
  9282. .input_mux = &alc861_capture_source,
  9283. },
  9284. [ALC861_6ST_DIG] = {
  9285. .mixers = { alc861_base_mixer },
  9286. .init_verbs = { alc861_base_init_verbs },
  9287. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9288. .dac_nids = alc861_dac_nids,
  9289. .dig_out_nid = ALC861_DIGOUT_NID,
  9290. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9291. .channel_mode = alc861_8ch_modes,
  9292. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9293. .adc_nids = alc861_adc_nids,
  9294. .input_mux = &alc861_capture_source,
  9295. },
  9296. [ALC660_3ST] = {
  9297. .mixers = { alc861_3ST_mixer },
  9298. .init_verbs = { alc861_threestack_init_verbs },
  9299. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9300. .dac_nids = alc660_dac_nids,
  9301. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9302. .channel_mode = alc861_threestack_modes,
  9303. .need_dac_fix = 1,
  9304. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9305. .adc_nids = alc861_adc_nids,
  9306. .input_mux = &alc861_capture_source,
  9307. },
  9308. [ALC861_UNIWILL_M31] = {
  9309. .mixers = { alc861_uniwill_m31_mixer },
  9310. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9311. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9312. .dac_nids = alc861_dac_nids,
  9313. .dig_out_nid = ALC861_DIGOUT_NID,
  9314. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9315. .channel_mode = alc861_uniwill_m31_modes,
  9316. .need_dac_fix = 1,
  9317. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9318. .adc_nids = alc861_adc_nids,
  9319. .input_mux = &alc861_capture_source,
  9320. },
  9321. [ALC861_TOSHIBA] = {
  9322. .mixers = { alc861_toshiba_mixer },
  9323. .init_verbs = { alc861_base_init_verbs,
  9324. alc861_toshiba_init_verbs },
  9325. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9326. .dac_nids = alc861_dac_nids,
  9327. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9328. .channel_mode = alc883_3ST_2ch_modes,
  9329. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9330. .adc_nids = alc861_adc_nids,
  9331. .input_mux = &alc861_capture_source,
  9332. .unsol_event = alc861_toshiba_unsol_event,
  9333. .init_hook = alc861_toshiba_automute,
  9334. },
  9335. [ALC861_ASUS] = {
  9336. .mixers = { alc861_asus_mixer },
  9337. .init_verbs = { alc861_asus_init_verbs },
  9338. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9339. .dac_nids = alc861_dac_nids,
  9340. .dig_out_nid = ALC861_DIGOUT_NID,
  9341. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9342. .channel_mode = alc861_asus_modes,
  9343. .need_dac_fix = 1,
  9344. .hp_nid = 0x06,
  9345. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9346. .adc_nids = alc861_adc_nids,
  9347. .input_mux = &alc861_capture_source,
  9348. },
  9349. [ALC861_ASUS_LAPTOP] = {
  9350. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9351. .init_verbs = { alc861_asus_init_verbs,
  9352. alc861_asus_laptop_init_verbs },
  9353. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9354. .dac_nids = alc861_dac_nids,
  9355. .dig_out_nid = ALC861_DIGOUT_NID,
  9356. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9357. .channel_mode = alc883_3ST_2ch_modes,
  9358. .need_dac_fix = 1,
  9359. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9360. .adc_nids = alc861_adc_nids,
  9361. .input_mux = &alc861_capture_source,
  9362. },
  9363. };
  9364. static int patch_alc861(struct hda_codec *codec)
  9365. {
  9366. struct alc_spec *spec;
  9367. int board_config;
  9368. int err;
  9369. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9370. if (spec == NULL)
  9371. return -ENOMEM;
  9372. codec->spec = spec;
  9373. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9374. alc861_models,
  9375. alc861_cfg_tbl);
  9376. if (board_config < 0) {
  9377. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9378. "trying auto-probe from BIOS...\n");
  9379. board_config = ALC861_AUTO;
  9380. }
  9381. if (board_config == ALC861_AUTO) {
  9382. /* automatic parse from the BIOS config */
  9383. err = alc861_parse_auto_config(codec);
  9384. if (err < 0) {
  9385. alc_free(codec);
  9386. return err;
  9387. } else if (!err) {
  9388. printk(KERN_INFO
  9389. "hda_codec: Cannot set up configuration "
  9390. "from BIOS. Using base mode...\n");
  9391. board_config = ALC861_3ST_DIG;
  9392. }
  9393. }
  9394. if (board_config != ALC861_AUTO)
  9395. setup_preset(spec, &alc861_presets[board_config]);
  9396. spec->stream_name_analog = "ALC861 Analog";
  9397. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9398. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9399. spec->stream_name_digital = "ALC861 Digital";
  9400. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9401. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9402. codec->patch_ops = alc_patch_ops;
  9403. if (board_config == ALC861_AUTO)
  9404. spec->init_hook = alc861_auto_init;
  9405. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9406. if (!spec->loopback.amplist)
  9407. spec->loopback.amplist = alc861_loopbacks;
  9408. #endif
  9409. return 0;
  9410. }
  9411. /*
  9412. * ALC861-VD support
  9413. *
  9414. * Based on ALC882
  9415. *
  9416. * In addition, an independent DAC
  9417. */
  9418. #define ALC861VD_DIGOUT_NID 0x06
  9419. static hda_nid_t alc861vd_dac_nids[4] = {
  9420. /* front, surr, clfe, side surr */
  9421. 0x02, 0x03, 0x04, 0x05
  9422. };
  9423. /* dac_nids for ALC660vd are in a different order - according to
  9424. * Realtek's driver.
  9425. * This should probably tesult in a different mixer for 6stack models
  9426. * of ALC660vd codecs, but for now there is only 3stack mixer
  9427. * - and it is the same as in 861vd.
  9428. * adc_nids in ALC660vd are (is) the same as in 861vd
  9429. */
  9430. static hda_nid_t alc660vd_dac_nids[3] = {
  9431. /* front, rear, clfe, rear_surr */
  9432. 0x02, 0x04, 0x03
  9433. };
  9434. static hda_nid_t alc861vd_adc_nids[1] = {
  9435. /* ADC0 */
  9436. 0x09,
  9437. };
  9438. /* input MUX */
  9439. /* FIXME: should be a matrix-type input source selection */
  9440. static struct hda_input_mux alc861vd_capture_source = {
  9441. .num_items = 4,
  9442. .items = {
  9443. { "Mic", 0x0 },
  9444. { "Front Mic", 0x1 },
  9445. { "Line", 0x2 },
  9446. { "CD", 0x4 },
  9447. },
  9448. };
  9449. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9450. .num_items = 3,
  9451. .items = {
  9452. { "Front Mic", 0x0 },
  9453. { "ATAPI Mic", 0x1 },
  9454. { "Line In", 0x5 },
  9455. },
  9456. };
  9457. static struct hda_input_mux alc861vd_hp_capture_source = {
  9458. .num_items = 2,
  9459. .items = {
  9460. { "Front Mic", 0x0 },
  9461. { "ATAPI Mic", 0x1 },
  9462. },
  9463. };
  9464. #define alc861vd_mux_enum_info alc_mux_enum_info
  9465. #define alc861vd_mux_enum_get alc_mux_enum_get
  9466. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9467. struct snd_ctl_elem_value *ucontrol)
  9468. {
  9469. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9470. struct alc_spec *spec = codec->spec;
  9471. const struct hda_input_mux *imux = spec->input_mux;
  9472. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9473. static hda_nid_t capture_mixers[1] = { 0x22 };
  9474. hda_nid_t nid = capture_mixers[adc_idx];
  9475. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9476. unsigned int i, idx;
  9477. idx = ucontrol->value.enumerated.item[0];
  9478. if (idx >= imux->num_items)
  9479. idx = imux->num_items - 1;
  9480. if (*cur_val == idx)
  9481. return 0;
  9482. for (i = 0; i < imux->num_items; i++) {
  9483. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9484. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9485. imux->items[i].index,
  9486. HDA_AMP_MUTE, v);
  9487. }
  9488. *cur_val = idx;
  9489. return 1;
  9490. }
  9491. /*
  9492. * 2ch mode
  9493. */
  9494. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9495. { 2, NULL }
  9496. };
  9497. /*
  9498. * 6ch mode
  9499. */
  9500. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9501. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9502. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9503. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9504. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9505. { } /* end */
  9506. };
  9507. /*
  9508. * 8ch mode
  9509. */
  9510. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9511. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9512. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9513. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9514. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9515. { } /* end */
  9516. };
  9517. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9518. { 6, alc861vd_6stack_ch6_init },
  9519. { 8, alc861vd_6stack_ch8_init },
  9520. };
  9521. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9522. {
  9523. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9524. .name = "Channel Mode",
  9525. .info = alc_ch_mode_info,
  9526. .get = alc_ch_mode_get,
  9527. .put = alc_ch_mode_put,
  9528. },
  9529. { } /* end */
  9530. };
  9531. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9532. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9533. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9534. {
  9535. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9536. /* The multiple "Capture Source" controls confuse alsamixer
  9537. * So call somewhat different..
  9538. *FIXME: the controls appear in the "playback" view!
  9539. */
  9540. /* .name = "Capture Source", */
  9541. .name = "Input Source",
  9542. .count = 1,
  9543. .info = alc861vd_mux_enum_info,
  9544. .get = alc861vd_mux_enum_get,
  9545. .put = alc861vd_mux_enum_put,
  9546. },
  9547. { } /* end */
  9548. };
  9549. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9550. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9551. */
  9552. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9553. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9554. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9555. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9556. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9557. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9558. HDA_OUTPUT),
  9559. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9560. HDA_OUTPUT),
  9561. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9562. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9563. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9564. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9565. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9566. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9567. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9568. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9569. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9570. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9571. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9572. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9573. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9574. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9575. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9576. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9577. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9578. { } /* end */
  9579. };
  9580. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9581. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9582. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9583. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9584. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9585. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9586. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9587. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9588. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9589. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9590. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9591. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9592. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9593. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9594. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9595. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9596. { } /* end */
  9597. };
  9598. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9599. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9600. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9601. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9602. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9603. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9604. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9605. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9606. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9607. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9608. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9609. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9610. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9611. { } /* end */
  9612. };
  9613. /* Pin assignment: Front=0x14, HP = 0x15,
  9614. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9615. */
  9616. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9617. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9618. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9619. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9620. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9621. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9622. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9623. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9624. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9625. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9626. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9627. { } /* end */
  9628. };
  9629. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9630. * Front Mic=0x18, ATAPI Mic = 0x19,
  9631. */
  9632. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9633. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9634. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9635. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9636. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9637. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9638. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9639. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9640. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9641. { } /* end */
  9642. };
  9643. /*
  9644. * generic initialization of ADC, input mixers and output mixers
  9645. */
  9646. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9647. /*
  9648. * Unmute ADC0 and set the default input to mic-in
  9649. */
  9650. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9651. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9652. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9653. * the analog-loopback mixer widget
  9654. */
  9655. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9659. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9660. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9661. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9662. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9663. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9664. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9665. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9666. /*
  9667. * Set up output mixers (0x02 - 0x05)
  9668. */
  9669. /* set vol=0 to output mixers */
  9670. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9671. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9672. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9673. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9674. /* set up input amps for analog loopback */
  9675. /* Amp Indices: DAC = 0, mixer = 1 */
  9676. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9677. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9678. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9679. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9680. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9681. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9682. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9683. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9684. { }
  9685. };
  9686. /*
  9687. * 3-stack pin configuration:
  9688. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9689. */
  9690. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9691. /*
  9692. * Set pin mode and muting
  9693. */
  9694. /* set front pin widgets 0x14 for output */
  9695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9696. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9697. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9698. /* Mic (rear) pin: input vref at 80% */
  9699. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9700. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9701. /* Front Mic pin: input vref at 80% */
  9702. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9703. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9704. /* Line In pin: input */
  9705. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9706. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9707. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9708. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9709. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9710. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9711. /* CD pin widget for input */
  9712. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9713. { }
  9714. };
  9715. /*
  9716. * 6-stack pin configuration:
  9717. */
  9718. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9719. /*
  9720. * Set pin mode and muting
  9721. */
  9722. /* set front pin widgets 0x14 for output */
  9723. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9724. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9725. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9726. /* Rear Pin: output 1 (0x0d) */
  9727. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9728. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9729. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9730. /* CLFE Pin: output 2 (0x0e) */
  9731. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9732. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9733. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9734. /* Side Pin: output 3 (0x0f) */
  9735. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9736. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9737. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9738. /* Mic (rear) pin: input vref at 80% */
  9739. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9740. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9741. /* Front Mic pin: input vref at 80% */
  9742. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9743. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9744. /* Line In pin: input */
  9745. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9746. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9747. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9748. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9749. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9750. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9751. /* CD pin widget for input */
  9752. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9753. { }
  9754. };
  9755. static struct hda_verb alc861vd_eapd_verbs[] = {
  9756. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9757. { }
  9758. };
  9759. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9760. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9761. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9762. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9763. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9764. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9765. {}
  9766. };
  9767. /* toggle speaker-output according to the hp-jack state */
  9768. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9769. {
  9770. unsigned int present;
  9771. unsigned char bits;
  9772. present = snd_hda_codec_read(codec, 0x1b, 0,
  9773. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9774. bits = present ? HDA_AMP_MUTE : 0;
  9775. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9776. HDA_AMP_MUTE, bits);
  9777. }
  9778. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9779. {
  9780. unsigned int present;
  9781. unsigned char bits;
  9782. present = snd_hda_codec_read(codec, 0x18, 0,
  9783. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9784. bits = present ? HDA_AMP_MUTE : 0;
  9785. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9786. HDA_AMP_MUTE, bits);
  9787. }
  9788. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9789. {
  9790. alc861vd_lenovo_hp_automute(codec);
  9791. alc861vd_lenovo_mic_automute(codec);
  9792. }
  9793. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9794. unsigned int res)
  9795. {
  9796. switch (res >> 26) {
  9797. case ALC880_HP_EVENT:
  9798. alc861vd_lenovo_hp_automute(codec);
  9799. break;
  9800. case ALC880_MIC_EVENT:
  9801. alc861vd_lenovo_mic_automute(codec);
  9802. break;
  9803. }
  9804. }
  9805. static struct hda_verb alc861vd_dallas_verbs[] = {
  9806. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9807. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9808. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9809. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9810. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9811. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9812. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9813. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9814. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9815. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9816. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9817. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9818. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9819. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9821. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9822. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9823. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9824. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9825. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9826. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9827. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9828. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9829. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9830. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9831. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9832. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9833. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9834. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9835. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9837. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9839. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9840. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9841. { } /* end */
  9842. };
  9843. /* toggle speaker-output according to the hp-jack state */
  9844. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9845. {
  9846. unsigned int present;
  9847. present = snd_hda_codec_read(codec, 0x15, 0,
  9848. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9849. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9850. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9851. }
  9852. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9853. {
  9854. if ((res >> 26) == ALC880_HP_EVENT)
  9855. alc861vd_dallas_automute(codec);
  9856. }
  9857. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9858. #define alc861vd_loopbacks alc880_loopbacks
  9859. #endif
  9860. /* pcm configuration: identiacal with ALC880 */
  9861. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9862. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9863. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9864. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9865. /*
  9866. * configuration and preset
  9867. */
  9868. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9869. [ALC660VD_3ST] = "3stack-660",
  9870. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9871. [ALC861VD_3ST] = "3stack",
  9872. [ALC861VD_3ST_DIG] = "3stack-digout",
  9873. [ALC861VD_6ST_DIG] = "6stack-digout",
  9874. [ALC861VD_LENOVO] = "lenovo",
  9875. [ALC861VD_DALLAS] = "dallas",
  9876. [ALC861VD_HP] = "hp",
  9877. [ALC861VD_AUTO] = "auto",
  9878. };
  9879. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9880. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9881. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9882. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9883. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9884. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9885. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9886. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9887. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9888. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9889. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9890. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9891. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9892. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9893. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9894. {}
  9895. };
  9896. static struct alc_config_preset alc861vd_presets[] = {
  9897. [ALC660VD_3ST] = {
  9898. .mixers = { alc861vd_3st_mixer },
  9899. .init_verbs = { alc861vd_volume_init_verbs,
  9900. alc861vd_3stack_init_verbs },
  9901. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9902. .dac_nids = alc660vd_dac_nids,
  9903. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9904. .adc_nids = alc861vd_adc_nids,
  9905. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9906. .channel_mode = alc861vd_3stack_2ch_modes,
  9907. .input_mux = &alc861vd_capture_source,
  9908. },
  9909. [ALC660VD_3ST_DIG] = {
  9910. .mixers = { alc861vd_3st_mixer },
  9911. .init_verbs = { alc861vd_volume_init_verbs,
  9912. alc861vd_3stack_init_verbs },
  9913. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9914. .dac_nids = alc660vd_dac_nids,
  9915. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9916. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9917. .adc_nids = alc861vd_adc_nids,
  9918. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9919. .channel_mode = alc861vd_3stack_2ch_modes,
  9920. .input_mux = &alc861vd_capture_source,
  9921. },
  9922. [ALC861VD_3ST] = {
  9923. .mixers = { alc861vd_3st_mixer },
  9924. .init_verbs = { alc861vd_volume_init_verbs,
  9925. alc861vd_3stack_init_verbs },
  9926. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9927. .dac_nids = alc861vd_dac_nids,
  9928. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9929. .channel_mode = alc861vd_3stack_2ch_modes,
  9930. .input_mux = &alc861vd_capture_source,
  9931. },
  9932. [ALC861VD_3ST_DIG] = {
  9933. .mixers = { alc861vd_3st_mixer },
  9934. .init_verbs = { alc861vd_volume_init_verbs,
  9935. alc861vd_3stack_init_verbs },
  9936. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9937. .dac_nids = alc861vd_dac_nids,
  9938. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9939. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9940. .channel_mode = alc861vd_3stack_2ch_modes,
  9941. .input_mux = &alc861vd_capture_source,
  9942. },
  9943. [ALC861VD_6ST_DIG] = {
  9944. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9945. .init_verbs = { alc861vd_volume_init_verbs,
  9946. alc861vd_6stack_init_verbs },
  9947. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9948. .dac_nids = alc861vd_dac_nids,
  9949. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9950. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9951. .channel_mode = alc861vd_6stack_modes,
  9952. .input_mux = &alc861vd_capture_source,
  9953. },
  9954. [ALC861VD_LENOVO] = {
  9955. .mixers = { alc861vd_lenovo_mixer },
  9956. .init_verbs = { alc861vd_volume_init_verbs,
  9957. alc861vd_3stack_init_verbs,
  9958. alc861vd_eapd_verbs,
  9959. alc861vd_lenovo_unsol_verbs },
  9960. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9961. .dac_nids = alc660vd_dac_nids,
  9962. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9963. .adc_nids = alc861vd_adc_nids,
  9964. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9965. .channel_mode = alc861vd_3stack_2ch_modes,
  9966. .input_mux = &alc861vd_capture_source,
  9967. .unsol_event = alc861vd_lenovo_unsol_event,
  9968. .init_hook = alc861vd_lenovo_automute,
  9969. },
  9970. [ALC861VD_DALLAS] = {
  9971. .mixers = { alc861vd_dallas_mixer },
  9972. .init_verbs = { alc861vd_dallas_verbs },
  9973. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9974. .dac_nids = alc861vd_dac_nids,
  9975. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9976. .adc_nids = alc861vd_adc_nids,
  9977. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9978. .channel_mode = alc861vd_3stack_2ch_modes,
  9979. .input_mux = &alc861vd_dallas_capture_source,
  9980. .unsol_event = alc861vd_dallas_unsol_event,
  9981. .init_hook = alc861vd_dallas_automute,
  9982. },
  9983. [ALC861VD_HP] = {
  9984. .mixers = { alc861vd_hp_mixer },
  9985. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9986. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9987. .dac_nids = alc861vd_dac_nids,
  9988. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9989. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9990. .adc_nids = alc861vd_adc_nids,
  9991. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9992. .channel_mode = alc861vd_3stack_2ch_modes,
  9993. .input_mux = &alc861vd_hp_capture_source,
  9994. .unsol_event = alc861vd_dallas_unsol_event,
  9995. .init_hook = alc861vd_dallas_automute,
  9996. },
  9997. };
  9998. /*
  9999. * BIOS auto configuration
  10000. */
  10001. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10002. hda_nid_t nid, int pin_type, int dac_idx)
  10003. {
  10004. /* set as output */
  10005. snd_hda_codec_write(codec, nid, 0,
  10006. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10007. snd_hda_codec_write(codec, nid, 0,
  10008. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10009. }
  10010. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10011. {
  10012. struct alc_spec *spec = codec->spec;
  10013. int i;
  10014. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10015. for (i = 0; i <= HDA_SIDE; i++) {
  10016. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10017. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10018. if (nid)
  10019. alc861vd_auto_set_output_and_unmute(codec, nid,
  10020. pin_type, i);
  10021. }
  10022. }
  10023. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10024. {
  10025. struct alc_spec *spec = codec->spec;
  10026. hda_nid_t pin;
  10027. pin = spec->autocfg.hp_pins[0];
  10028. if (pin) /* connect to front and use dac 0 */
  10029. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10030. }
  10031. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10032. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10033. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10034. {
  10035. struct alc_spec *spec = codec->spec;
  10036. int i;
  10037. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10038. hda_nid_t nid = spec->autocfg.input_pins[i];
  10039. if (alc861vd_is_input_pin(nid)) {
  10040. snd_hda_codec_write(codec, nid, 0,
  10041. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10042. i <= AUTO_PIN_FRONT_MIC ?
  10043. PIN_VREF80 : PIN_IN);
  10044. if (nid != ALC861VD_PIN_CD_NID)
  10045. snd_hda_codec_write(codec, nid, 0,
  10046. AC_VERB_SET_AMP_GAIN_MUTE,
  10047. AMP_OUT_MUTE);
  10048. }
  10049. }
  10050. }
  10051. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10052. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10053. /* add playback controls from the parsed DAC table */
  10054. /* Based on ALC880 version. But ALC861VD has separate,
  10055. * different NIDs for mute/unmute switch and volume control */
  10056. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10057. const struct auto_pin_cfg *cfg)
  10058. {
  10059. char name[32];
  10060. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10061. hda_nid_t nid_v, nid_s;
  10062. int i, err;
  10063. for (i = 0; i < cfg->line_outs; i++) {
  10064. if (!spec->multiout.dac_nids[i])
  10065. continue;
  10066. nid_v = alc861vd_idx_to_mixer_vol(
  10067. alc880_dac_to_idx(
  10068. spec->multiout.dac_nids[i]));
  10069. nid_s = alc861vd_idx_to_mixer_switch(
  10070. alc880_dac_to_idx(
  10071. spec->multiout.dac_nids[i]));
  10072. if (i == 2) {
  10073. /* Center/LFE */
  10074. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10075. "Center Playback Volume",
  10076. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10077. HDA_OUTPUT));
  10078. if (err < 0)
  10079. return err;
  10080. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10081. "LFE Playback Volume",
  10082. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10083. HDA_OUTPUT));
  10084. if (err < 0)
  10085. return err;
  10086. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10087. "Center Playback Switch",
  10088. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10089. HDA_INPUT));
  10090. if (err < 0)
  10091. return err;
  10092. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10093. "LFE Playback Switch",
  10094. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10095. HDA_INPUT));
  10096. if (err < 0)
  10097. return err;
  10098. } else {
  10099. sprintf(name, "%s Playback Volume", chname[i]);
  10100. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10101. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10102. HDA_OUTPUT));
  10103. if (err < 0)
  10104. return err;
  10105. sprintf(name, "%s Playback Switch", chname[i]);
  10106. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10107. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10108. HDA_INPUT));
  10109. if (err < 0)
  10110. return err;
  10111. }
  10112. }
  10113. return 0;
  10114. }
  10115. /* add playback controls for speaker and HP outputs */
  10116. /* Based on ALC880 version. But ALC861VD has separate,
  10117. * different NIDs for mute/unmute switch and volume control */
  10118. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10119. hda_nid_t pin, const char *pfx)
  10120. {
  10121. hda_nid_t nid_v, nid_s;
  10122. int err;
  10123. char name[32];
  10124. if (!pin)
  10125. return 0;
  10126. if (alc880_is_fixed_pin(pin)) {
  10127. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10128. /* specify the DAC as the extra output */
  10129. if (!spec->multiout.hp_nid)
  10130. spec->multiout.hp_nid = nid_v;
  10131. else
  10132. spec->multiout.extra_out_nid[0] = nid_v;
  10133. /* control HP volume/switch on the output mixer amp */
  10134. nid_v = alc861vd_idx_to_mixer_vol(
  10135. alc880_fixed_pin_idx(pin));
  10136. nid_s = alc861vd_idx_to_mixer_switch(
  10137. alc880_fixed_pin_idx(pin));
  10138. sprintf(name, "%s Playback Volume", pfx);
  10139. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10140. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10141. if (err < 0)
  10142. return err;
  10143. sprintf(name, "%s Playback Switch", pfx);
  10144. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10145. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10146. if (err < 0)
  10147. return err;
  10148. } else if (alc880_is_multi_pin(pin)) {
  10149. /* set manual connection */
  10150. /* we have only a switch on HP-out PIN */
  10151. sprintf(name, "%s Playback Switch", pfx);
  10152. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10153. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10154. if (err < 0)
  10155. return err;
  10156. }
  10157. return 0;
  10158. }
  10159. /* parse the BIOS configuration and set up the alc_spec
  10160. * return 1 if successful, 0 if the proper config is not found,
  10161. * or a negative error code
  10162. * Based on ALC880 version - had to change it to override
  10163. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10164. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10165. {
  10166. struct alc_spec *spec = codec->spec;
  10167. int err;
  10168. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10169. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10170. alc861vd_ignore);
  10171. if (err < 0)
  10172. return err;
  10173. if (!spec->autocfg.line_outs)
  10174. return 0; /* can't find valid BIOS pin config */
  10175. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10176. if (err < 0)
  10177. return err;
  10178. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10179. if (err < 0)
  10180. return err;
  10181. err = alc861vd_auto_create_extra_out(spec,
  10182. spec->autocfg.speaker_pins[0],
  10183. "Speaker");
  10184. if (err < 0)
  10185. return err;
  10186. err = alc861vd_auto_create_extra_out(spec,
  10187. spec->autocfg.hp_pins[0],
  10188. "Headphone");
  10189. if (err < 0)
  10190. return err;
  10191. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10192. if (err < 0)
  10193. return err;
  10194. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10195. if (spec->autocfg.dig_out_pin)
  10196. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10197. if (spec->kctl_alloc)
  10198. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10199. spec->init_verbs[spec->num_init_verbs++]
  10200. = alc861vd_volume_init_verbs;
  10201. spec->num_mux_defs = 1;
  10202. spec->input_mux = &spec->private_imux;
  10203. err = alc_auto_add_mic_boost(codec);
  10204. if (err < 0)
  10205. return err;
  10206. return 1;
  10207. }
  10208. /* additional initialization for auto-configuration model */
  10209. static void alc861vd_auto_init(struct hda_codec *codec)
  10210. {
  10211. alc861vd_auto_init_multi_out(codec);
  10212. alc861vd_auto_init_hp_out(codec);
  10213. alc861vd_auto_init_analog_input(codec);
  10214. }
  10215. static int patch_alc861vd(struct hda_codec *codec)
  10216. {
  10217. struct alc_spec *spec;
  10218. int err, board_config;
  10219. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10220. if (spec == NULL)
  10221. return -ENOMEM;
  10222. codec->spec = spec;
  10223. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10224. alc861vd_models,
  10225. alc861vd_cfg_tbl);
  10226. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10227. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10228. "ALC861VD, trying auto-probe from BIOS...\n");
  10229. board_config = ALC861VD_AUTO;
  10230. }
  10231. if (board_config == ALC861VD_AUTO) {
  10232. /* automatic parse from the BIOS config */
  10233. err = alc861vd_parse_auto_config(codec);
  10234. if (err < 0) {
  10235. alc_free(codec);
  10236. return err;
  10237. } else if (!err) {
  10238. printk(KERN_INFO
  10239. "hda_codec: Cannot set up configuration "
  10240. "from BIOS. Using base mode...\n");
  10241. board_config = ALC861VD_3ST;
  10242. }
  10243. }
  10244. if (board_config != ALC861VD_AUTO)
  10245. setup_preset(spec, &alc861vd_presets[board_config]);
  10246. spec->stream_name_analog = "ALC861VD Analog";
  10247. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10248. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10249. spec->stream_name_digital = "ALC861VD Digital";
  10250. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10251. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10252. spec->adc_nids = alc861vd_adc_nids;
  10253. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10254. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10255. spec->num_mixers++;
  10256. codec->patch_ops = alc_patch_ops;
  10257. if (board_config == ALC861VD_AUTO)
  10258. spec->init_hook = alc861vd_auto_init;
  10259. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10260. if (!spec->loopback.amplist)
  10261. spec->loopback.amplist = alc861vd_loopbacks;
  10262. #endif
  10263. return 0;
  10264. }
  10265. /*
  10266. * ALC662 support
  10267. *
  10268. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10269. * configuration. Each pin widget can choose any input DACs and a mixer.
  10270. * Each ADC is connected from a mixer of all inputs. This makes possible
  10271. * 6-channel independent captures.
  10272. *
  10273. * In addition, an independent DAC for the multi-playback (not used in this
  10274. * driver yet).
  10275. */
  10276. #define ALC662_DIGOUT_NID 0x06
  10277. #define ALC662_DIGIN_NID 0x0a
  10278. static hda_nid_t alc662_dac_nids[4] = {
  10279. /* front, rear, clfe, rear_surr */
  10280. 0x02, 0x03, 0x04
  10281. };
  10282. static hda_nid_t alc662_adc_nids[1] = {
  10283. /* ADC1-2 */
  10284. 0x09,
  10285. };
  10286. /* input MUX */
  10287. /* FIXME: should be a matrix-type input source selection */
  10288. static struct hda_input_mux alc662_capture_source = {
  10289. .num_items = 4,
  10290. .items = {
  10291. { "Mic", 0x0 },
  10292. { "Front Mic", 0x1 },
  10293. { "Line", 0x2 },
  10294. { "CD", 0x4 },
  10295. },
  10296. };
  10297. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10298. .num_items = 2,
  10299. .items = {
  10300. { "Mic", 0x1 },
  10301. { "Line", 0x2 },
  10302. },
  10303. };
  10304. #define alc662_mux_enum_info alc_mux_enum_info
  10305. #define alc662_mux_enum_get alc_mux_enum_get
  10306. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10307. struct snd_ctl_elem_value *ucontrol)
  10308. {
  10309. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10310. struct alc_spec *spec = codec->spec;
  10311. const struct hda_input_mux *imux = spec->input_mux;
  10312. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10313. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10314. hda_nid_t nid = capture_mixers[adc_idx];
  10315. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10316. unsigned int i, idx;
  10317. idx = ucontrol->value.enumerated.item[0];
  10318. if (idx >= imux->num_items)
  10319. idx = imux->num_items - 1;
  10320. if (*cur_val == idx)
  10321. return 0;
  10322. for (i = 0; i < imux->num_items; i++) {
  10323. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10324. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10325. imux->items[i].index,
  10326. HDA_AMP_MUTE, v);
  10327. }
  10328. *cur_val = idx;
  10329. return 1;
  10330. }
  10331. /*
  10332. * 2ch mode
  10333. */
  10334. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10335. { 2, NULL }
  10336. };
  10337. /*
  10338. * 2ch mode
  10339. */
  10340. static struct hda_verb alc662_3ST_ch2_init[] = {
  10341. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10342. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10343. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10344. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10345. { } /* end */
  10346. };
  10347. /*
  10348. * 6ch mode
  10349. */
  10350. static struct hda_verb alc662_3ST_ch6_init[] = {
  10351. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10352. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10353. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10354. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10355. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10356. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10357. { } /* end */
  10358. };
  10359. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10360. { 2, alc662_3ST_ch2_init },
  10361. { 6, alc662_3ST_ch6_init },
  10362. };
  10363. /*
  10364. * 2ch mode
  10365. */
  10366. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10367. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10368. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10369. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10370. { } /* end */
  10371. };
  10372. /*
  10373. * 6ch mode
  10374. */
  10375. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10376. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10377. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10378. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10379. { } /* end */
  10380. };
  10381. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10382. { 2, alc662_sixstack_ch6_init },
  10383. { 6, alc662_sixstack_ch8_init },
  10384. };
  10385. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10386. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10387. */
  10388. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10389. /* output mixer control */
  10390. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10391. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10392. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10393. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10394. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10395. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10396. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10397. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10398. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10399. /*Input mixer control */
  10400. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10401. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10402. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10403. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10404. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10405. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10406. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10407. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10408. /* Capture mixer control */
  10409. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10410. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10411. {
  10412. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10413. .name = "Capture Source",
  10414. .count = 1,
  10415. .info = alc_mux_enum_info,
  10416. .get = alc_mux_enum_get,
  10417. .put = alc_mux_enum_put,
  10418. },
  10419. { } /* end */
  10420. };
  10421. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10422. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10423. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10424. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10425. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10426. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10427. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10428. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10429. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10430. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10431. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10432. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10433. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10434. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10435. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10436. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10437. {
  10438. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10439. /* .name = "Capture Source", */
  10440. .name = "Input Source",
  10441. .count = 1,
  10442. .info = alc662_mux_enum_info,
  10443. .get = alc662_mux_enum_get,
  10444. .put = alc662_mux_enum_put,
  10445. },
  10446. { } /* end */
  10447. };
  10448. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10449. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10450. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10451. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10452. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10453. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10454. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10455. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10456. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10457. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10458. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10459. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10460. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10461. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10462. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10463. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10464. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10465. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10466. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10467. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10468. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10469. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10470. {
  10471. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10472. /* .name = "Capture Source", */
  10473. .name = "Input Source",
  10474. .count = 1,
  10475. .info = alc662_mux_enum_info,
  10476. .get = alc662_mux_enum_get,
  10477. .put = alc662_mux_enum_put,
  10478. },
  10479. { } /* end */
  10480. };
  10481. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10482. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10483. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10484. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10485. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10486. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10487. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10488. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10489. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10490. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10491. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10492. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10493. {
  10494. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10495. /* .name = "Capture Source", */
  10496. .name = "Input Source",
  10497. .count = 1,
  10498. .info = alc662_mux_enum_info,
  10499. .get = alc662_mux_enum_get,
  10500. .put = alc662_mux_enum_put,
  10501. },
  10502. { } /* end */
  10503. };
  10504. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10505. {
  10506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10507. .name = "Channel Mode",
  10508. .info = alc_ch_mode_info,
  10509. .get = alc_ch_mode_get,
  10510. .put = alc_ch_mode_put,
  10511. },
  10512. { } /* end */
  10513. };
  10514. static struct hda_verb alc662_init_verbs[] = {
  10515. /* ADC: mute amp left and right */
  10516. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10517. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10518. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10519. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10520. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10521. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10522. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10523. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10524. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10525. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10526. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10527. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10528. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10529. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10530. /* Front Pin: output 0 (0x0c) */
  10531. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10532. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10533. /* Rear Pin: output 1 (0x0d) */
  10534. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10535. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10536. /* CLFE Pin: output 2 (0x0e) */
  10537. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10538. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10539. /* Mic (rear) pin: input vref at 80% */
  10540. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10541. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10542. /* Front Mic pin: input vref at 80% */
  10543. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10544. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10545. /* Line In pin: input */
  10546. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10547. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10548. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10549. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10550. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10551. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10552. /* CD pin widget for input */
  10553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10554. /* FIXME: use matrix-type input source selection */
  10555. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10556. /* Input mixer */
  10557. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10558. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10559. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10560. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10561. { }
  10562. };
  10563. static struct hda_verb alc662_sue_init_verbs[] = {
  10564. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10565. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10566. {}
  10567. };
  10568. /*
  10569. * generic initialization of ADC, input mixers and output mixers
  10570. */
  10571. static struct hda_verb alc662_auto_init_verbs[] = {
  10572. /*
  10573. * Unmute ADC and set the default input to mic-in
  10574. */
  10575. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10576. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10577. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10578. * mixer widget
  10579. * Note: PASD motherboards uses the Line In 2 as the input for front
  10580. * panel mic (mic 2)
  10581. */
  10582. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10583. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10584. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10586. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10587. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10588. /*
  10589. * Set up output mixers (0x0c - 0x0f)
  10590. */
  10591. /* set vol=0 to output mixers */
  10592. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10593. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10594. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10595. /* set up input amps for analog loopback */
  10596. /* Amp Indices: DAC = 0, mixer = 1 */
  10597. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10598. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10599. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10600. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10601. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10602. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10603. /* FIXME: use matrix-type input source selection */
  10604. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10605. /* Input mixer */
  10606. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10607. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10608. { }
  10609. };
  10610. /* capture mixer elements */
  10611. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10612. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10613. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10614. {
  10615. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10616. /* The multiple "Capture Source" controls confuse alsamixer
  10617. * So call somewhat different..
  10618. * FIXME: the controls appear in the "playback" view!
  10619. */
  10620. /* .name = "Capture Source", */
  10621. .name = "Input Source",
  10622. .count = 1,
  10623. .info = alc882_mux_enum_info,
  10624. .get = alc882_mux_enum_get,
  10625. .put = alc882_mux_enum_put,
  10626. },
  10627. { } /* end */
  10628. };
  10629. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10630. {
  10631. unsigned int present;
  10632. unsigned char bits;
  10633. present = snd_hda_codec_read(codec, 0x14, 0,
  10634. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10635. bits = present ? HDA_AMP_MUTE : 0;
  10636. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10637. HDA_AMP_MUTE, bits);
  10638. }
  10639. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10640. {
  10641. unsigned int present;
  10642. unsigned char bits;
  10643. present = snd_hda_codec_read(codec, 0x1b, 0,
  10644. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10645. bits = present ? HDA_AMP_MUTE : 0;
  10646. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10647. HDA_AMP_MUTE, bits);
  10648. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10649. HDA_AMP_MUTE, bits);
  10650. }
  10651. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10652. unsigned int res)
  10653. {
  10654. if ((res >> 26) == ALC880_HP_EVENT)
  10655. alc662_lenovo_101e_all_automute(codec);
  10656. if ((res >> 26) == ALC880_FRONT_EVENT)
  10657. alc662_lenovo_101e_ispeaker_automute(codec);
  10658. }
  10659. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10660. #define alc662_loopbacks alc880_loopbacks
  10661. #endif
  10662. /* pcm configuration: identiacal with ALC880 */
  10663. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10664. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10665. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10666. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10667. /*
  10668. * configuration and preset
  10669. */
  10670. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10671. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10672. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10673. [ALC662_3ST_6ch] = "3stack-6ch",
  10674. [ALC662_5ST_DIG] = "6stack-dig",
  10675. [ALC662_LENOVO_101E] = "lenovo-101e",
  10676. [ALC662_AUTO] = "auto",
  10677. };
  10678. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10679. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10680. {}
  10681. };
  10682. static struct alc_config_preset alc662_presets[] = {
  10683. [ALC662_3ST_2ch_DIG] = {
  10684. .mixers = { alc662_3ST_2ch_mixer },
  10685. .init_verbs = { alc662_init_verbs },
  10686. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10687. .dac_nids = alc662_dac_nids,
  10688. .dig_out_nid = ALC662_DIGOUT_NID,
  10689. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10690. .adc_nids = alc662_adc_nids,
  10691. .dig_in_nid = ALC662_DIGIN_NID,
  10692. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10693. .channel_mode = alc662_3ST_2ch_modes,
  10694. .input_mux = &alc662_capture_source,
  10695. },
  10696. [ALC662_3ST_6ch_DIG] = {
  10697. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10698. .init_verbs = { alc662_init_verbs },
  10699. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10700. .dac_nids = alc662_dac_nids,
  10701. .dig_out_nid = ALC662_DIGOUT_NID,
  10702. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10703. .adc_nids = alc662_adc_nids,
  10704. .dig_in_nid = ALC662_DIGIN_NID,
  10705. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10706. .channel_mode = alc662_3ST_6ch_modes,
  10707. .need_dac_fix = 1,
  10708. .input_mux = &alc662_capture_source,
  10709. },
  10710. [ALC662_3ST_6ch] = {
  10711. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10712. .init_verbs = { alc662_init_verbs },
  10713. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10714. .dac_nids = alc662_dac_nids,
  10715. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10716. .adc_nids = alc662_adc_nids,
  10717. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10718. .channel_mode = alc662_3ST_6ch_modes,
  10719. .need_dac_fix = 1,
  10720. .input_mux = &alc662_capture_source,
  10721. },
  10722. [ALC662_5ST_DIG] = {
  10723. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10724. .init_verbs = { alc662_init_verbs },
  10725. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10726. .dac_nids = alc662_dac_nids,
  10727. .dig_out_nid = ALC662_DIGOUT_NID,
  10728. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10729. .adc_nids = alc662_adc_nids,
  10730. .dig_in_nid = ALC662_DIGIN_NID,
  10731. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10732. .channel_mode = alc662_5stack_modes,
  10733. .input_mux = &alc662_capture_source,
  10734. },
  10735. [ALC662_LENOVO_101E] = {
  10736. .mixers = { alc662_lenovo_101e_mixer },
  10737. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10738. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10739. .dac_nids = alc662_dac_nids,
  10740. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10741. .adc_nids = alc662_adc_nids,
  10742. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10743. .channel_mode = alc662_3ST_2ch_modes,
  10744. .input_mux = &alc662_lenovo_101e_capture_source,
  10745. .unsol_event = alc662_lenovo_101e_unsol_event,
  10746. .init_hook = alc662_lenovo_101e_all_automute,
  10747. },
  10748. };
  10749. /*
  10750. * BIOS auto configuration
  10751. */
  10752. /* add playback controls from the parsed DAC table */
  10753. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10754. const struct auto_pin_cfg *cfg)
  10755. {
  10756. char name[32];
  10757. static const char *chname[4] = {
  10758. "Front", "Surround", NULL /*CLFE*/, "Side"
  10759. };
  10760. hda_nid_t nid;
  10761. int i, err;
  10762. for (i = 0; i < cfg->line_outs; i++) {
  10763. if (!spec->multiout.dac_nids[i])
  10764. continue;
  10765. nid = alc880_idx_to_mixer(i);
  10766. if (i == 2) {
  10767. /* Center/LFE */
  10768. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10769. "Center Playback Volume",
  10770. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10771. HDA_OUTPUT));
  10772. if (err < 0)
  10773. return err;
  10774. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10775. "LFE Playback Volume",
  10776. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10777. HDA_OUTPUT));
  10778. if (err < 0)
  10779. return err;
  10780. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10781. "Center Playback Switch",
  10782. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10783. HDA_INPUT));
  10784. if (err < 0)
  10785. return err;
  10786. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10787. "LFE Playback Switch",
  10788. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10789. HDA_INPUT));
  10790. if (err < 0)
  10791. return err;
  10792. } else {
  10793. sprintf(name, "%s Playback Volume", chname[i]);
  10794. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10795. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10796. HDA_OUTPUT));
  10797. if (err < 0)
  10798. return err;
  10799. sprintf(name, "%s Playback Switch", chname[i]);
  10800. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10801. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10802. HDA_INPUT));
  10803. if (err < 0)
  10804. return err;
  10805. }
  10806. }
  10807. return 0;
  10808. }
  10809. /* add playback controls for speaker and HP outputs */
  10810. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10811. const char *pfx)
  10812. {
  10813. hda_nid_t nid;
  10814. int err;
  10815. char name[32];
  10816. if (!pin)
  10817. return 0;
  10818. if (alc880_is_fixed_pin(pin)) {
  10819. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10820. /* printk("DAC nid=%x\n",nid); */
  10821. /* specify the DAC as the extra output */
  10822. if (!spec->multiout.hp_nid)
  10823. spec->multiout.hp_nid = nid;
  10824. else
  10825. spec->multiout.extra_out_nid[0] = nid;
  10826. /* control HP volume/switch on the output mixer amp */
  10827. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10828. sprintf(name, "%s Playback Volume", pfx);
  10829. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10830. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10831. if (err < 0)
  10832. return err;
  10833. sprintf(name, "%s Playback Switch", pfx);
  10834. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10835. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10836. if (err < 0)
  10837. return err;
  10838. } else if (alc880_is_multi_pin(pin)) {
  10839. /* set manual connection */
  10840. /* we have only a switch on HP-out PIN */
  10841. sprintf(name, "%s Playback Switch", pfx);
  10842. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10843. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10844. if (err < 0)
  10845. return err;
  10846. }
  10847. return 0;
  10848. }
  10849. /* create playback/capture controls for input pins */
  10850. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10851. const struct auto_pin_cfg *cfg)
  10852. {
  10853. struct hda_input_mux *imux = &spec->private_imux;
  10854. int i, err, idx;
  10855. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10856. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10857. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10858. err = new_analog_input(spec, cfg->input_pins[i],
  10859. auto_pin_cfg_labels[i],
  10860. idx, 0x0b);
  10861. if (err < 0)
  10862. return err;
  10863. imux->items[imux->num_items].label =
  10864. auto_pin_cfg_labels[i];
  10865. imux->items[imux->num_items].index =
  10866. alc880_input_pin_idx(cfg->input_pins[i]);
  10867. imux->num_items++;
  10868. }
  10869. }
  10870. return 0;
  10871. }
  10872. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10873. hda_nid_t nid, int pin_type,
  10874. int dac_idx)
  10875. {
  10876. /* set as output */
  10877. snd_hda_codec_write(codec, nid, 0,
  10878. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10879. snd_hda_codec_write(codec, nid, 0,
  10880. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10881. /* need the manual connection? */
  10882. if (alc880_is_multi_pin(nid)) {
  10883. struct alc_spec *spec = codec->spec;
  10884. int idx = alc880_multi_pin_idx(nid);
  10885. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10886. AC_VERB_SET_CONNECT_SEL,
  10887. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10888. }
  10889. }
  10890. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10891. {
  10892. struct alc_spec *spec = codec->spec;
  10893. int i;
  10894. for (i = 0; i <= HDA_SIDE; i++) {
  10895. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10896. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10897. if (nid)
  10898. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10899. i);
  10900. }
  10901. }
  10902. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10903. {
  10904. struct alc_spec *spec = codec->spec;
  10905. hda_nid_t pin;
  10906. pin = spec->autocfg.hp_pins[0];
  10907. if (pin) /* connect to front */
  10908. /* use dac 0 */
  10909. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10910. }
  10911. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10912. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10913. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10914. {
  10915. struct alc_spec *spec = codec->spec;
  10916. int i;
  10917. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10918. hda_nid_t nid = spec->autocfg.input_pins[i];
  10919. if (alc662_is_input_pin(nid)) {
  10920. snd_hda_codec_write(codec, nid, 0,
  10921. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10922. (i <= AUTO_PIN_FRONT_MIC ?
  10923. PIN_VREF80 : PIN_IN));
  10924. if (nid != ALC662_PIN_CD_NID)
  10925. snd_hda_codec_write(codec, nid, 0,
  10926. AC_VERB_SET_AMP_GAIN_MUTE,
  10927. AMP_OUT_MUTE);
  10928. }
  10929. }
  10930. }
  10931. static int alc662_parse_auto_config(struct hda_codec *codec)
  10932. {
  10933. struct alc_spec *spec = codec->spec;
  10934. int err;
  10935. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10936. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10937. alc662_ignore);
  10938. if (err < 0)
  10939. return err;
  10940. if (!spec->autocfg.line_outs)
  10941. return 0; /* can't find valid BIOS pin config */
  10942. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10943. if (err < 0)
  10944. return err;
  10945. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10946. if (err < 0)
  10947. return err;
  10948. err = alc662_auto_create_extra_out(spec,
  10949. spec->autocfg.speaker_pins[0],
  10950. "Speaker");
  10951. if (err < 0)
  10952. return err;
  10953. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10954. "Headphone");
  10955. if (err < 0)
  10956. return err;
  10957. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10958. if (err < 0)
  10959. return err;
  10960. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10961. if (spec->autocfg.dig_out_pin)
  10962. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10963. if (spec->kctl_alloc)
  10964. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10965. spec->num_mux_defs = 1;
  10966. spec->input_mux = &spec->private_imux;
  10967. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10968. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10969. spec->num_mixers++;
  10970. return 1;
  10971. }
  10972. /* additional initialization for auto-configuration model */
  10973. static void alc662_auto_init(struct hda_codec *codec)
  10974. {
  10975. alc662_auto_init_multi_out(codec);
  10976. alc662_auto_init_hp_out(codec);
  10977. alc662_auto_init_analog_input(codec);
  10978. }
  10979. static int patch_alc662(struct hda_codec *codec)
  10980. {
  10981. struct alc_spec *spec;
  10982. int err, board_config;
  10983. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10984. if (!spec)
  10985. return -ENOMEM;
  10986. codec->spec = spec;
  10987. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10988. alc662_models,
  10989. alc662_cfg_tbl);
  10990. if (board_config < 0) {
  10991. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10992. "trying auto-probe from BIOS...\n");
  10993. board_config = ALC662_AUTO;
  10994. }
  10995. if (board_config == ALC662_AUTO) {
  10996. /* automatic parse from the BIOS config */
  10997. err = alc662_parse_auto_config(codec);
  10998. if (err < 0) {
  10999. alc_free(codec);
  11000. return err;
  11001. } else if (!err) {
  11002. printk(KERN_INFO
  11003. "hda_codec: Cannot set up configuration "
  11004. "from BIOS. Using base mode...\n");
  11005. board_config = ALC662_3ST_2ch_DIG;
  11006. }
  11007. }
  11008. if (board_config != ALC662_AUTO)
  11009. setup_preset(spec, &alc662_presets[board_config]);
  11010. spec->stream_name_analog = "ALC662 Analog";
  11011. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11012. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11013. spec->stream_name_digital = "ALC662 Digital";
  11014. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11015. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11016. if (!spec->adc_nids && spec->input_mux) {
  11017. spec->adc_nids = alc662_adc_nids;
  11018. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11019. }
  11020. codec->patch_ops = alc_patch_ops;
  11021. if (board_config == ALC662_AUTO)
  11022. spec->init_hook = alc662_auto_init;
  11023. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11024. if (!spec->loopback.amplist)
  11025. spec->loopback.amplist = alc662_loopbacks;
  11026. #endif
  11027. return 0;
  11028. }
  11029. /*
  11030. * patch entries
  11031. */
  11032. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11033. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11034. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11035. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11036. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11037. .patch = patch_alc861 },
  11038. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11039. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11040. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11041. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11042. .patch = patch_alc883 },
  11043. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11044. .patch = patch_alc662 },
  11045. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11046. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11047. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11048. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11049. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11050. {} /* terminator */
  11051. };