patch_realtek.c 415 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577
  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_ULTRA,
  94. ALC262_AUTO,
  95. ALC262_MODEL_LAST /* last tag */
  96. };
  97. /* ALC268 models */
  98. enum {
  99. ALC268_3ST,
  100. ALC268_TOSHIBA,
  101. ALC268_ACER,
  102. ALC268_AUTO,
  103. ALC268_MODEL_LAST /* last tag */
  104. };
  105. /* ALC861 models */
  106. enum {
  107. ALC861_3ST,
  108. ALC660_3ST,
  109. ALC861_3ST_DIG,
  110. ALC861_6ST_DIG,
  111. ALC861_UNIWILL_M31,
  112. ALC861_TOSHIBA,
  113. ALC861_ASUS,
  114. ALC861_ASUS_LAPTOP,
  115. ALC861_AUTO,
  116. ALC861_MODEL_LAST,
  117. };
  118. /* ALC861-VD models */
  119. enum {
  120. ALC660VD_3ST,
  121. ALC660VD_3ST_DIG,
  122. ALC861VD_3ST,
  123. ALC861VD_3ST_DIG,
  124. ALC861VD_6ST_DIG,
  125. ALC861VD_LENOVO,
  126. ALC861VD_DALLAS,
  127. ALC861VD_HP,
  128. ALC861VD_AUTO,
  129. ALC861VD_MODEL_LAST,
  130. };
  131. /* ALC662 models */
  132. enum {
  133. ALC662_3ST_2ch_DIG,
  134. ALC662_3ST_6ch_DIG,
  135. ALC662_3ST_6ch,
  136. ALC662_5ST_DIG,
  137. ALC662_LENOVO_101E,
  138. ALC662_ASUS_EEEPC_P701,
  139. ALC662_AUTO,
  140. ALC662_MODEL_LAST,
  141. };
  142. /* ALC882 models */
  143. enum {
  144. ALC882_3ST_DIG,
  145. ALC882_6ST_DIG,
  146. ALC882_ARIMA,
  147. ALC882_W2JC,
  148. ALC882_TARGA,
  149. ALC882_ASUS_A7J,
  150. ALC882_ASUS_A7M,
  151. ALC885_MACPRO,
  152. ALC885_MBP3,
  153. ALC885_IMAC24,
  154. ALC882_AUTO,
  155. ALC882_MODEL_LAST,
  156. };
  157. /* ALC883 models */
  158. enum {
  159. ALC883_3ST_2ch_DIG,
  160. ALC883_3ST_6ch_DIG,
  161. ALC883_3ST_6ch,
  162. ALC883_6ST_DIG,
  163. ALC883_TARGA_DIG,
  164. ALC883_TARGA_2ch_DIG,
  165. ALC883_ACER,
  166. ALC883_ACER_ASPIRE,
  167. ALC883_MEDION,
  168. ALC883_MEDION_MD2,
  169. ALC883_LAPTOP_EAPD,
  170. ALC883_LENOVO_101E_2ch,
  171. ALC883_LENOVO_NB0763,
  172. ALC888_LENOVO_MS7195_DIG,
  173. ALC883_HAIER_W66,
  174. ALC888_6ST_HP,
  175. ALC888_3ST_HP,
  176. ALC883_AUTO,
  177. ALC883_MODEL_LAST,
  178. };
  179. /* for GPIO Poll */
  180. #define GPIO_MASK 0x03
  181. struct alc_spec {
  182. /* codec parameterization */
  183. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  184. unsigned int num_mixers;
  185. const struct hda_verb *init_verbs[5]; /* initialization verbs
  186. * don't forget NULL
  187. * termination!
  188. */
  189. unsigned int num_init_verbs;
  190. char *stream_name_analog; /* analog PCM stream */
  191. struct hda_pcm_stream *stream_analog_playback;
  192. struct hda_pcm_stream *stream_analog_capture;
  193. char *stream_name_digital; /* digital PCM stream */
  194. struct hda_pcm_stream *stream_digital_playback;
  195. struct hda_pcm_stream *stream_digital_capture;
  196. /* playback */
  197. struct hda_multi_out multiout; /* playback set-up
  198. * max_channels, dacs must be set
  199. * dig_out_nid and hp_nid are optional
  200. */
  201. /* capture */
  202. unsigned int num_adc_nids;
  203. hda_nid_t *adc_nids;
  204. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  205. /* capture source */
  206. unsigned int num_mux_defs;
  207. const struct hda_input_mux *input_mux;
  208. unsigned int cur_mux[3];
  209. /* channel model */
  210. const struct hda_channel_mode *channel_mode;
  211. int num_channel_mode;
  212. int need_dac_fix;
  213. /* PCM information */
  214. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  215. /* dynamic controls, init_verbs and input_mux */
  216. struct auto_pin_cfg autocfg;
  217. unsigned int num_kctl_alloc, num_kctl_used;
  218. struct snd_kcontrol_new *kctl_alloc;
  219. struct hda_input_mux private_imux;
  220. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  221. /* hooks */
  222. void (*init_hook)(struct hda_codec *codec);
  223. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  224. /* for pin sensing */
  225. unsigned int sense_updated: 1;
  226. unsigned int jack_present: 1;
  227. #ifdef CONFIG_SND_HDA_POWER_SAVE
  228. struct hda_loopback_check loopback;
  229. #endif
  230. };
  231. /*
  232. * configuration template - to be copied to the spec instance
  233. */
  234. struct alc_config_preset {
  235. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  236. * with spec
  237. */
  238. const struct hda_verb *init_verbs[5];
  239. unsigned int num_dacs;
  240. hda_nid_t *dac_nids;
  241. hda_nid_t dig_out_nid; /* optional */
  242. hda_nid_t hp_nid; /* optional */
  243. unsigned int num_adc_nids;
  244. hda_nid_t *adc_nids;
  245. hda_nid_t dig_in_nid;
  246. unsigned int num_channel_mode;
  247. const struct hda_channel_mode *channel_mode;
  248. int need_dac_fix;
  249. unsigned int num_mux_defs;
  250. const struct hda_input_mux *input_mux;
  251. void (*unsol_event)(struct hda_codec *, unsigned int);
  252. void (*init_hook)(struct hda_codec *);
  253. #ifdef CONFIG_SND_HDA_POWER_SAVE
  254. struct hda_amp_list *loopbacks;
  255. #endif
  256. };
  257. /*
  258. * input MUX handling
  259. */
  260. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_info *uinfo)
  262. {
  263. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  264. struct alc_spec *spec = codec->spec;
  265. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  266. if (mux_idx >= spec->num_mux_defs)
  267. mux_idx = 0;
  268. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  269. }
  270. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  271. struct snd_ctl_elem_value *ucontrol)
  272. {
  273. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  274. struct alc_spec *spec = codec->spec;
  275. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  276. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  277. return 0;
  278. }
  279. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  280. struct snd_ctl_elem_value *ucontrol)
  281. {
  282. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  283. struct alc_spec *spec = codec->spec;
  284. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  285. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  286. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  287. spec->adc_nids[adc_idx],
  288. &spec->cur_mux[adc_idx]);
  289. }
  290. /*
  291. * channel mode setting
  292. */
  293. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  294. struct snd_ctl_elem_info *uinfo)
  295. {
  296. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  297. struct alc_spec *spec = codec->spec;
  298. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  299. spec->num_channel_mode);
  300. }
  301. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  302. struct snd_ctl_elem_value *ucontrol)
  303. {
  304. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  305. struct alc_spec *spec = codec->spec;
  306. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  307. spec->num_channel_mode,
  308. spec->multiout.max_channels);
  309. }
  310. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  311. struct snd_ctl_elem_value *ucontrol)
  312. {
  313. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  314. struct alc_spec *spec = codec->spec;
  315. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  316. spec->num_channel_mode,
  317. &spec->multiout.max_channels);
  318. if (err >= 0 && spec->need_dac_fix)
  319. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  320. return err;
  321. }
  322. /*
  323. * Control the mode of pin widget settings via the mixer. "pc" is used
  324. * instead of "%" to avoid consequences of accidently treating the % as
  325. * being part of a format specifier. Maximum allowed length of a value is
  326. * 63 characters plus NULL terminator.
  327. *
  328. * Note: some retasking pin complexes seem to ignore requests for input
  329. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  330. * are requested. Therefore order this list so that this behaviour will not
  331. * cause problems when mixer clients move through the enum sequentially.
  332. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  333. * March 2006.
  334. */
  335. static char *alc_pin_mode_names[] = {
  336. "Mic 50pc bias", "Mic 80pc bias",
  337. "Line in", "Line out", "Headphone out",
  338. };
  339. static unsigned char alc_pin_mode_values[] = {
  340. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  341. };
  342. /* The control can present all 5 options, or it can limit the options based
  343. * in the pin being assumed to be exclusively an input or an output pin. In
  344. * addition, "input" pins may or may not process the mic bias option
  345. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  346. * accept requests for bias as of chip versions up to March 2006) and/or
  347. * wiring in the computer.
  348. */
  349. #define ALC_PIN_DIR_IN 0x00
  350. #define ALC_PIN_DIR_OUT 0x01
  351. #define ALC_PIN_DIR_INOUT 0x02
  352. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  353. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  354. /* Info about the pin modes supported by the different pin direction modes.
  355. * For each direction the minimum and maximum values are given.
  356. */
  357. static signed char alc_pin_mode_dir_info[5][2] = {
  358. { 0, 2 }, /* ALC_PIN_DIR_IN */
  359. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  360. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  361. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  362. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  363. };
  364. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  365. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  366. #define alc_pin_mode_n_items(_dir) \
  367. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  368. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  369. struct snd_ctl_elem_info *uinfo)
  370. {
  371. unsigned int item_num = uinfo->value.enumerated.item;
  372. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  373. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  374. uinfo->count = 1;
  375. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  376. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  377. item_num = alc_pin_mode_min(dir);
  378. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  379. return 0;
  380. }
  381. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  382. struct snd_ctl_elem_value *ucontrol)
  383. {
  384. unsigned int i;
  385. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  386. hda_nid_t nid = kcontrol->private_value & 0xffff;
  387. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  388. long *valp = ucontrol->value.integer.value;
  389. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  390. AC_VERB_GET_PIN_WIDGET_CONTROL,
  391. 0x00);
  392. /* Find enumerated value for current pinctl setting */
  393. i = alc_pin_mode_min(dir);
  394. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  395. i++;
  396. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  397. return 0;
  398. }
  399. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  400. struct snd_ctl_elem_value *ucontrol)
  401. {
  402. signed int change;
  403. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  404. hda_nid_t nid = kcontrol->private_value & 0xffff;
  405. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  406. long val = *ucontrol->value.integer.value;
  407. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  408. AC_VERB_GET_PIN_WIDGET_CONTROL,
  409. 0x00);
  410. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  411. val = alc_pin_mode_min(dir);
  412. change = pinctl != alc_pin_mode_values[val];
  413. if (change) {
  414. /* Set pin mode to that requested */
  415. snd_hda_codec_write_cache(codec, nid, 0,
  416. AC_VERB_SET_PIN_WIDGET_CONTROL,
  417. alc_pin_mode_values[val]);
  418. /* Also enable the retasking pin's input/output as required
  419. * for the requested pin mode. Enum values of 2 or less are
  420. * input modes.
  421. *
  422. * Dynamically switching the input/output buffers probably
  423. * reduces noise slightly (particularly on input) so we'll
  424. * do it. However, having both input and output buffers
  425. * enabled simultaneously doesn't seem to be problematic if
  426. * this turns out to be necessary in the future.
  427. */
  428. if (val <= 2) {
  429. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  430. HDA_AMP_MUTE, HDA_AMP_MUTE);
  431. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  432. HDA_AMP_MUTE, 0);
  433. } else {
  434. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  435. HDA_AMP_MUTE, HDA_AMP_MUTE);
  436. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  437. HDA_AMP_MUTE, 0);
  438. }
  439. }
  440. return change;
  441. }
  442. #define ALC_PIN_MODE(xname, nid, dir) \
  443. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  444. .info = alc_pin_mode_info, \
  445. .get = alc_pin_mode_get, \
  446. .put = alc_pin_mode_put, \
  447. .private_value = nid | (dir<<16) }
  448. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  449. * together using a mask with more than one bit set. This control is
  450. * currently used only by the ALC260 test model. At this stage they are not
  451. * needed for any "production" models.
  452. */
  453. #ifdef CONFIG_SND_DEBUG
  454. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  455. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  456. struct snd_ctl_elem_value *ucontrol)
  457. {
  458. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  459. hda_nid_t nid = kcontrol->private_value & 0xffff;
  460. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  461. long *valp = ucontrol->value.integer.value;
  462. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  463. AC_VERB_GET_GPIO_DATA, 0x00);
  464. *valp = (val & mask) != 0;
  465. return 0;
  466. }
  467. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  468. struct snd_ctl_elem_value *ucontrol)
  469. {
  470. signed int change;
  471. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  472. hda_nid_t nid = kcontrol->private_value & 0xffff;
  473. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  474. long val = *ucontrol->value.integer.value;
  475. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  476. AC_VERB_GET_GPIO_DATA,
  477. 0x00);
  478. /* Set/unset the masked GPIO bit(s) as needed */
  479. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  480. if (val == 0)
  481. gpio_data &= ~mask;
  482. else
  483. gpio_data |= mask;
  484. snd_hda_codec_write_cache(codec, nid, 0,
  485. AC_VERB_SET_GPIO_DATA, gpio_data);
  486. return change;
  487. }
  488. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  489. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  490. .info = alc_gpio_data_info, \
  491. .get = alc_gpio_data_get, \
  492. .put = alc_gpio_data_put, \
  493. .private_value = nid | (mask<<16) }
  494. #endif /* CONFIG_SND_DEBUG */
  495. /* A switch control to allow the enabling of the digital IO pins on the
  496. * ALC260. This is incredibly simplistic; the intention of this control is
  497. * to provide something in the test model allowing digital outputs to be
  498. * identified if present. If models are found which can utilise these
  499. * outputs a more complete mixer control can be devised for those models if
  500. * necessary.
  501. */
  502. #ifdef CONFIG_SND_DEBUG
  503. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  504. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  505. struct snd_ctl_elem_value *ucontrol)
  506. {
  507. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  508. hda_nid_t nid = kcontrol->private_value & 0xffff;
  509. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  510. long *valp = ucontrol->value.integer.value;
  511. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  512. AC_VERB_GET_DIGI_CONVERT, 0x00);
  513. *valp = (val & mask) != 0;
  514. return 0;
  515. }
  516. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  517. struct snd_ctl_elem_value *ucontrol)
  518. {
  519. signed int change;
  520. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  521. hda_nid_t nid = kcontrol->private_value & 0xffff;
  522. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  523. long val = *ucontrol->value.integer.value;
  524. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  525. AC_VERB_GET_DIGI_CONVERT,
  526. 0x00);
  527. /* Set/unset the masked control bit(s) as needed */
  528. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  529. if (val==0)
  530. ctrl_data &= ~mask;
  531. else
  532. ctrl_data |= mask;
  533. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  534. ctrl_data);
  535. return change;
  536. }
  537. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  538. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  539. .info = alc_spdif_ctrl_info, \
  540. .get = alc_spdif_ctrl_get, \
  541. .put = alc_spdif_ctrl_put, \
  542. .private_value = nid | (mask<<16) }
  543. #endif /* CONFIG_SND_DEBUG */
  544. /*
  545. * set up from the preset table
  546. */
  547. static void setup_preset(struct alc_spec *spec,
  548. const struct alc_config_preset *preset)
  549. {
  550. int i;
  551. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  552. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  553. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  554. i++)
  555. spec->init_verbs[spec->num_init_verbs++] =
  556. preset->init_verbs[i];
  557. spec->channel_mode = preset->channel_mode;
  558. spec->num_channel_mode = preset->num_channel_mode;
  559. spec->need_dac_fix = preset->need_dac_fix;
  560. spec->multiout.max_channels = spec->channel_mode[0].channels;
  561. spec->multiout.num_dacs = preset->num_dacs;
  562. spec->multiout.dac_nids = preset->dac_nids;
  563. spec->multiout.dig_out_nid = preset->dig_out_nid;
  564. spec->multiout.hp_nid = preset->hp_nid;
  565. spec->num_mux_defs = preset->num_mux_defs;
  566. if (!spec->num_mux_defs)
  567. spec->num_mux_defs = 1;
  568. spec->input_mux = preset->input_mux;
  569. spec->num_adc_nids = preset->num_adc_nids;
  570. spec->adc_nids = preset->adc_nids;
  571. spec->dig_in_nid = preset->dig_in_nid;
  572. spec->unsol_event = preset->unsol_event;
  573. spec->init_hook = preset->init_hook;
  574. #ifdef CONFIG_SND_HDA_POWER_SAVE
  575. spec->loopback.amplist = preset->loopbacks;
  576. #endif
  577. }
  578. /* Enable GPIO mask and set output */
  579. static struct hda_verb alc_gpio1_init_verbs[] = {
  580. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  582. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  583. { }
  584. };
  585. static struct hda_verb alc_gpio2_init_verbs[] = {
  586. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  588. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  589. { }
  590. };
  591. static struct hda_verb alc_gpio3_init_verbs[] = {
  592. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  594. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  595. { }
  596. };
  597. static void alc_sku_automute(struct hda_codec *codec)
  598. {
  599. struct alc_spec *spec = codec->spec;
  600. unsigned int mute;
  601. unsigned int present;
  602. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  603. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  604. /* need to execute and sync at first */
  605. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  606. present = snd_hda_codec_read(codec, hp_nid, 0,
  607. AC_VERB_GET_PIN_SENSE, 0);
  608. spec->jack_present = (present & 0x80000000) != 0;
  609. if (spec->jack_present) {
  610. /* mute internal speaker */
  611. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  612. HDA_AMP_MUTE, HDA_AMP_MUTE);
  613. } else {
  614. /* unmute internal speaker if necessary */
  615. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  616. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  617. HDA_AMP_MUTE, mute);
  618. }
  619. }
  620. /* unsolicited event for HP jack sensing */
  621. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  622. {
  623. if (codec->vendor_id == 0x10ec0880)
  624. res >>= 28;
  625. else
  626. res >>= 26;
  627. if (res != ALC880_HP_EVENT)
  628. return;
  629. alc_sku_automute(codec);
  630. }
  631. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  632. * 31 ~ 16 : Manufacture ID
  633. * 15 ~ 8 : SKU ID
  634. * 7 ~ 0 : Assembly ID
  635. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  636. */
  637. static void alc_subsystem_id(struct hda_codec *codec,
  638. unsigned int porta, unsigned int porte,
  639. unsigned int portd)
  640. {
  641. unsigned int ass, tmp, i;
  642. unsigned nid;
  643. struct alc_spec *spec = codec->spec;
  644. ass = codec->subsystem_id & 0xffff;
  645. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  646. goto do_sku;
  647. /*
  648. * 31~30 : port conetcivity
  649. * 29~21 : reserve
  650. * 20 : PCBEEP input
  651. * 19~16 : Check sum (15:1)
  652. * 15~1 : Custom
  653. * 0 : override
  654. */
  655. nid = 0x1d;
  656. if (codec->vendor_id == 0x10ec0260)
  657. nid = 0x17;
  658. ass = snd_hda_codec_read(codec, nid, 0,
  659. AC_VERB_GET_CONFIG_DEFAULT, 0);
  660. if (!(ass & 1) && !(ass & 0x100000))
  661. return;
  662. if ((ass >> 30) != 1) /* no physical connection */
  663. return;
  664. /* check sum */
  665. tmp = 0;
  666. for (i = 1; i < 16; i++) {
  667. if ((ass >> i) && 1)
  668. tmp++;
  669. }
  670. if (((ass >> 16) & 0xf) != tmp)
  671. return;
  672. do_sku:
  673. /*
  674. * 0 : override
  675. * 1 : Swap Jack
  676. * 2 : 0 --> Desktop, 1 --> Laptop
  677. * 3~5 : External Amplifier control
  678. * 7~6 : Reserved
  679. */
  680. tmp = (ass & 0x38) >> 3; /* external Amp control */
  681. switch (tmp) {
  682. case 1:
  683. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  684. break;
  685. case 3:
  686. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  687. break;
  688. case 7:
  689. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  690. break;
  691. case 5: /* set EAPD output high */
  692. switch (codec->vendor_id) {
  693. case 0x10ec0260:
  694. snd_hda_codec_write(codec, 0x0f, 0,
  695. AC_VERB_SET_EAPD_BTLENABLE, 2);
  696. snd_hda_codec_write(codec, 0x10, 0,
  697. AC_VERB_SET_EAPD_BTLENABLE, 2);
  698. break;
  699. case 0x10ec0262:
  700. case 0x10ec0267:
  701. case 0x10ec0268:
  702. case 0x10ec0269:
  703. case 0x10ec0862:
  704. case 0x10ec0662:
  705. snd_hda_codec_write(codec, 0x14, 0,
  706. AC_VERB_SET_EAPD_BTLENABLE, 2);
  707. snd_hda_codec_write(codec, 0x15, 0,
  708. AC_VERB_SET_EAPD_BTLENABLE, 2);
  709. break;
  710. }
  711. switch (codec->vendor_id) {
  712. case 0x10ec0260:
  713. snd_hda_codec_write(codec, 0x1a, 0,
  714. AC_VERB_SET_COEF_INDEX, 7);
  715. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  716. AC_VERB_GET_PROC_COEF, 0);
  717. snd_hda_codec_write(codec, 0x1a, 0,
  718. AC_VERB_SET_COEF_INDEX, 7);
  719. snd_hda_codec_write(codec, 0x1a, 0,
  720. AC_VERB_SET_PROC_COEF,
  721. tmp | 0x2010);
  722. break;
  723. case 0x10ec0262:
  724. case 0x10ec0880:
  725. case 0x10ec0882:
  726. case 0x10ec0883:
  727. case 0x10ec0885:
  728. case 0x10ec0888:
  729. snd_hda_codec_write(codec, 0x20, 0,
  730. AC_VERB_SET_COEF_INDEX, 7);
  731. tmp = snd_hda_codec_read(codec, 0x20, 0,
  732. AC_VERB_GET_PROC_COEF, 0);
  733. snd_hda_codec_write(codec, 0x20, 0,
  734. AC_VERB_SET_COEF_INDEX, 7);
  735. snd_hda_codec_write(codec, 0x20, 0,
  736. AC_VERB_SET_PROC_COEF,
  737. tmp | 0x2010);
  738. break;
  739. case 0x10ec0267:
  740. case 0x10ec0268:
  741. snd_hda_codec_write(codec, 0x20, 0,
  742. AC_VERB_SET_COEF_INDEX, 7);
  743. tmp = snd_hda_codec_read(codec, 0x20, 0,
  744. AC_VERB_GET_PROC_COEF, 0);
  745. snd_hda_codec_write(codec, 0x20, 0,
  746. AC_VERB_SET_COEF_INDEX, 7);
  747. snd_hda_codec_write(codec, 0x20, 0,
  748. AC_VERB_SET_PROC_COEF,
  749. tmp | 0x3000);
  750. break;
  751. }
  752. default:
  753. break;
  754. }
  755. /* is laptop and enable the function "Mute internal speaker
  756. * when the external headphone out jack is plugged"
  757. */
  758. if (!(ass & 0x4) || !(ass & 0x8000))
  759. return;
  760. /*
  761. * 10~8 : Jack location
  762. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  763. * 14~13: Resvered
  764. * 15 : 1 --> enable the function "Mute internal speaker
  765. * when the external headphone out jack is plugged"
  766. */
  767. if (!spec->autocfg.speaker_pins[0]) {
  768. if (spec->multiout.dac_nids[0])
  769. spec->autocfg.speaker_pins[0] =
  770. spec->multiout.dac_nids[0];
  771. else
  772. return;
  773. }
  774. if (!spec->autocfg.hp_pins[0]) {
  775. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  776. if (tmp == 0)
  777. spec->autocfg.hp_pins[0] = porta;
  778. else if (tmp == 1)
  779. spec->autocfg.hp_pins[0] = porte;
  780. else if (tmp == 2)
  781. spec->autocfg.hp_pins[0] = portd;
  782. else
  783. return;
  784. }
  785. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  786. AC_VERB_SET_UNSOLICITED_ENABLE,
  787. AC_USRSP_EN | ALC880_HP_EVENT);
  788. spec->unsol_event = alc_sku_unsol_event;
  789. spec->init_hook = alc_sku_automute;
  790. }
  791. /*
  792. * Fix-up pin default configurations
  793. */
  794. struct alc_pincfg {
  795. hda_nid_t nid;
  796. u32 val;
  797. };
  798. static void alc_fix_pincfg(struct hda_codec *codec,
  799. const struct snd_pci_quirk *quirk,
  800. const struct alc_pincfg **pinfix)
  801. {
  802. const struct alc_pincfg *cfg;
  803. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  804. if (!quirk)
  805. return;
  806. cfg = pinfix[quirk->value];
  807. for (; cfg->nid; cfg++) {
  808. int i;
  809. u32 val = cfg->val;
  810. for (i = 0; i < 4; i++) {
  811. snd_hda_codec_write(codec, cfg->nid, 0,
  812. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  813. val & 0xff);
  814. val >>= 8;
  815. }
  816. }
  817. }
  818. /*
  819. * ALC880 3-stack model
  820. *
  821. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  822. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  823. * F-Mic = 0x1b, HP = 0x19
  824. */
  825. static hda_nid_t alc880_dac_nids[4] = {
  826. /* front, rear, clfe, rear_surr */
  827. 0x02, 0x05, 0x04, 0x03
  828. };
  829. static hda_nid_t alc880_adc_nids[3] = {
  830. /* ADC0-2 */
  831. 0x07, 0x08, 0x09,
  832. };
  833. /* The datasheet says the node 0x07 is connected from inputs,
  834. * but it shows zero connection in the real implementation on some devices.
  835. * Note: this is a 915GAV bug, fixed on 915GLV
  836. */
  837. static hda_nid_t alc880_adc_nids_alt[2] = {
  838. /* ADC1-2 */
  839. 0x08, 0x09,
  840. };
  841. #define ALC880_DIGOUT_NID 0x06
  842. #define ALC880_DIGIN_NID 0x0a
  843. static struct hda_input_mux alc880_capture_source = {
  844. .num_items = 4,
  845. .items = {
  846. { "Mic", 0x0 },
  847. { "Front Mic", 0x3 },
  848. { "Line", 0x2 },
  849. { "CD", 0x4 },
  850. },
  851. };
  852. /* channel source setting (2/6 channel selection for 3-stack) */
  853. /* 2ch mode */
  854. static struct hda_verb alc880_threestack_ch2_init[] = {
  855. /* set line-in to input, mute it */
  856. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  857. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  858. /* set mic-in to input vref 80%, mute it */
  859. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  860. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  861. { } /* end */
  862. };
  863. /* 6ch mode */
  864. static struct hda_verb alc880_threestack_ch6_init[] = {
  865. /* set line-in to output, unmute it */
  866. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  867. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  868. /* set mic-in to output, unmute it */
  869. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  870. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  871. { } /* end */
  872. };
  873. static struct hda_channel_mode alc880_threestack_modes[2] = {
  874. { 2, alc880_threestack_ch2_init },
  875. { 6, alc880_threestack_ch6_init },
  876. };
  877. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  878. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  879. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  881. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  882. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  883. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  884. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  885. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  886. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  887. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  888. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  889. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  890. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  891. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  892. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  893. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  894. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  895. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  896. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  897. {
  898. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  899. .name = "Channel Mode",
  900. .info = alc_ch_mode_info,
  901. .get = alc_ch_mode_get,
  902. .put = alc_ch_mode_put,
  903. },
  904. { } /* end */
  905. };
  906. /* capture mixer elements */
  907. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  908. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  909. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  910. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  911. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  912. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  913. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  914. {
  915. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  916. /* The multiple "Capture Source" controls confuse alsamixer
  917. * So call somewhat different..
  918. * FIXME: the controls appear in the "playback" view!
  919. */
  920. /* .name = "Capture Source", */
  921. .name = "Input Source",
  922. .count = 3,
  923. .info = alc_mux_enum_info,
  924. .get = alc_mux_enum_get,
  925. .put = alc_mux_enum_put,
  926. },
  927. { } /* end */
  928. };
  929. /* capture mixer elements (in case NID 0x07 not available) */
  930. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  931. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  932. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  933. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  934. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  935. {
  936. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  937. /* The multiple "Capture Source" controls confuse alsamixer
  938. * So call somewhat different..
  939. * FIXME: the controls appear in the "playback" view!
  940. */
  941. /* .name = "Capture Source", */
  942. .name = "Input Source",
  943. .count = 2,
  944. .info = alc_mux_enum_info,
  945. .get = alc_mux_enum_get,
  946. .put = alc_mux_enum_put,
  947. },
  948. { } /* end */
  949. };
  950. /*
  951. * ALC880 5-stack model
  952. *
  953. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  954. * Side = 0x02 (0xd)
  955. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  956. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  957. */
  958. /* additional mixers to alc880_three_stack_mixer */
  959. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  960. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  961. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  962. { } /* end */
  963. };
  964. /* channel source setting (6/8 channel selection for 5-stack) */
  965. /* 6ch mode */
  966. static struct hda_verb alc880_fivestack_ch6_init[] = {
  967. /* set line-in to input, mute it */
  968. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  969. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  970. { } /* end */
  971. };
  972. /* 8ch mode */
  973. static struct hda_verb alc880_fivestack_ch8_init[] = {
  974. /* set line-in to output, unmute it */
  975. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  976. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  977. { } /* end */
  978. };
  979. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  980. { 6, alc880_fivestack_ch6_init },
  981. { 8, alc880_fivestack_ch8_init },
  982. };
  983. /*
  984. * ALC880 6-stack model
  985. *
  986. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  987. * Side = 0x05 (0x0f)
  988. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  989. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  990. */
  991. static hda_nid_t alc880_6st_dac_nids[4] = {
  992. /* front, rear, clfe, rear_surr */
  993. 0x02, 0x03, 0x04, 0x05
  994. };
  995. static struct hda_input_mux alc880_6stack_capture_source = {
  996. .num_items = 4,
  997. .items = {
  998. { "Mic", 0x0 },
  999. { "Front Mic", 0x1 },
  1000. { "Line", 0x2 },
  1001. { "CD", 0x4 },
  1002. },
  1003. };
  1004. /* fixed 8-channels */
  1005. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1006. { 8, NULL },
  1007. };
  1008. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1009. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1010. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1011. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1013. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1014. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1015. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1016. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1017. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1018. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1020. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1023. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1024. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1025. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1027. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1028. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1029. {
  1030. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1031. .name = "Channel Mode",
  1032. .info = alc_ch_mode_info,
  1033. .get = alc_ch_mode_get,
  1034. .put = alc_ch_mode_put,
  1035. },
  1036. { } /* end */
  1037. };
  1038. /*
  1039. * ALC880 W810 model
  1040. *
  1041. * W810 has rear IO for:
  1042. * Front (DAC 02)
  1043. * Surround (DAC 03)
  1044. * Center/LFE (DAC 04)
  1045. * Digital out (06)
  1046. *
  1047. * The system also has a pair of internal speakers, and a headphone jack.
  1048. * These are both connected to Line2 on the codec, hence to DAC 02.
  1049. *
  1050. * There is a variable resistor to control the speaker or headphone
  1051. * volume. This is a hardware-only device without a software API.
  1052. *
  1053. * Plugging headphones in will disable the internal speakers. This is
  1054. * implemented in hardware, not via the driver using jack sense. In
  1055. * a similar fashion, plugging into the rear socket marked "front" will
  1056. * disable both the speakers and headphones.
  1057. *
  1058. * For input, there's a microphone jack, and an "audio in" jack.
  1059. * These may not do anything useful with this driver yet, because I
  1060. * haven't setup any initialization verbs for these yet...
  1061. */
  1062. static hda_nid_t alc880_w810_dac_nids[3] = {
  1063. /* front, rear/surround, clfe */
  1064. 0x02, 0x03, 0x04
  1065. };
  1066. /* fixed 6 channels */
  1067. static struct hda_channel_mode alc880_w810_modes[1] = {
  1068. { 6, NULL }
  1069. };
  1070. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1071. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1072. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1073. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1074. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1075. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1076. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1077. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1079. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1080. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1081. { } /* end */
  1082. };
  1083. /*
  1084. * Z710V model
  1085. *
  1086. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1087. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1088. * Line = 0x1a
  1089. */
  1090. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1091. 0x02
  1092. };
  1093. #define ALC880_Z71V_HP_DAC 0x03
  1094. /* fixed 2 channels */
  1095. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1096. { 2, NULL }
  1097. };
  1098. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1099. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1100. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1101. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1102. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1103. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1104. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1106. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1107. { } /* end */
  1108. };
  1109. /* FIXME! */
  1110. /*
  1111. * ALC880 F1734 model
  1112. *
  1113. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1114. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1115. */
  1116. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1117. 0x03
  1118. };
  1119. #define ALC880_F1734_HP_DAC 0x02
  1120. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1121. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1122. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1123. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1124. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1125. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1126. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1127. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1128. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1129. { } /* end */
  1130. };
  1131. /* FIXME! */
  1132. /*
  1133. * ALC880 ASUS model
  1134. *
  1135. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1136. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1137. * Mic = 0x18, Line = 0x1a
  1138. */
  1139. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1140. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1141. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1142. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1143. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1144. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1145. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1146. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1147. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1148. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1149. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1150. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1151. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1152. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1153. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1154. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1155. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1156. {
  1157. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1158. .name = "Channel Mode",
  1159. .info = alc_ch_mode_info,
  1160. .get = alc_ch_mode_get,
  1161. .put = alc_ch_mode_put,
  1162. },
  1163. { } /* end */
  1164. };
  1165. /* FIXME! */
  1166. /*
  1167. * ALC880 ASUS W1V model
  1168. *
  1169. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1170. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1171. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1172. */
  1173. /* additional mixers to alc880_asus_mixer */
  1174. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1175. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1176. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1177. { } /* end */
  1178. };
  1179. /* additional mixers to alc880_asus_mixer */
  1180. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1181. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1182. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1183. { } /* end */
  1184. };
  1185. /* TCL S700 */
  1186. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1187. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1188. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1189. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1190. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1191. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1192. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1193. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1194. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1195. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1196. {
  1197. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1198. /* The multiple "Capture Source" controls confuse alsamixer
  1199. * So call somewhat different..
  1200. * FIXME: the controls appear in the "playback" view!
  1201. */
  1202. /* .name = "Capture Source", */
  1203. .name = "Input Source",
  1204. .count = 1,
  1205. .info = alc_mux_enum_info,
  1206. .get = alc_mux_enum_get,
  1207. .put = alc_mux_enum_put,
  1208. },
  1209. { } /* end */
  1210. };
  1211. /* Uniwill */
  1212. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1213. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1214. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1215. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1216. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1217. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1218. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1219. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1220. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1221. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1222. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1223. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1224. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1225. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1226. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1227. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1228. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1229. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1230. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1231. {
  1232. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1233. .name = "Channel Mode",
  1234. .info = alc_ch_mode_info,
  1235. .get = alc_ch_mode_get,
  1236. .put = alc_ch_mode_put,
  1237. },
  1238. { } /* end */
  1239. };
  1240. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1241. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1242. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1243. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1244. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1245. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1246. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1247. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1248. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1249. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1250. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1251. { } /* end */
  1252. };
  1253. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1254. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1255. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1256. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1257. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1258. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1259. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1260. { } /* end */
  1261. };
  1262. /*
  1263. * build control elements
  1264. */
  1265. static int alc_build_controls(struct hda_codec *codec)
  1266. {
  1267. struct alc_spec *spec = codec->spec;
  1268. int err;
  1269. int i;
  1270. for (i = 0; i < spec->num_mixers; i++) {
  1271. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1272. if (err < 0)
  1273. return err;
  1274. }
  1275. if (spec->multiout.dig_out_nid) {
  1276. err = snd_hda_create_spdif_out_ctls(codec,
  1277. spec->multiout.dig_out_nid);
  1278. if (err < 0)
  1279. return err;
  1280. }
  1281. if (spec->dig_in_nid) {
  1282. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1283. if (err < 0)
  1284. return err;
  1285. }
  1286. return 0;
  1287. }
  1288. /*
  1289. * initialize the codec volumes, etc
  1290. */
  1291. /*
  1292. * generic initialization of ADC, input mixers and output mixers
  1293. */
  1294. static struct hda_verb alc880_volume_init_verbs[] = {
  1295. /*
  1296. * Unmute ADC0-2 and set the default input to mic-in
  1297. */
  1298. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1299. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1300. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1301. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1302. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1303. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1304. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1305. * mixer widget
  1306. * Note: PASD motherboards uses the Line In 2 as the input for front
  1307. * panel mic (mic 2)
  1308. */
  1309. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1310. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1314. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1315. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1316. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1317. /*
  1318. * Set up output mixers (0x0c - 0x0f)
  1319. */
  1320. /* set vol=0 to output mixers */
  1321. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1322. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1323. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1324. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1325. /* set up input amps for analog loopback */
  1326. /* Amp Indices: DAC = 0, mixer = 1 */
  1327. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1328. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1329. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1330. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1331. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1332. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1333. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1334. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1335. { }
  1336. };
  1337. /*
  1338. * 3-stack pin configuration:
  1339. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1340. */
  1341. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1342. /*
  1343. * preset connection lists of input pins
  1344. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1345. */
  1346. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1347. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1348. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1349. /*
  1350. * Set pin mode and muting
  1351. */
  1352. /* set front pin widgets 0x14 for output */
  1353. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1354. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1355. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1356. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. /* Mic2 (as headphone out) for HP output */
  1359. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1360. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1361. /* Line In pin widget for input */
  1362. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1363. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1364. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1365. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1366. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1367. /* CD pin widget for input */
  1368. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1369. { }
  1370. };
  1371. /*
  1372. * 5-stack pin configuration:
  1373. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1374. * line-in/side = 0x1a, f-mic = 0x1b
  1375. */
  1376. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1377. /*
  1378. * preset connection lists of input pins
  1379. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1380. */
  1381. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1382. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1383. /*
  1384. * Set pin mode and muting
  1385. */
  1386. /* set pin widgets 0x14-0x17 for output */
  1387. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1388. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1389. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1390. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1391. /* unmute pins for output (no gain on this amp) */
  1392. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1393. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1394. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1395. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1396. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1397. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1398. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1399. /* Mic2 (as headphone out) for HP output */
  1400. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1401. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1402. /* Line In pin widget for input */
  1403. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1404. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1405. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1406. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1407. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1408. /* CD pin widget for input */
  1409. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1410. { }
  1411. };
  1412. /*
  1413. * W810 pin configuration:
  1414. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1415. */
  1416. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1417. /* hphone/speaker input selector: front DAC */
  1418. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1419. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1420. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1421. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1422. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1423. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1424. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1425. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1426. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1427. { }
  1428. };
  1429. /*
  1430. * Z71V pin configuration:
  1431. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1432. */
  1433. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1434. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1435. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1436. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1437. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1438. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1439. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1440. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1441. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1442. { }
  1443. };
  1444. /*
  1445. * 6-stack pin configuration:
  1446. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1447. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1448. */
  1449. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1450. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1451. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1452. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1453. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1454. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1455. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1456. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1457. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1458. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1459. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1460. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1461. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1462. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1463. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1464. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1465. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1466. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1468. { }
  1469. };
  1470. /*
  1471. * Uniwill pin configuration:
  1472. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1473. * line = 0x1a
  1474. */
  1475. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1476. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1477. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1478. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1481. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1482. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1483. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1484. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1486. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1487. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1488. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1489. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1490. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1491. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1492. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1493. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1494. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1495. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1497. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1498. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1499. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1500. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1501. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1502. { }
  1503. };
  1504. /*
  1505. * Uniwill P53
  1506. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1507. */
  1508. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1509. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1510. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1513. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1514. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1515. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1516. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1517. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1518. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1519. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1520. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1521. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1522. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1523. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1524. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1525. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1526. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1527. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1528. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1529. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1530. { }
  1531. };
  1532. static struct hda_verb alc880_beep_init_verbs[] = {
  1533. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1534. { }
  1535. };
  1536. /* toggle speaker-output according to the hp-jack state */
  1537. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1538. {
  1539. unsigned int present;
  1540. unsigned char bits;
  1541. present = snd_hda_codec_read(codec, 0x14, 0,
  1542. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1543. bits = present ? HDA_AMP_MUTE : 0;
  1544. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1545. HDA_AMP_MUTE, bits);
  1546. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1547. HDA_AMP_MUTE, bits);
  1548. }
  1549. /* auto-toggle front mic */
  1550. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1551. {
  1552. unsigned int present;
  1553. unsigned char bits;
  1554. present = snd_hda_codec_read(codec, 0x18, 0,
  1555. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1556. bits = present ? HDA_AMP_MUTE : 0;
  1557. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1558. }
  1559. static void alc880_uniwill_automute(struct hda_codec *codec)
  1560. {
  1561. alc880_uniwill_hp_automute(codec);
  1562. alc880_uniwill_mic_automute(codec);
  1563. }
  1564. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1565. unsigned int res)
  1566. {
  1567. /* Looks like the unsol event is incompatible with the standard
  1568. * definition. 4bit tag is placed at 28 bit!
  1569. */
  1570. switch (res >> 28) {
  1571. case ALC880_HP_EVENT:
  1572. alc880_uniwill_hp_automute(codec);
  1573. break;
  1574. case ALC880_MIC_EVENT:
  1575. alc880_uniwill_mic_automute(codec);
  1576. break;
  1577. }
  1578. }
  1579. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1580. {
  1581. unsigned int present;
  1582. unsigned char bits;
  1583. present = snd_hda_codec_read(codec, 0x14, 0,
  1584. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1585. bits = present ? HDA_AMP_MUTE : 0;
  1586. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1587. }
  1588. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1589. {
  1590. unsigned int present;
  1591. present = snd_hda_codec_read(codec, 0x21, 0,
  1592. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1593. present &= HDA_AMP_VOLMASK;
  1594. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1595. HDA_AMP_VOLMASK, present);
  1596. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1597. HDA_AMP_VOLMASK, present);
  1598. }
  1599. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1600. unsigned int res)
  1601. {
  1602. /* Looks like the unsol event is incompatible with the standard
  1603. * definition. 4bit tag is placed at 28 bit!
  1604. */
  1605. if ((res >> 28) == ALC880_HP_EVENT)
  1606. alc880_uniwill_p53_hp_automute(codec);
  1607. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1608. alc880_uniwill_p53_dcvol_automute(codec);
  1609. }
  1610. /* FIXME! */
  1611. /*
  1612. * F1734 pin configuration:
  1613. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1614. */
  1615. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1616. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1617. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1618. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1619. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1620. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1621. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1622. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1623. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1624. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1625. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1626. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1627. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1628. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1629. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1630. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1631. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1632. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1633. { }
  1634. };
  1635. /* FIXME! */
  1636. /*
  1637. * ASUS pin configuration:
  1638. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1639. */
  1640. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1641. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1642. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1643. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1644. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1645. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1646. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1648. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1649. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1650. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1651. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1652. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1653. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1654. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1655. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1656. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1657. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1658. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1659. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1660. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1661. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1662. { }
  1663. };
  1664. /* Enable GPIO mask and set output */
  1665. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1666. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1667. /* Clevo m520g init */
  1668. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1669. /* headphone output */
  1670. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1671. /* line-out */
  1672. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1673. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* Line-in */
  1675. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1676. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1677. /* CD */
  1678. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1679. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1680. /* Mic1 (rear panel) */
  1681. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1682. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1683. /* Mic2 (front panel) */
  1684. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1685. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1686. /* headphone */
  1687. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1688. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1689. /* change to EAPD mode */
  1690. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1691. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1692. { }
  1693. };
  1694. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1695. /* change to EAPD mode */
  1696. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1697. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1698. /* Headphone output */
  1699. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1700. /* Front output*/
  1701. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1702. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1703. /* Line In pin widget for input */
  1704. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1705. /* CD pin widget for input */
  1706. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1707. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1708. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1709. /* change to EAPD mode */
  1710. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1711. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1712. { }
  1713. };
  1714. /*
  1715. * LG m1 express dual
  1716. *
  1717. * Pin assignment:
  1718. * Rear Line-In/Out (blue): 0x14
  1719. * Build-in Mic-In: 0x15
  1720. * Speaker-out: 0x17
  1721. * HP-Out (green): 0x1b
  1722. * Mic-In/Out (red): 0x19
  1723. * SPDIF-Out: 0x1e
  1724. */
  1725. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1726. static hda_nid_t alc880_lg_dac_nids[3] = {
  1727. 0x05, 0x02, 0x03
  1728. };
  1729. /* seems analog CD is not working */
  1730. static struct hda_input_mux alc880_lg_capture_source = {
  1731. .num_items = 3,
  1732. .items = {
  1733. { "Mic", 0x1 },
  1734. { "Line", 0x5 },
  1735. { "Internal Mic", 0x6 },
  1736. },
  1737. };
  1738. /* 2,4,6 channel modes */
  1739. static struct hda_verb alc880_lg_ch2_init[] = {
  1740. /* set line-in and mic-in to input */
  1741. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1742. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1743. { }
  1744. };
  1745. static struct hda_verb alc880_lg_ch4_init[] = {
  1746. /* set line-in to out and mic-in to input */
  1747. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1748. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1749. { }
  1750. };
  1751. static struct hda_verb alc880_lg_ch6_init[] = {
  1752. /* set line-in and mic-in to output */
  1753. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1754. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1755. { }
  1756. };
  1757. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1758. { 2, alc880_lg_ch2_init },
  1759. { 4, alc880_lg_ch4_init },
  1760. { 6, alc880_lg_ch6_init },
  1761. };
  1762. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1763. /* FIXME: it's not really "master" but front channels */
  1764. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1765. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1766. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1767. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1768. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1769. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1770. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1771. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1772. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1773. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1774. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1775. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1776. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1777. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1778. {
  1779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1780. .name = "Channel Mode",
  1781. .info = alc_ch_mode_info,
  1782. .get = alc_ch_mode_get,
  1783. .put = alc_ch_mode_put,
  1784. },
  1785. { } /* end */
  1786. };
  1787. static struct hda_verb alc880_lg_init_verbs[] = {
  1788. /* set capture source to mic-in */
  1789. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1790. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1791. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1792. /* mute all amp mixer inputs */
  1793. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1795. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1796. /* line-in to input */
  1797. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1798. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1799. /* built-in mic */
  1800. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1801. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1802. /* speaker-out */
  1803. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1804. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1805. /* mic-in to input */
  1806. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1807. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1808. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1809. /* HP-out */
  1810. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1811. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1812. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1813. /* jack sense */
  1814. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1815. { }
  1816. };
  1817. /* toggle speaker-output according to the hp-jack state */
  1818. static void alc880_lg_automute(struct hda_codec *codec)
  1819. {
  1820. unsigned int present;
  1821. unsigned char bits;
  1822. present = snd_hda_codec_read(codec, 0x1b, 0,
  1823. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1824. bits = present ? HDA_AMP_MUTE : 0;
  1825. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1826. HDA_AMP_MUTE, bits);
  1827. }
  1828. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1829. {
  1830. /* Looks like the unsol event is incompatible with the standard
  1831. * definition. 4bit tag is placed at 28 bit!
  1832. */
  1833. if ((res >> 28) == 0x01)
  1834. alc880_lg_automute(codec);
  1835. }
  1836. /*
  1837. * LG LW20
  1838. *
  1839. * Pin assignment:
  1840. * Speaker-out: 0x14
  1841. * Mic-In: 0x18
  1842. * Built-in Mic-In: 0x19
  1843. * Line-In: 0x1b
  1844. * HP-Out: 0x1a
  1845. * SPDIF-Out: 0x1e
  1846. */
  1847. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1848. .num_items = 3,
  1849. .items = {
  1850. { "Mic", 0x0 },
  1851. { "Internal Mic", 0x1 },
  1852. { "Line In", 0x2 },
  1853. },
  1854. };
  1855. #define alc880_lg_lw_modes alc880_threestack_modes
  1856. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1857. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1858. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1859. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1860. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1861. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1862. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1863. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1864. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1865. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1866. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1867. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1868. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1869. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1870. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1871. {
  1872. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1873. .name = "Channel Mode",
  1874. .info = alc_ch_mode_info,
  1875. .get = alc_ch_mode_get,
  1876. .put = alc_ch_mode_put,
  1877. },
  1878. { } /* end */
  1879. };
  1880. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1881. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1882. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1883. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1884. /* set capture source to mic-in */
  1885. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1886. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1887. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1888. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1889. /* speaker-out */
  1890. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1891. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1892. /* HP-out */
  1893. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1894. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1895. /* mic-in to input */
  1896. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1897. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1898. /* built-in mic */
  1899. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1900. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1901. /* jack sense */
  1902. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1903. { }
  1904. };
  1905. /* toggle speaker-output according to the hp-jack state */
  1906. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1907. {
  1908. unsigned int present;
  1909. unsigned char bits;
  1910. present = snd_hda_codec_read(codec, 0x1b, 0,
  1911. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1912. bits = present ? HDA_AMP_MUTE : 0;
  1913. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1914. HDA_AMP_MUTE, bits);
  1915. }
  1916. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1917. {
  1918. /* Looks like the unsol event is incompatible with the standard
  1919. * definition. 4bit tag is placed at 28 bit!
  1920. */
  1921. if ((res >> 28) == 0x01)
  1922. alc880_lg_lw_automute(codec);
  1923. }
  1924. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1925. static struct hda_amp_list alc880_loopbacks[] = {
  1926. { 0x0b, HDA_INPUT, 0 },
  1927. { 0x0b, HDA_INPUT, 1 },
  1928. { 0x0b, HDA_INPUT, 2 },
  1929. { 0x0b, HDA_INPUT, 3 },
  1930. { 0x0b, HDA_INPUT, 4 },
  1931. { } /* end */
  1932. };
  1933. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1934. { 0x0b, HDA_INPUT, 1 },
  1935. { 0x0b, HDA_INPUT, 6 },
  1936. { 0x0b, HDA_INPUT, 7 },
  1937. { } /* end */
  1938. };
  1939. #endif
  1940. /*
  1941. * Common callbacks
  1942. */
  1943. static int alc_init(struct hda_codec *codec)
  1944. {
  1945. struct alc_spec *spec = codec->spec;
  1946. unsigned int i;
  1947. for (i = 0; i < spec->num_init_verbs; i++)
  1948. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1949. if (spec->init_hook)
  1950. spec->init_hook(codec);
  1951. return 0;
  1952. }
  1953. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1954. {
  1955. struct alc_spec *spec = codec->spec;
  1956. if (spec->unsol_event)
  1957. spec->unsol_event(codec, res);
  1958. }
  1959. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1960. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1961. {
  1962. struct alc_spec *spec = codec->spec;
  1963. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1964. }
  1965. #endif
  1966. /*
  1967. * Analog playback callbacks
  1968. */
  1969. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1970. struct hda_codec *codec,
  1971. struct snd_pcm_substream *substream)
  1972. {
  1973. struct alc_spec *spec = codec->spec;
  1974. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1975. }
  1976. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1977. struct hda_codec *codec,
  1978. unsigned int stream_tag,
  1979. unsigned int format,
  1980. struct snd_pcm_substream *substream)
  1981. {
  1982. struct alc_spec *spec = codec->spec;
  1983. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1984. stream_tag, format, substream);
  1985. }
  1986. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1987. struct hda_codec *codec,
  1988. struct snd_pcm_substream *substream)
  1989. {
  1990. struct alc_spec *spec = codec->spec;
  1991. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1992. }
  1993. /*
  1994. * Digital out
  1995. */
  1996. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1997. struct hda_codec *codec,
  1998. struct snd_pcm_substream *substream)
  1999. {
  2000. struct alc_spec *spec = codec->spec;
  2001. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2002. }
  2003. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2004. struct hda_codec *codec,
  2005. unsigned int stream_tag,
  2006. unsigned int format,
  2007. struct snd_pcm_substream *substream)
  2008. {
  2009. struct alc_spec *spec = codec->spec;
  2010. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2011. stream_tag, format, substream);
  2012. }
  2013. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2014. struct hda_codec *codec,
  2015. struct snd_pcm_substream *substream)
  2016. {
  2017. struct alc_spec *spec = codec->spec;
  2018. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2019. }
  2020. /*
  2021. * Analog capture
  2022. */
  2023. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2024. struct hda_codec *codec,
  2025. unsigned int stream_tag,
  2026. unsigned int format,
  2027. struct snd_pcm_substream *substream)
  2028. {
  2029. struct alc_spec *spec = codec->spec;
  2030. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2031. stream_tag, 0, format);
  2032. return 0;
  2033. }
  2034. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2035. struct hda_codec *codec,
  2036. struct snd_pcm_substream *substream)
  2037. {
  2038. struct alc_spec *spec = codec->spec;
  2039. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2040. 0, 0, 0);
  2041. return 0;
  2042. }
  2043. /*
  2044. */
  2045. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2046. .substreams = 1,
  2047. .channels_min = 2,
  2048. .channels_max = 8,
  2049. /* NID is set in alc_build_pcms */
  2050. .ops = {
  2051. .open = alc880_playback_pcm_open,
  2052. .prepare = alc880_playback_pcm_prepare,
  2053. .cleanup = alc880_playback_pcm_cleanup
  2054. },
  2055. };
  2056. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2057. .substreams = 2,
  2058. .channels_min = 2,
  2059. .channels_max = 2,
  2060. /* NID is set in alc_build_pcms */
  2061. .ops = {
  2062. .prepare = alc880_capture_pcm_prepare,
  2063. .cleanup = alc880_capture_pcm_cleanup
  2064. },
  2065. };
  2066. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2067. .substreams = 1,
  2068. .channels_min = 2,
  2069. .channels_max = 2,
  2070. /* NID is set in alc_build_pcms */
  2071. .ops = {
  2072. .open = alc880_dig_playback_pcm_open,
  2073. .close = alc880_dig_playback_pcm_close,
  2074. .prepare = alc880_dig_playback_pcm_prepare
  2075. },
  2076. };
  2077. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2078. .substreams = 1,
  2079. .channels_min = 2,
  2080. .channels_max = 2,
  2081. /* NID is set in alc_build_pcms */
  2082. };
  2083. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2084. static struct hda_pcm_stream alc_pcm_null_playback = {
  2085. .substreams = 0,
  2086. .channels_min = 0,
  2087. .channels_max = 0,
  2088. };
  2089. static int alc_build_pcms(struct hda_codec *codec)
  2090. {
  2091. struct alc_spec *spec = codec->spec;
  2092. struct hda_pcm *info = spec->pcm_rec;
  2093. int i;
  2094. codec->num_pcms = 1;
  2095. codec->pcm_info = info;
  2096. info->name = spec->stream_name_analog;
  2097. if (spec->stream_analog_playback) {
  2098. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2099. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2100. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2101. }
  2102. if (spec->stream_analog_capture) {
  2103. snd_assert(spec->adc_nids, return -EINVAL);
  2104. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2105. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2106. }
  2107. if (spec->channel_mode) {
  2108. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2109. for (i = 0; i < spec->num_channel_mode; i++) {
  2110. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2111. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2112. }
  2113. }
  2114. }
  2115. /* SPDIF for stream index #1 */
  2116. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2117. codec->num_pcms = 2;
  2118. info = spec->pcm_rec + 1;
  2119. info->name = spec->stream_name_digital;
  2120. if (spec->multiout.dig_out_nid &&
  2121. spec->stream_digital_playback) {
  2122. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2123. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2124. }
  2125. if (spec->dig_in_nid &&
  2126. spec->stream_digital_capture) {
  2127. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2128. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2129. }
  2130. }
  2131. /* If the use of more than one ADC is requested for the current
  2132. * model, configure a second analog capture-only PCM.
  2133. */
  2134. /* Additional Analaog capture for index #2 */
  2135. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2136. spec->adc_nids) {
  2137. codec->num_pcms = 3;
  2138. info = spec->pcm_rec + 2;
  2139. info->name = spec->stream_name_analog;
  2140. /* No playback stream for second PCM */
  2141. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2142. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2143. if (spec->stream_analog_capture) {
  2144. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2145. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2146. }
  2147. }
  2148. return 0;
  2149. }
  2150. static void alc_free(struct hda_codec *codec)
  2151. {
  2152. struct alc_spec *spec = codec->spec;
  2153. unsigned int i;
  2154. if (!spec)
  2155. return;
  2156. if (spec->kctl_alloc) {
  2157. for (i = 0; i < spec->num_kctl_used; i++)
  2158. kfree(spec->kctl_alloc[i].name);
  2159. kfree(spec->kctl_alloc);
  2160. }
  2161. kfree(spec);
  2162. }
  2163. /*
  2164. */
  2165. static struct hda_codec_ops alc_patch_ops = {
  2166. .build_controls = alc_build_controls,
  2167. .build_pcms = alc_build_pcms,
  2168. .init = alc_init,
  2169. .free = alc_free,
  2170. .unsol_event = alc_unsol_event,
  2171. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2172. .check_power_status = alc_check_power_status,
  2173. #endif
  2174. };
  2175. /*
  2176. * Test configuration for debugging
  2177. *
  2178. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2179. * enum controls.
  2180. */
  2181. #ifdef CONFIG_SND_DEBUG
  2182. static hda_nid_t alc880_test_dac_nids[4] = {
  2183. 0x02, 0x03, 0x04, 0x05
  2184. };
  2185. static struct hda_input_mux alc880_test_capture_source = {
  2186. .num_items = 7,
  2187. .items = {
  2188. { "In-1", 0x0 },
  2189. { "In-2", 0x1 },
  2190. { "In-3", 0x2 },
  2191. { "In-4", 0x3 },
  2192. { "CD", 0x4 },
  2193. { "Front", 0x5 },
  2194. { "Surround", 0x6 },
  2195. },
  2196. };
  2197. static struct hda_channel_mode alc880_test_modes[4] = {
  2198. { 2, NULL },
  2199. { 4, NULL },
  2200. { 6, NULL },
  2201. { 8, NULL },
  2202. };
  2203. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2204. struct snd_ctl_elem_info *uinfo)
  2205. {
  2206. static char *texts[] = {
  2207. "N/A", "Line Out", "HP Out",
  2208. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2209. };
  2210. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2211. uinfo->count = 1;
  2212. uinfo->value.enumerated.items = 8;
  2213. if (uinfo->value.enumerated.item >= 8)
  2214. uinfo->value.enumerated.item = 7;
  2215. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2216. return 0;
  2217. }
  2218. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2219. struct snd_ctl_elem_value *ucontrol)
  2220. {
  2221. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2222. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2223. unsigned int pin_ctl, item = 0;
  2224. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2225. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2226. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2227. if (pin_ctl & AC_PINCTL_HP_EN)
  2228. item = 2;
  2229. else
  2230. item = 1;
  2231. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2232. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2233. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2234. case AC_PINCTL_VREF_50: item = 4; break;
  2235. case AC_PINCTL_VREF_GRD: item = 5; break;
  2236. case AC_PINCTL_VREF_80: item = 6; break;
  2237. case AC_PINCTL_VREF_100: item = 7; break;
  2238. }
  2239. }
  2240. ucontrol->value.enumerated.item[0] = item;
  2241. return 0;
  2242. }
  2243. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2244. struct snd_ctl_elem_value *ucontrol)
  2245. {
  2246. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2247. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2248. static unsigned int ctls[] = {
  2249. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2250. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2251. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2252. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2253. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2254. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2255. };
  2256. unsigned int old_ctl, new_ctl;
  2257. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2258. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2259. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2260. if (old_ctl != new_ctl) {
  2261. int val;
  2262. snd_hda_codec_write_cache(codec, nid, 0,
  2263. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2264. new_ctl);
  2265. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2266. HDA_AMP_MUTE : 0;
  2267. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2268. HDA_AMP_MUTE, val);
  2269. return 1;
  2270. }
  2271. return 0;
  2272. }
  2273. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2274. struct snd_ctl_elem_info *uinfo)
  2275. {
  2276. static char *texts[] = {
  2277. "Front", "Surround", "CLFE", "Side"
  2278. };
  2279. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2280. uinfo->count = 1;
  2281. uinfo->value.enumerated.items = 4;
  2282. if (uinfo->value.enumerated.item >= 4)
  2283. uinfo->value.enumerated.item = 3;
  2284. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2285. return 0;
  2286. }
  2287. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2288. struct snd_ctl_elem_value *ucontrol)
  2289. {
  2290. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2291. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2292. unsigned int sel;
  2293. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2294. ucontrol->value.enumerated.item[0] = sel & 3;
  2295. return 0;
  2296. }
  2297. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2298. struct snd_ctl_elem_value *ucontrol)
  2299. {
  2300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2301. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2302. unsigned int sel;
  2303. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2304. if (ucontrol->value.enumerated.item[0] != sel) {
  2305. sel = ucontrol->value.enumerated.item[0] & 3;
  2306. snd_hda_codec_write_cache(codec, nid, 0,
  2307. AC_VERB_SET_CONNECT_SEL, sel);
  2308. return 1;
  2309. }
  2310. return 0;
  2311. }
  2312. #define PIN_CTL_TEST(xname,nid) { \
  2313. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2314. .name = xname, \
  2315. .info = alc_test_pin_ctl_info, \
  2316. .get = alc_test_pin_ctl_get, \
  2317. .put = alc_test_pin_ctl_put, \
  2318. .private_value = nid \
  2319. }
  2320. #define PIN_SRC_TEST(xname,nid) { \
  2321. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2322. .name = xname, \
  2323. .info = alc_test_pin_src_info, \
  2324. .get = alc_test_pin_src_get, \
  2325. .put = alc_test_pin_src_put, \
  2326. .private_value = nid \
  2327. }
  2328. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2329. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2330. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2331. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2332. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2333. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2334. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2335. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2336. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2337. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2338. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2339. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2340. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2341. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2342. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2343. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2344. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2345. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2346. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2347. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2348. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2349. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2350. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2351. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2352. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2353. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2354. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2355. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2356. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2357. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2358. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2359. {
  2360. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2361. .name = "Channel Mode",
  2362. .info = alc_ch_mode_info,
  2363. .get = alc_ch_mode_get,
  2364. .put = alc_ch_mode_put,
  2365. },
  2366. { } /* end */
  2367. };
  2368. static struct hda_verb alc880_test_init_verbs[] = {
  2369. /* Unmute inputs of 0x0c - 0x0f */
  2370. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2371. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2372. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2373. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2374. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2375. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2376. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2377. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2378. /* Vol output for 0x0c-0x0f */
  2379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2382. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2383. /* Set output pins 0x14-0x17 */
  2384. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2385. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2386. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2387. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2388. /* Unmute output pins 0x14-0x17 */
  2389. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2391. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2392. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2393. /* Set input pins 0x18-0x1c */
  2394. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2395. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2396. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2397. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2398. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2399. /* Mute input pins 0x18-0x1b */
  2400. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2401. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2402. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2403. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2404. /* ADC set up */
  2405. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2406. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2407. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2408. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2409. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2410. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2411. /* Analog input/passthru */
  2412. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2413. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2414. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2415. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2416. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2417. { }
  2418. };
  2419. #endif
  2420. /*
  2421. */
  2422. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2423. [ALC880_3ST] = "3stack",
  2424. [ALC880_TCL_S700] = "tcl",
  2425. [ALC880_3ST_DIG] = "3stack-digout",
  2426. [ALC880_CLEVO] = "clevo",
  2427. [ALC880_5ST] = "5stack",
  2428. [ALC880_5ST_DIG] = "5stack-digout",
  2429. [ALC880_W810] = "w810",
  2430. [ALC880_Z71V] = "z71v",
  2431. [ALC880_6ST] = "6stack",
  2432. [ALC880_6ST_DIG] = "6stack-digout",
  2433. [ALC880_ASUS] = "asus",
  2434. [ALC880_ASUS_W1V] = "asus-w1v",
  2435. [ALC880_ASUS_DIG] = "asus-dig",
  2436. [ALC880_ASUS_DIG2] = "asus-dig2",
  2437. [ALC880_UNIWILL_DIG] = "uniwill",
  2438. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2439. [ALC880_FUJITSU] = "fujitsu",
  2440. [ALC880_F1734] = "F1734",
  2441. [ALC880_LG] = "lg",
  2442. [ALC880_LG_LW] = "lg-lw",
  2443. #ifdef CONFIG_SND_DEBUG
  2444. [ALC880_TEST] = "test",
  2445. #endif
  2446. [ALC880_AUTO] = "auto",
  2447. };
  2448. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2449. /* Broken BIOS configuration */
  2450. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2451. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2452. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2453. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2454. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2455. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2456. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2457. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2458. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2459. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2460. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2461. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2462. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2463. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2464. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2465. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2466. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2467. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2468. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2469. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2470. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2471. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2472. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2473. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2474. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2475. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2476. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2477. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2478. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2479. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2480. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2481. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2482. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2483. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2484. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2485. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2486. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2487. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2488. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2489. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2490. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2491. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2492. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2493. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2494. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2495. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2496. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2497. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2498. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2499. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2500. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2501. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2502. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2503. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2504. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2505. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2506. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2507. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2508. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2509. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2510. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2511. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2512. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2513. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2514. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2515. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2516. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2517. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2518. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2519. {}
  2520. };
  2521. /*
  2522. * ALC880 codec presets
  2523. */
  2524. static struct alc_config_preset alc880_presets[] = {
  2525. [ALC880_3ST] = {
  2526. .mixers = { alc880_three_stack_mixer },
  2527. .init_verbs = { alc880_volume_init_verbs,
  2528. alc880_pin_3stack_init_verbs },
  2529. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2530. .dac_nids = alc880_dac_nids,
  2531. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2532. .channel_mode = alc880_threestack_modes,
  2533. .need_dac_fix = 1,
  2534. .input_mux = &alc880_capture_source,
  2535. },
  2536. [ALC880_3ST_DIG] = {
  2537. .mixers = { alc880_three_stack_mixer },
  2538. .init_verbs = { alc880_volume_init_verbs,
  2539. alc880_pin_3stack_init_verbs },
  2540. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2541. .dac_nids = alc880_dac_nids,
  2542. .dig_out_nid = ALC880_DIGOUT_NID,
  2543. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2544. .channel_mode = alc880_threestack_modes,
  2545. .need_dac_fix = 1,
  2546. .input_mux = &alc880_capture_source,
  2547. },
  2548. [ALC880_TCL_S700] = {
  2549. .mixers = { alc880_tcl_s700_mixer },
  2550. .init_verbs = { alc880_volume_init_verbs,
  2551. alc880_pin_tcl_S700_init_verbs,
  2552. alc880_gpio2_init_verbs },
  2553. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2554. .dac_nids = alc880_dac_nids,
  2555. .hp_nid = 0x03,
  2556. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2557. .channel_mode = alc880_2_jack_modes,
  2558. .input_mux = &alc880_capture_source,
  2559. },
  2560. [ALC880_5ST] = {
  2561. .mixers = { alc880_three_stack_mixer,
  2562. alc880_five_stack_mixer},
  2563. .init_verbs = { alc880_volume_init_verbs,
  2564. alc880_pin_5stack_init_verbs },
  2565. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2566. .dac_nids = alc880_dac_nids,
  2567. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2568. .channel_mode = alc880_fivestack_modes,
  2569. .input_mux = &alc880_capture_source,
  2570. },
  2571. [ALC880_5ST_DIG] = {
  2572. .mixers = { alc880_three_stack_mixer,
  2573. alc880_five_stack_mixer },
  2574. .init_verbs = { alc880_volume_init_verbs,
  2575. alc880_pin_5stack_init_verbs },
  2576. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2577. .dac_nids = alc880_dac_nids,
  2578. .dig_out_nid = ALC880_DIGOUT_NID,
  2579. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2580. .channel_mode = alc880_fivestack_modes,
  2581. .input_mux = &alc880_capture_source,
  2582. },
  2583. [ALC880_6ST] = {
  2584. .mixers = { alc880_six_stack_mixer },
  2585. .init_verbs = { alc880_volume_init_verbs,
  2586. alc880_pin_6stack_init_verbs },
  2587. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2588. .dac_nids = alc880_6st_dac_nids,
  2589. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2590. .channel_mode = alc880_sixstack_modes,
  2591. .input_mux = &alc880_6stack_capture_source,
  2592. },
  2593. [ALC880_6ST_DIG] = {
  2594. .mixers = { alc880_six_stack_mixer },
  2595. .init_verbs = { alc880_volume_init_verbs,
  2596. alc880_pin_6stack_init_verbs },
  2597. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2598. .dac_nids = alc880_6st_dac_nids,
  2599. .dig_out_nid = ALC880_DIGOUT_NID,
  2600. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2601. .channel_mode = alc880_sixstack_modes,
  2602. .input_mux = &alc880_6stack_capture_source,
  2603. },
  2604. [ALC880_W810] = {
  2605. .mixers = { alc880_w810_base_mixer },
  2606. .init_verbs = { alc880_volume_init_verbs,
  2607. alc880_pin_w810_init_verbs,
  2608. alc880_gpio2_init_verbs },
  2609. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2610. .dac_nids = alc880_w810_dac_nids,
  2611. .dig_out_nid = ALC880_DIGOUT_NID,
  2612. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2613. .channel_mode = alc880_w810_modes,
  2614. .input_mux = &alc880_capture_source,
  2615. },
  2616. [ALC880_Z71V] = {
  2617. .mixers = { alc880_z71v_mixer },
  2618. .init_verbs = { alc880_volume_init_verbs,
  2619. alc880_pin_z71v_init_verbs },
  2620. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2621. .dac_nids = alc880_z71v_dac_nids,
  2622. .dig_out_nid = ALC880_DIGOUT_NID,
  2623. .hp_nid = 0x03,
  2624. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2625. .channel_mode = alc880_2_jack_modes,
  2626. .input_mux = &alc880_capture_source,
  2627. },
  2628. [ALC880_F1734] = {
  2629. .mixers = { alc880_f1734_mixer },
  2630. .init_verbs = { alc880_volume_init_verbs,
  2631. alc880_pin_f1734_init_verbs },
  2632. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2633. .dac_nids = alc880_f1734_dac_nids,
  2634. .hp_nid = 0x02,
  2635. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2636. .channel_mode = alc880_2_jack_modes,
  2637. .input_mux = &alc880_capture_source,
  2638. },
  2639. [ALC880_ASUS] = {
  2640. .mixers = { alc880_asus_mixer },
  2641. .init_verbs = { alc880_volume_init_verbs,
  2642. alc880_pin_asus_init_verbs,
  2643. alc880_gpio1_init_verbs },
  2644. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2645. .dac_nids = alc880_asus_dac_nids,
  2646. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2647. .channel_mode = alc880_asus_modes,
  2648. .need_dac_fix = 1,
  2649. .input_mux = &alc880_capture_source,
  2650. },
  2651. [ALC880_ASUS_DIG] = {
  2652. .mixers = { alc880_asus_mixer },
  2653. .init_verbs = { alc880_volume_init_verbs,
  2654. alc880_pin_asus_init_verbs,
  2655. alc880_gpio1_init_verbs },
  2656. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2657. .dac_nids = alc880_asus_dac_nids,
  2658. .dig_out_nid = ALC880_DIGOUT_NID,
  2659. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2660. .channel_mode = alc880_asus_modes,
  2661. .need_dac_fix = 1,
  2662. .input_mux = &alc880_capture_source,
  2663. },
  2664. [ALC880_ASUS_DIG2] = {
  2665. .mixers = { alc880_asus_mixer },
  2666. .init_verbs = { alc880_volume_init_verbs,
  2667. alc880_pin_asus_init_verbs,
  2668. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2669. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2670. .dac_nids = alc880_asus_dac_nids,
  2671. .dig_out_nid = ALC880_DIGOUT_NID,
  2672. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2673. .channel_mode = alc880_asus_modes,
  2674. .need_dac_fix = 1,
  2675. .input_mux = &alc880_capture_source,
  2676. },
  2677. [ALC880_ASUS_W1V] = {
  2678. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2679. .init_verbs = { alc880_volume_init_verbs,
  2680. alc880_pin_asus_init_verbs,
  2681. alc880_gpio1_init_verbs },
  2682. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2683. .dac_nids = alc880_asus_dac_nids,
  2684. .dig_out_nid = ALC880_DIGOUT_NID,
  2685. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2686. .channel_mode = alc880_asus_modes,
  2687. .need_dac_fix = 1,
  2688. .input_mux = &alc880_capture_source,
  2689. },
  2690. [ALC880_UNIWILL_DIG] = {
  2691. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2692. .init_verbs = { alc880_volume_init_verbs,
  2693. alc880_pin_asus_init_verbs },
  2694. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2695. .dac_nids = alc880_asus_dac_nids,
  2696. .dig_out_nid = ALC880_DIGOUT_NID,
  2697. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2698. .channel_mode = alc880_asus_modes,
  2699. .need_dac_fix = 1,
  2700. .input_mux = &alc880_capture_source,
  2701. },
  2702. [ALC880_UNIWILL] = {
  2703. .mixers = { alc880_uniwill_mixer },
  2704. .init_verbs = { alc880_volume_init_verbs,
  2705. alc880_uniwill_init_verbs },
  2706. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2707. .dac_nids = alc880_asus_dac_nids,
  2708. .dig_out_nid = ALC880_DIGOUT_NID,
  2709. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2710. .channel_mode = alc880_threestack_modes,
  2711. .need_dac_fix = 1,
  2712. .input_mux = &alc880_capture_source,
  2713. .unsol_event = alc880_uniwill_unsol_event,
  2714. .init_hook = alc880_uniwill_automute,
  2715. },
  2716. [ALC880_UNIWILL_P53] = {
  2717. .mixers = { alc880_uniwill_p53_mixer },
  2718. .init_verbs = { alc880_volume_init_verbs,
  2719. alc880_uniwill_p53_init_verbs },
  2720. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2721. .dac_nids = alc880_asus_dac_nids,
  2722. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2723. .channel_mode = alc880_threestack_modes,
  2724. .input_mux = &alc880_capture_source,
  2725. .unsol_event = alc880_uniwill_p53_unsol_event,
  2726. .init_hook = alc880_uniwill_p53_hp_automute,
  2727. },
  2728. [ALC880_FUJITSU] = {
  2729. .mixers = { alc880_fujitsu_mixer,
  2730. alc880_pcbeep_mixer, },
  2731. .init_verbs = { alc880_volume_init_verbs,
  2732. alc880_uniwill_p53_init_verbs,
  2733. alc880_beep_init_verbs },
  2734. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2735. .dac_nids = alc880_dac_nids,
  2736. .dig_out_nid = ALC880_DIGOUT_NID,
  2737. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2738. .channel_mode = alc880_2_jack_modes,
  2739. .input_mux = &alc880_capture_source,
  2740. .unsol_event = alc880_uniwill_p53_unsol_event,
  2741. .init_hook = alc880_uniwill_p53_hp_automute,
  2742. },
  2743. [ALC880_CLEVO] = {
  2744. .mixers = { alc880_three_stack_mixer },
  2745. .init_verbs = { alc880_volume_init_verbs,
  2746. alc880_pin_clevo_init_verbs },
  2747. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2748. .dac_nids = alc880_dac_nids,
  2749. .hp_nid = 0x03,
  2750. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2751. .channel_mode = alc880_threestack_modes,
  2752. .need_dac_fix = 1,
  2753. .input_mux = &alc880_capture_source,
  2754. },
  2755. [ALC880_LG] = {
  2756. .mixers = { alc880_lg_mixer },
  2757. .init_verbs = { alc880_volume_init_verbs,
  2758. alc880_lg_init_verbs },
  2759. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2760. .dac_nids = alc880_lg_dac_nids,
  2761. .dig_out_nid = ALC880_DIGOUT_NID,
  2762. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2763. .channel_mode = alc880_lg_ch_modes,
  2764. .need_dac_fix = 1,
  2765. .input_mux = &alc880_lg_capture_source,
  2766. .unsol_event = alc880_lg_unsol_event,
  2767. .init_hook = alc880_lg_automute,
  2768. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2769. .loopbacks = alc880_lg_loopbacks,
  2770. #endif
  2771. },
  2772. [ALC880_LG_LW] = {
  2773. .mixers = { alc880_lg_lw_mixer },
  2774. .init_verbs = { alc880_volume_init_verbs,
  2775. alc880_lg_lw_init_verbs },
  2776. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2777. .dac_nids = alc880_dac_nids,
  2778. .dig_out_nid = ALC880_DIGOUT_NID,
  2779. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2780. .channel_mode = alc880_lg_lw_modes,
  2781. .input_mux = &alc880_lg_lw_capture_source,
  2782. .unsol_event = alc880_lg_lw_unsol_event,
  2783. .init_hook = alc880_lg_lw_automute,
  2784. },
  2785. #ifdef CONFIG_SND_DEBUG
  2786. [ALC880_TEST] = {
  2787. .mixers = { alc880_test_mixer },
  2788. .init_verbs = { alc880_test_init_verbs },
  2789. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2790. .dac_nids = alc880_test_dac_nids,
  2791. .dig_out_nid = ALC880_DIGOUT_NID,
  2792. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2793. .channel_mode = alc880_test_modes,
  2794. .input_mux = &alc880_test_capture_source,
  2795. },
  2796. #endif
  2797. };
  2798. /*
  2799. * Automatic parse of I/O pins from the BIOS configuration
  2800. */
  2801. #define NUM_CONTROL_ALLOC 32
  2802. #define NUM_VERB_ALLOC 32
  2803. enum {
  2804. ALC_CTL_WIDGET_VOL,
  2805. ALC_CTL_WIDGET_MUTE,
  2806. ALC_CTL_BIND_MUTE,
  2807. };
  2808. static struct snd_kcontrol_new alc880_control_templates[] = {
  2809. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2810. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2811. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2812. };
  2813. /* add dynamic controls */
  2814. static int add_control(struct alc_spec *spec, int type, const char *name,
  2815. unsigned long val)
  2816. {
  2817. struct snd_kcontrol_new *knew;
  2818. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2819. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2820. /* array + terminator */
  2821. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2822. if (!knew)
  2823. return -ENOMEM;
  2824. if (spec->kctl_alloc) {
  2825. memcpy(knew, spec->kctl_alloc,
  2826. sizeof(*knew) * spec->num_kctl_alloc);
  2827. kfree(spec->kctl_alloc);
  2828. }
  2829. spec->kctl_alloc = knew;
  2830. spec->num_kctl_alloc = num;
  2831. }
  2832. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2833. *knew = alc880_control_templates[type];
  2834. knew->name = kstrdup(name, GFP_KERNEL);
  2835. if (!knew->name)
  2836. return -ENOMEM;
  2837. knew->private_value = val;
  2838. spec->num_kctl_used++;
  2839. return 0;
  2840. }
  2841. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2842. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2843. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2844. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2845. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2846. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2847. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2848. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2849. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2850. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2851. #define ALC880_PIN_CD_NID 0x1c
  2852. /* fill in the dac_nids table from the parsed pin configuration */
  2853. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2854. const struct auto_pin_cfg *cfg)
  2855. {
  2856. hda_nid_t nid;
  2857. int assigned[4];
  2858. int i, j;
  2859. memset(assigned, 0, sizeof(assigned));
  2860. spec->multiout.dac_nids = spec->private_dac_nids;
  2861. /* check the pins hardwired to audio widget */
  2862. for (i = 0; i < cfg->line_outs; i++) {
  2863. nid = cfg->line_out_pins[i];
  2864. if (alc880_is_fixed_pin(nid)) {
  2865. int idx = alc880_fixed_pin_idx(nid);
  2866. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2867. assigned[idx] = 1;
  2868. }
  2869. }
  2870. /* left pins can be connect to any audio widget */
  2871. for (i = 0; i < cfg->line_outs; i++) {
  2872. nid = cfg->line_out_pins[i];
  2873. if (alc880_is_fixed_pin(nid))
  2874. continue;
  2875. /* search for an empty channel */
  2876. for (j = 0; j < cfg->line_outs; j++) {
  2877. if (!assigned[j]) {
  2878. spec->multiout.dac_nids[i] =
  2879. alc880_idx_to_dac(j);
  2880. assigned[j] = 1;
  2881. break;
  2882. }
  2883. }
  2884. }
  2885. spec->multiout.num_dacs = cfg->line_outs;
  2886. return 0;
  2887. }
  2888. /* add playback controls from the parsed DAC table */
  2889. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2890. const struct auto_pin_cfg *cfg)
  2891. {
  2892. char name[32];
  2893. static const char *chname[4] = {
  2894. "Front", "Surround", NULL /*CLFE*/, "Side"
  2895. };
  2896. hda_nid_t nid;
  2897. int i, err;
  2898. for (i = 0; i < cfg->line_outs; i++) {
  2899. if (!spec->multiout.dac_nids[i])
  2900. continue;
  2901. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2902. if (i == 2) {
  2903. /* Center/LFE */
  2904. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2905. "Center Playback Volume",
  2906. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2907. HDA_OUTPUT));
  2908. if (err < 0)
  2909. return err;
  2910. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2911. "LFE Playback Volume",
  2912. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2913. HDA_OUTPUT));
  2914. if (err < 0)
  2915. return err;
  2916. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2917. "Center Playback Switch",
  2918. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2919. HDA_INPUT));
  2920. if (err < 0)
  2921. return err;
  2922. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2923. "LFE Playback Switch",
  2924. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2925. HDA_INPUT));
  2926. if (err < 0)
  2927. return err;
  2928. } else {
  2929. sprintf(name, "%s Playback Volume", chname[i]);
  2930. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2931. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2932. HDA_OUTPUT));
  2933. if (err < 0)
  2934. return err;
  2935. sprintf(name, "%s Playback Switch", chname[i]);
  2936. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2937. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2938. HDA_INPUT));
  2939. if (err < 0)
  2940. return err;
  2941. }
  2942. }
  2943. return 0;
  2944. }
  2945. /* add playback controls for speaker and HP outputs */
  2946. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2947. const char *pfx)
  2948. {
  2949. hda_nid_t nid;
  2950. int err;
  2951. char name[32];
  2952. if (!pin)
  2953. return 0;
  2954. if (alc880_is_fixed_pin(pin)) {
  2955. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2956. /* specify the DAC as the extra output */
  2957. if (!spec->multiout.hp_nid)
  2958. spec->multiout.hp_nid = nid;
  2959. else
  2960. spec->multiout.extra_out_nid[0] = nid;
  2961. /* control HP volume/switch on the output mixer amp */
  2962. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2963. sprintf(name, "%s Playback Volume", pfx);
  2964. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2965. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2966. if (err < 0)
  2967. return err;
  2968. sprintf(name, "%s Playback Switch", pfx);
  2969. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2970. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2971. if (err < 0)
  2972. return err;
  2973. } else if (alc880_is_multi_pin(pin)) {
  2974. /* set manual connection */
  2975. /* we have only a switch on HP-out PIN */
  2976. sprintf(name, "%s Playback Switch", pfx);
  2977. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2978. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2979. if (err < 0)
  2980. return err;
  2981. }
  2982. return 0;
  2983. }
  2984. /* create input playback/capture controls for the given pin */
  2985. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2986. const char *ctlname,
  2987. int idx, hda_nid_t mix_nid)
  2988. {
  2989. char name[32];
  2990. int err;
  2991. sprintf(name, "%s Playback Volume", ctlname);
  2992. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2993. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2994. if (err < 0)
  2995. return err;
  2996. sprintf(name, "%s Playback Switch", ctlname);
  2997. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2998. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2999. if (err < 0)
  3000. return err;
  3001. return 0;
  3002. }
  3003. /* create playback/capture controls for input pins */
  3004. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3005. const struct auto_pin_cfg *cfg)
  3006. {
  3007. struct hda_input_mux *imux = &spec->private_imux;
  3008. int i, err, idx;
  3009. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3010. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3011. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3012. err = new_analog_input(spec, cfg->input_pins[i],
  3013. auto_pin_cfg_labels[i],
  3014. idx, 0x0b);
  3015. if (err < 0)
  3016. return err;
  3017. imux->items[imux->num_items].label =
  3018. auto_pin_cfg_labels[i];
  3019. imux->items[imux->num_items].index =
  3020. alc880_input_pin_idx(cfg->input_pins[i]);
  3021. imux->num_items++;
  3022. }
  3023. }
  3024. return 0;
  3025. }
  3026. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3027. hda_nid_t nid, int pin_type,
  3028. int dac_idx)
  3029. {
  3030. /* set as output */
  3031. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3032. pin_type);
  3033. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3034. AMP_OUT_UNMUTE);
  3035. /* need the manual connection? */
  3036. if (alc880_is_multi_pin(nid)) {
  3037. struct alc_spec *spec = codec->spec;
  3038. int idx = alc880_multi_pin_idx(nid);
  3039. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3040. AC_VERB_SET_CONNECT_SEL,
  3041. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3042. }
  3043. }
  3044. static int get_pin_type(int line_out_type)
  3045. {
  3046. if (line_out_type == AUTO_PIN_HP_OUT)
  3047. return PIN_HP;
  3048. else
  3049. return PIN_OUT;
  3050. }
  3051. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3052. {
  3053. struct alc_spec *spec = codec->spec;
  3054. int i;
  3055. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3056. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3057. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3058. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3059. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3060. }
  3061. }
  3062. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3063. {
  3064. struct alc_spec *spec = codec->spec;
  3065. hda_nid_t pin;
  3066. pin = spec->autocfg.speaker_pins[0];
  3067. if (pin) /* connect to front */
  3068. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3069. pin = spec->autocfg.hp_pins[0];
  3070. if (pin) /* connect to front */
  3071. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3072. }
  3073. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3074. {
  3075. struct alc_spec *spec = codec->spec;
  3076. int i;
  3077. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3078. hda_nid_t nid = spec->autocfg.input_pins[i];
  3079. if (alc880_is_input_pin(nid)) {
  3080. snd_hda_codec_write(codec, nid, 0,
  3081. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3082. i <= AUTO_PIN_FRONT_MIC ?
  3083. PIN_VREF80 : PIN_IN);
  3084. if (nid != ALC880_PIN_CD_NID)
  3085. snd_hda_codec_write(codec, nid, 0,
  3086. AC_VERB_SET_AMP_GAIN_MUTE,
  3087. AMP_OUT_MUTE);
  3088. }
  3089. }
  3090. }
  3091. /* parse the BIOS configuration and set up the alc_spec */
  3092. /* return 1 if successful, 0 if the proper config is not found,
  3093. * or a negative error code
  3094. */
  3095. static int alc880_parse_auto_config(struct hda_codec *codec)
  3096. {
  3097. struct alc_spec *spec = codec->spec;
  3098. int err;
  3099. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3100. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3101. alc880_ignore);
  3102. if (err < 0)
  3103. return err;
  3104. if (!spec->autocfg.line_outs)
  3105. return 0; /* can't find valid BIOS pin config */
  3106. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3107. if (err < 0)
  3108. return err;
  3109. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3110. if (err < 0)
  3111. return err;
  3112. err = alc880_auto_create_extra_out(spec,
  3113. spec->autocfg.speaker_pins[0],
  3114. "Speaker");
  3115. if (err < 0)
  3116. return err;
  3117. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3118. "Headphone");
  3119. if (err < 0)
  3120. return err;
  3121. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3122. if (err < 0)
  3123. return err;
  3124. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3125. if (spec->autocfg.dig_out_pin)
  3126. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3127. if (spec->autocfg.dig_in_pin)
  3128. spec->dig_in_nid = ALC880_DIGIN_NID;
  3129. if (spec->kctl_alloc)
  3130. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3131. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3132. spec->num_mux_defs = 1;
  3133. spec->input_mux = &spec->private_imux;
  3134. return 1;
  3135. }
  3136. /* additional initialization for auto-configuration model */
  3137. static void alc880_auto_init(struct hda_codec *codec)
  3138. {
  3139. alc880_auto_init_multi_out(codec);
  3140. alc880_auto_init_extra_out(codec);
  3141. alc880_auto_init_analog_input(codec);
  3142. }
  3143. /*
  3144. * OK, here we have finally the patch for ALC880
  3145. */
  3146. static int patch_alc880(struct hda_codec *codec)
  3147. {
  3148. struct alc_spec *spec;
  3149. int board_config;
  3150. int err;
  3151. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3152. if (spec == NULL)
  3153. return -ENOMEM;
  3154. codec->spec = spec;
  3155. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3156. alc880_models,
  3157. alc880_cfg_tbl);
  3158. if (board_config < 0) {
  3159. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3160. "trying auto-probe from BIOS...\n");
  3161. board_config = ALC880_AUTO;
  3162. }
  3163. if (board_config == ALC880_AUTO) {
  3164. /* automatic parse from the BIOS config */
  3165. err = alc880_parse_auto_config(codec);
  3166. if (err < 0) {
  3167. alc_free(codec);
  3168. return err;
  3169. } else if (!err) {
  3170. printk(KERN_INFO
  3171. "hda_codec: Cannot set up configuration "
  3172. "from BIOS. Using 3-stack mode...\n");
  3173. board_config = ALC880_3ST;
  3174. }
  3175. }
  3176. if (board_config != ALC880_AUTO)
  3177. setup_preset(spec, &alc880_presets[board_config]);
  3178. spec->stream_name_analog = "ALC880 Analog";
  3179. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3180. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3181. spec->stream_name_digital = "ALC880 Digital";
  3182. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3183. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3184. if (!spec->adc_nids && spec->input_mux) {
  3185. /* check whether NID 0x07 is valid */
  3186. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3187. /* get type */
  3188. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3189. if (wcap != AC_WID_AUD_IN) {
  3190. spec->adc_nids = alc880_adc_nids_alt;
  3191. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3192. spec->mixers[spec->num_mixers] =
  3193. alc880_capture_alt_mixer;
  3194. spec->num_mixers++;
  3195. } else {
  3196. spec->adc_nids = alc880_adc_nids;
  3197. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3198. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3199. spec->num_mixers++;
  3200. }
  3201. }
  3202. codec->patch_ops = alc_patch_ops;
  3203. if (board_config == ALC880_AUTO)
  3204. spec->init_hook = alc880_auto_init;
  3205. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3206. if (!spec->loopback.amplist)
  3207. spec->loopback.amplist = alc880_loopbacks;
  3208. #endif
  3209. return 0;
  3210. }
  3211. /*
  3212. * ALC260 support
  3213. */
  3214. static hda_nid_t alc260_dac_nids[1] = {
  3215. /* front */
  3216. 0x02,
  3217. };
  3218. static hda_nid_t alc260_adc_nids[1] = {
  3219. /* ADC0 */
  3220. 0x04,
  3221. };
  3222. static hda_nid_t alc260_adc_nids_alt[1] = {
  3223. /* ADC1 */
  3224. 0x05,
  3225. };
  3226. static hda_nid_t alc260_hp_adc_nids[2] = {
  3227. /* ADC1, 0 */
  3228. 0x05, 0x04
  3229. };
  3230. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3231. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3232. */
  3233. static hda_nid_t alc260_dual_adc_nids[2] = {
  3234. /* ADC0, ADC1 */
  3235. 0x04, 0x05
  3236. };
  3237. #define ALC260_DIGOUT_NID 0x03
  3238. #define ALC260_DIGIN_NID 0x06
  3239. static struct hda_input_mux alc260_capture_source = {
  3240. .num_items = 4,
  3241. .items = {
  3242. { "Mic", 0x0 },
  3243. { "Front Mic", 0x1 },
  3244. { "Line", 0x2 },
  3245. { "CD", 0x4 },
  3246. },
  3247. };
  3248. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3249. * headphone jack and the internal CD lines since these are the only pins at
  3250. * which audio can appear. For flexibility, also allow the option of
  3251. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3252. * connection to the mixer output).
  3253. */
  3254. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3255. {
  3256. .num_items = 3,
  3257. .items = {
  3258. { "Mic/Line", 0x0 },
  3259. { "CD", 0x4 },
  3260. { "Headphone", 0x2 },
  3261. },
  3262. },
  3263. {
  3264. .num_items = 4,
  3265. .items = {
  3266. { "Mic/Line", 0x0 },
  3267. { "CD", 0x4 },
  3268. { "Headphone", 0x2 },
  3269. { "Mixer", 0x5 },
  3270. },
  3271. },
  3272. };
  3273. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3274. * the Fujitsu S702x, but jacks are marked differently.
  3275. */
  3276. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3277. {
  3278. .num_items = 4,
  3279. .items = {
  3280. { "Mic", 0x0 },
  3281. { "Line", 0x2 },
  3282. { "CD", 0x4 },
  3283. { "Headphone", 0x5 },
  3284. },
  3285. },
  3286. {
  3287. .num_items = 5,
  3288. .items = {
  3289. { "Mic", 0x0 },
  3290. { "Line", 0x2 },
  3291. { "CD", 0x4 },
  3292. { "Headphone", 0x6 },
  3293. { "Mixer", 0x5 },
  3294. },
  3295. },
  3296. };
  3297. /*
  3298. * This is just place-holder, so there's something for alc_build_pcms to look
  3299. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3300. * element which allows changing the channel mode, so the verb list is
  3301. * never used.
  3302. */
  3303. static struct hda_channel_mode alc260_modes[1] = {
  3304. { 2, NULL },
  3305. };
  3306. /* Mixer combinations
  3307. *
  3308. * basic: base_output + input + pc_beep + capture
  3309. * HP: base_output + input + capture_alt
  3310. * HP_3013: hp_3013 + input + capture
  3311. * fujitsu: fujitsu + capture
  3312. * acer: acer + capture
  3313. */
  3314. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3315. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3316. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3317. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3318. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3319. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3320. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3321. { } /* end */
  3322. };
  3323. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3324. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3325. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3326. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3327. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3328. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3329. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3330. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3331. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3332. { } /* end */
  3333. };
  3334. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3335. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3336. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3337. { } /* end */
  3338. };
  3339. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3340. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3341. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3342. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3343. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3344. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3345. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3346. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3347. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3348. { } /* end */
  3349. };
  3350. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3351. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3352. */
  3353. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3354. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3355. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3356. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3357. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3358. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3359. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3360. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3361. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3362. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3363. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3364. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3365. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3366. { } /* end */
  3367. };
  3368. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3369. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3370. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3371. * datasheet doesn't mention this restriction. At this stage it's not clear
  3372. * whether this behaviour is intentional or is a hardware bug in chip
  3373. * revisions available in early 2006. Therefore for now allow the
  3374. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3375. * that the lack of mic bias for this NID is intentional we could change the
  3376. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3377. *
  3378. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3379. * don't appear to make the mic bias available from the "line" jack, even
  3380. * though the NID used for this jack (0x14) can supply it. The theory is
  3381. * that perhaps Acer have included blocking capacitors between the ALC260
  3382. * and the output jack. If this turns out to be the case for all such
  3383. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3384. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3385. *
  3386. * The C20x Tablet series have a mono internal speaker which is controlled
  3387. * via the chip's Mono sum widget and pin complex, so include the necessary
  3388. * controls for such models. On models without a "mono speaker" the control
  3389. * won't do anything.
  3390. */
  3391. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3392. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3393. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3394. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3395. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3396. HDA_OUTPUT),
  3397. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3398. HDA_INPUT),
  3399. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3400. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3401. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3402. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3403. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3404. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3405. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3406. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3407. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3408. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3409. { } /* end */
  3410. };
  3411. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3412. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3413. */
  3414. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3415. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3416. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3417. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3418. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3419. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3420. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3421. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3422. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3423. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3424. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3425. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3426. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3427. { } /* end */
  3428. };
  3429. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3430. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3431. */
  3432. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3433. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3434. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3435. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3436. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3437. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3438. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3439. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3440. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3441. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3442. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3443. { } /* end */
  3444. };
  3445. /* capture mixer elements */
  3446. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3447. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3448. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3449. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3450. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3451. {
  3452. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3453. /* The multiple "Capture Source" controls confuse alsamixer
  3454. * So call somewhat different..
  3455. * FIXME: the controls appear in the "playback" view!
  3456. */
  3457. /* .name = "Capture Source", */
  3458. .name = "Input Source",
  3459. .count = 2,
  3460. .info = alc_mux_enum_info,
  3461. .get = alc_mux_enum_get,
  3462. .put = alc_mux_enum_put,
  3463. },
  3464. { } /* end */
  3465. };
  3466. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3467. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3468. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3469. {
  3470. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3471. /* The multiple "Capture Source" controls confuse alsamixer
  3472. * So call somewhat different..
  3473. * FIXME: the controls appear in the "playback" view!
  3474. */
  3475. /* .name = "Capture Source", */
  3476. .name = "Input Source",
  3477. .count = 1,
  3478. .info = alc_mux_enum_info,
  3479. .get = alc_mux_enum_get,
  3480. .put = alc_mux_enum_put,
  3481. },
  3482. { } /* end */
  3483. };
  3484. /*
  3485. * initialization verbs
  3486. */
  3487. static struct hda_verb alc260_init_verbs[] = {
  3488. /* Line In pin widget for input */
  3489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3490. /* CD pin widget for input */
  3491. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3492. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3493. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3494. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3495. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3496. /* LINE-2 is used for line-out in rear */
  3497. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3498. /* select line-out */
  3499. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3500. /* LINE-OUT pin */
  3501. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3502. /* enable HP */
  3503. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3504. /* enable Mono */
  3505. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3506. /* mute capture amp left and right */
  3507. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3508. /* set connection select to line in (default select for this ADC) */
  3509. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3510. /* mute capture amp left and right */
  3511. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3512. /* set connection select to line in (default select for this ADC) */
  3513. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3514. /* set vol=0 Line-Out mixer amp left and right */
  3515. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3516. /* unmute pin widget amp left and right (no gain on this amp) */
  3517. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3518. /* set vol=0 HP mixer amp left and right */
  3519. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3520. /* unmute pin widget amp left and right (no gain on this amp) */
  3521. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3522. /* set vol=0 Mono mixer amp left and right */
  3523. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3524. /* unmute pin widget amp left and right (no gain on this amp) */
  3525. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3526. /* unmute LINE-2 out pin */
  3527. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3528. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3529. * Line In 2 = 0x03
  3530. */
  3531. /* mute analog inputs */
  3532. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3533. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3534. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3536. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3537. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3538. /* mute Front out path */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. /* mute Headphone out path */
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. /* mute Mono out path */
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. { }
  3548. };
  3549. #if 0 /* should be identical with alc260_init_verbs? */
  3550. static struct hda_verb alc260_hp_init_verbs[] = {
  3551. /* Headphone and output */
  3552. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3553. /* mono output */
  3554. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3555. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3556. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3557. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3558. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3559. /* Line In pin widget for input */
  3560. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3561. /* Line-2 pin widget for output */
  3562. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3563. /* CD pin widget for input */
  3564. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3565. /* unmute amp left and right */
  3566. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3567. /* set connection select to line in (default select for this ADC) */
  3568. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3569. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3570. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3571. /* mute pin widget amp left and right (no gain on this amp) */
  3572. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3573. /* unmute HP mixer amp left and right (volume = 0) */
  3574. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3575. /* mute pin widget amp left and right (no gain on this amp) */
  3576. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3577. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3578. * Line In 2 = 0x03
  3579. */
  3580. /* mute analog inputs */
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3582. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3583. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3584. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3585. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3586. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3587. /* Unmute Front out path */
  3588. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3589. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3590. /* Unmute Headphone out path */
  3591. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3592. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3593. /* Unmute Mono out path */
  3594. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3595. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3596. { }
  3597. };
  3598. #endif
  3599. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3600. /* Line out and output */
  3601. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3602. /* mono output */
  3603. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3604. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3605. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3606. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3607. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3608. /* Line In pin widget for input */
  3609. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3610. /* Headphone pin widget for output */
  3611. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3612. /* CD pin widget for input */
  3613. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3614. /* unmute amp left and right */
  3615. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3616. /* set connection select to line in (default select for this ADC) */
  3617. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3618. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3620. /* mute pin widget amp left and right (no gain on this amp) */
  3621. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3622. /* unmute HP mixer amp left and right (volume = 0) */
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3624. /* mute pin widget amp left and right (no gain on this amp) */
  3625. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3626. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3627. * Line In 2 = 0x03
  3628. */
  3629. /* mute analog inputs */
  3630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3635. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3636. /* Unmute Front out path */
  3637. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3638. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3639. /* Unmute Headphone out path */
  3640. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3641. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3642. /* Unmute Mono out path */
  3643. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3644. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3645. { }
  3646. };
  3647. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3648. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3649. * audio = 0x16, internal speaker = 0x10.
  3650. */
  3651. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3652. /* Disable all GPIOs */
  3653. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3654. /* Internal speaker is connected to headphone pin */
  3655. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3656. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3657. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3658. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3659. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3660. /* Ensure all other unused pins are disabled and muted. */
  3661. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3662. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3663. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3664. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3665. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3666. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3667. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3668. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3669. /* Disable digital (SPDIF) pins */
  3670. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3671. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3672. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3673. * when acting as an output.
  3674. */
  3675. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3676. /* Start with output sum widgets muted and their output gains at min */
  3677. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3678. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3679. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3680. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3682. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3683. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3684. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3685. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3686. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3687. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3688. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3689. * If the pin mode is changed by the user the pin mode control will
  3690. * take care of enabling the pin's input/output buffers as needed.
  3691. * Therefore there's no need to enable the input buffer at this
  3692. * stage.
  3693. */
  3694. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3695. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3696. * mixer ctrl)
  3697. */
  3698. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3699. /* Mute capture amp left and right */
  3700. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3701. /* Set ADC connection select to match default mixer setting - line
  3702. * in (on mic1 pin)
  3703. */
  3704. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3705. /* Do the same for the second ADC: mute capture input amp and
  3706. * set ADC connection to line in (on mic1 pin)
  3707. */
  3708. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3709. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3710. /* Mute all inputs to mixer widget (even unconnected ones) */
  3711. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3713. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3714. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3715. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3717. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3718. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3719. { }
  3720. };
  3721. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3722. * similar laptops (adapted from Fujitsu init verbs).
  3723. */
  3724. static struct hda_verb alc260_acer_init_verbs[] = {
  3725. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3726. * the headphone jack. Turn this on and rely on the standard mute
  3727. * methods whenever the user wants to turn these outputs off.
  3728. */
  3729. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3730. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3731. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3732. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3733. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3734. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3735. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3736. /* Line In jack is connected to Line1 pin */
  3737. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3738. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3739. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3740. /* Ensure all other unused pins are disabled and muted. */
  3741. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3742. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3743. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3744. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3745. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3747. /* Disable digital (SPDIF) pins */
  3748. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3749. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3750. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3751. * bus when acting as outputs.
  3752. */
  3753. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3754. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3755. /* Start with output sum widgets muted and their output gains at min */
  3756. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3758. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3759. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3761. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3762. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3763. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3764. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3765. /* Unmute Line-out pin widget amp left and right
  3766. * (no equiv mixer ctrl)
  3767. */
  3768. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3769. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3770. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3771. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3772. * inputs. If the pin mode is changed by the user the pin mode control
  3773. * will take care of enabling the pin's input/output buffers as needed.
  3774. * Therefore there's no need to enable the input buffer at this
  3775. * stage.
  3776. */
  3777. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3778. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3779. /* Mute capture amp left and right */
  3780. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3781. /* Set ADC connection select to match default mixer setting - mic
  3782. * (on mic1 pin)
  3783. */
  3784. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3785. /* Do similar with the second ADC: mute capture input amp and
  3786. * set ADC connection to mic to match ALSA's default state.
  3787. */
  3788. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3789. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3790. /* Mute all inputs to mixer widget (even unconnected ones) */
  3791. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3792. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3793. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3797. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3798. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3799. { }
  3800. };
  3801. static struct hda_verb alc260_will_verbs[] = {
  3802. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3803. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3804. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3805. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3806. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3807. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3808. {}
  3809. };
  3810. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3811. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3812. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3813. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3814. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3815. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3816. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3817. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3818. {}
  3819. };
  3820. /* toggle speaker-output according to the hp-jack state */
  3821. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3822. {
  3823. unsigned int present;
  3824. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3825. present = snd_hda_codec_read(codec, 0x0f, 0,
  3826. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3827. if (present) {
  3828. snd_hda_codec_write_cache(codec, 0x01, 0,
  3829. AC_VERB_SET_GPIO_DATA, 1);
  3830. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3831. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3832. PIN_HP);
  3833. } else {
  3834. snd_hda_codec_write_cache(codec, 0x01, 0,
  3835. AC_VERB_SET_GPIO_DATA, 0);
  3836. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3837. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3838. PIN_OUT);
  3839. }
  3840. }
  3841. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3842. unsigned int res)
  3843. {
  3844. if ((res >> 26) == ALC880_HP_EVENT)
  3845. alc260_replacer_672v_automute(codec);
  3846. }
  3847. /* Test configuration for debugging, modelled after the ALC880 test
  3848. * configuration.
  3849. */
  3850. #ifdef CONFIG_SND_DEBUG
  3851. static hda_nid_t alc260_test_dac_nids[1] = {
  3852. 0x02,
  3853. };
  3854. static hda_nid_t alc260_test_adc_nids[2] = {
  3855. 0x04, 0x05,
  3856. };
  3857. /* For testing the ALC260, each input MUX needs its own definition since
  3858. * the signal assignments are different. This assumes that the first ADC
  3859. * is NID 0x04.
  3860. */
  3861. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3862. {
  3863. .num_items = 7,
  3864. .items = {
  3865. { "MIC1 pin", 0x0 },
  3866. { "MIC2 pin", 0x1 },
  3867. { "LINE1 pin", 0x2 },
  3868. { "LINE2 pin", 0x3 },
  3869. { "CD pin", 0x4 },
  3870. { "LINE-OUT pin", 0x5 },
  3871. { "HP-OUT pin", 0x6 },
  3872. },
  3873. },
  3874. {
  3875. .num_items = 8,
  3876. .items = {
  3877. { "MIC1 pin", 0x0 },
  3878. { "MIC2 pin", 0x1 },
  3879. { "LINE1 pin", 0x2 },
  3880. { "LINE2 pin", 0x3 },
  3881. { "CD pin", 0x4 },
  3882. { "Mixer", 0x5 },
  3883. { "LINE-OUT pin", 0x6 },
  3884. { "HP-OUT pin", 0x7 },
  3885. },
  3886. },
  3887. };
  3888. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3889. /* Output driver widgets */
  3890. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3891. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3892. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3893. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3894. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3895. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3896. /* Modes for retasking pin widgets
  3897. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3898. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3899. * mention this restriction. At this stage it's not clear whether
  3900. * this behaviour is intentional or is a hardware bug in chip
  3901. * revisions available at least up until early 2006. Therefore for
  3902. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3903. * choices, but if it turns out that the lack of mic bias for these
  3904. * NIDs is intentional we could change their modes from
  3905. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3906. */
  3907. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3908. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3909. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3910. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3911. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3912. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3913. /* Loopback mixer controls */
  3914. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3915. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3916. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3917. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3918. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3919. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3920. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3921. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3922. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3923. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3924. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3925. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3926. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3927. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3928. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3929. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3930. /* Controls for GPIO pins, assuming they are configured as outputs */
  3931. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3932. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3933. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3934. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3935. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3936. * is ambigious as to which NID is which; testing on laptops which
  3937. * make this output available should provide clarification.
  3938. */
  3939. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3940. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3941. { } /* end */
  3942. };
  3943. static struct hda_verb alc260_test_init_verbs[] = {
  3944. /* Enable all GPIOs as outputs with an initial value of 0 */
  3945. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3946. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3947. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3948. /* Enable retasking pins as output, initially without power amp */
  3949. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3950. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3951. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3952. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3953. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3954. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3955. /* Disable digital (SPDIF) pins initially, but users can enable
  3956. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3957. * payload also sets the generation to 0, output to be in "consumer"
  3958. * PCM format, copyright asserted, no pre-emphasis and no validity
  3959. * control.
  3960. */
  3961. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3962. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3963. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3964. * OUT1 sum bus when acting as an output.
  3965. */
  3966. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3967. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3968. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3969. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3970. /* Start with output sum widgets muted and their output gains at min */
  3971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3972. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3973. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3974. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3975. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3976. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3977. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3978. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3979. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3980. /* Unmute retasking pin widget output buffers since the default
  3981. * state appears to be output. As the pin mode is changed by the
  3982. * user the pin mode control will take care of enabling the pin's
  3983. * input/output buffers as needed.
  3984. */
  3985. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3986. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3987. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3988. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3989. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3990. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3991. /* Also unmute the mono-out pin widget */
  3992. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3993. /* Mute capture amp left and right */
  3994. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3995. /* Set ADC connection select to match default mixer setting (mic1
  3996. * pin)
  3997. */
  3998. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3999. /* Do the same for the second ADC: mute capture input amp and
  4000. * set ADC connection to mic1 pin
  4001. */
  4002. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4003. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4004. /* Mute all inputs to mixer widget (even unconnected ones) */
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4008. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4009. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4010. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4011. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4012. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4013. { }
  4014. };
  4015. #endif
  4016. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4017. .substreams = 1,
  4018. .channels_min = 2,
  4019. .channels_max = 2,
  4020. };
  4021. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4022. .substreams = 1,
  4023. .channels_min = 2,
  4024. .channels_max = 2,
  4025. };
  4026. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4027. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4028. /*
  4029. * for BIOS auto-configuration
  4030. */
  4031. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4032. const char *pfx)
  4033. {
  4034. hda_nid_t nid_vol;
  4035. unsigned long vol_val, sw_val;
  4036. char name[32];
  4037. int err;
  4038. if (nid >= 0x0f && nid < 0x11) {
  4039. nid_vol = nid - 0x7;
  4040. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4041. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4042. } else if (nid == 0x11) {
  4043. nid_vol = nid - 0x7;
  4044. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4045. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4046. } else if (nid >= 0x12 && nid <= 0x15) {
  4047. nid_vol = 0x08;
  4048. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4049. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4050. } else
  4051. return 0; /* N/A */
  4052. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4053. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4054. if (err < 0)
  4055. return err;
  4056. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4057. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4058. if (err < 0)
  4059. return err;
  4060. return 1;
  4061. }
  4062. /* add playback controls from the parsed DAC table */
  4063. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4064. const struct auto_pin_cfg *cfg)
  4065. {
  4066. hda_nid_t nid;
  4067. int err;
  4068. spec->multiout.num_dacs = 1;
  4069. spec->multiout.dac_nids = spec->private_dac_nids;
  4070. spec->multiout.dac_nids[0] = 0x02;
  4071. nid = cfg->line_out_pins[0];
  4072. if (nid) {
  4073. err = alc260_add_playback_controls(spec, nid, "Front");
  4074. if (err < 0)
  4075. return err;
  4076. }
  4077. nid = cfg->speaker_pins[0];
  4078. if (nid) {
  4079. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4080. if (err < 0)
  4081. return err;
  4082. }
  4083. nid = cfg->hp_pins[0];
  4084. if (nid) {
  4085. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4086. if (err < 0)
  4087. return err;
  4088. }
  4089. return 0;
  4090. }
  4091. /* create playback/capture controls for input pins */
  4092. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4093. const struct auto_pin_cfg *cfg)
  4094. {
  4095. struct hda_input_mux *imux = &spec->private_imux;
  4096. int i, err, idx;
  4097. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4098. if (cfg->input_pins[i] >= 0x12) {
  4099. idx = cfg->input_pins[i] - 0x12;
  4100. err = new_analog_input(spec, cfg->input_pins[i],
  4101. auto_pin_cfg_labels[i], idx,
  4102. 0x07);
  4103. if (err < 0)
  4104. return err;
  4105. imux->items[imux->num_items].label =
  4106. auto_pin_cfg_labels[i];
  4107. imux->items[imux->num_items].index = idx;
  4108. imux->num_items++;
  4109. }
  4110. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4111. idx = cfg->input_pins[i] - 0x09;
  4112. err = new_analog_input(spec, cfg->input_pins[i],
  4113. auto_pin_cfg_labels[i], idx,
  4114. 0x07);
  4115. if (err < 0)
  4116. return err;
  4117. imux->items[imux->num_items].label =
  4118. auto_pin_cfg_labels[i];
  4119. imux->items[imux->num_items].index = idx;
  4120. imux->num_items++;
  4121. }
  4122. }
  4123. return 0;
  4124. }
  4125. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4126. hda_nid_t nid, int pin_type,
  4127. int sel_idx)
  4128. {
  4129. /* set as output */
  4130. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4131. pin_type);
  4132. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4133. AMP_OUT_UNMUTE);
  4134. /* need the manual connection? */
  4135. if (nid >= 0x12) {
  4136. int idx = nid - 0x12;
  4137. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4138. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4139. }
  4140. }
  4141. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4142. {
  4143. struct alc_spec *spec = codec->spec;
  4144. hda_nid_t nid;
  4145. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4146. nid = spec->autocfg.line_out_pins[0];
  4147. if (nid) {
  4148. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4149. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4150. }
  4151. nid = spec->autocfg.speaker_pins[0];
  4152. if (nid)
  4153. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4154. nid = spec->autocfg.hp_pins[0];
  4155. if (nid)
  4156. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4157. }
  4158. #define ALC260_PIN_CD_NID 0x16
  4159. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4160. {
  4161. struct alc_spec *spec = codec->spec;
  4162. int i;
  4163. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4164. hda_nid_t nid = spec->autocfg.input_pins[i];
  4165. if (nid >= 0x12) {
  4166. snd_hda_codec_write(codec, nid, 0,
  4167. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4168. i <= AUTO_PIN_FRONT_MIC ?
  4169. PIN_VREF80 : PIN_IN);
  4170. if (nid != ALC260_PIN_CD_NID)
  4171. snd_hda_codec_write(codec, nid, 0,
  4172. AC_VERB_SET_AMP_GAIN_MUTE,
  4173. AMP_OUT_MUTE);
  4174. }
  4175. }
  4176. }
  4177. /*
  4178. * generic initialization of ADC, input mixers and output mixers
  4179. */
  4180. static struct hda_verb alc260_volume_init_verbs[] = {
  4181. /*
  4182. * Unmute ADC0-1 and set the default input to mic-in
  4183. */
  4184. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4185. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4186. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4187. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4188. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4189. * mixer widget
  4190. * Note: PASD motherboards uses the Line In 2 as the input for
  4191. * front panel mic (mic 2)
  4192. */
  4193. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4194. /* mute analog inputs */
  4195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4199. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4200. /*
  4201. * Set up output mixers (0x08 - 0x0a)
  4202. */
  4203. /* set vol=0 to output mixers */
  4204. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4205. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4206. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4207. /* set up input amps for analog loopback */
  4208. /* Amp Indices: DAC = 0, mixer = 1 */
  4209. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4210. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4211. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4212. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4213. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4214. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4215. { }
  4216. };
  4217. static int alc260_parse_auto_config(struct hda_codec *codec)
  4218. {
  4219. struct alc_spec *spec = codec->spec;
  4220. unsigned int wcap;
  4221. int err;
  4222. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4223. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4224. alc260_ignore);
  4225. if (err < 0)
  4226. return err;
  4227. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4228. if (err < 0)
  4229. return err;
  4230. if (!spec->kctl_alloc)
  4231. return 0; /* can't find valid BIOS pin config */
  4232. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4233. if (err < 0)
  4234. return err;
  4235. spec->multiout.max_channels = 2;
  4236. if (spec->autocfg.dig_out_pin)
  4237. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4238. if (spec->kctl_alloc)
  4239. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4240. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4241. spec->num_mux_defs = 1;
  4242. spec->input_mux = &spec->private_imux;
  4243. /* check whether NID 0x04 is valid */
  4244. wcap = get_wcaps(codec, 0x04);
  4245. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4246. if (wcap != AC_WID_AUD_IN) {
  4247. spec->adc_nids = alc260_adc_nids_alt;
  4248. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4249. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4250. } else {
  4251. spec->adc_nids = alc260_adc_nids;
  4252. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4253. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4254. }
  4255. spec->num_mixers++;
  4256. return 1;
  4257. }
  4258. /* additional initialization for auto-configuration model */
  4259. static void alc260_auto_init(struct hda_codec *codec)
  4260. {
  4261. alc260_auto_init_multi_out(codec);
  4262. alc260_auto_init_analog_input(codec);
  4263. }
  4264. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4265. static struct hda_amp_list alc260_loopbacks[] = {
  4266. { 0x07, HDA_INPUT, 0 },
  4267. { 0x07, HDA_INPUT, 1 },
  4268. { 0x07, HDA_INPUT, 2 },
  4269. { 0x07, HDA_INPUT, 3 },
  4270. { 0x07, HDA_INPUT, 4 },
  4271. { } /* end */
  4272. };
  4273. #endif
  4274. /*
  4275. * ALC260 configurations
  4276. */
  4277. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4278. [ALC260_BASIC] = "basic",
  4279. [ALC260_HP] = "hp",
  4280. [ALC260_HP_3013] = "hp-3013",
  4281. [ALC260_FUJITSU_S702X] = "fujitsu",
  4282. [ALC260_ACER] = "acer",
  4283. [ALC260_WILL] = "will",
  4284. [ALC260_REPLACER_672V] = "replacer",
  4285. #ifdef CONFIG_SND_DEBUG
  4286. [ALC260_TEST] = "test",
  4287. #endif
  4288. [ALC260_AUTO] = "auto",
  4289. };
  4290. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4291. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4292. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4293. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4294. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4295. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4296. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4297. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4298. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4299. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4300. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4301. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4302. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4303. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4304. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4305. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4306. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4307. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4308. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4309. {}
  4310. };
  4311. static struct alc_config_preset alc260_presets[] = {
  4312. [ALC260_BASIC] = {
  4313. .mixers = { alc260_base_output_mixer,
  4314. alc260_input_mixer,
  4315. alc260_pc_beep_mixer,
  4316. alc260_capture_mixer },
  4317. .init_verbs = { alc260_init_verbs },
  4318. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4319. .dac_nids = alc260_dac_nids,
  4320. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4321. .adc_nids = alc260_adc_nids,
  4322. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4323. .channel_mode = alc260_modes,
  4324. .input_mux = &alc260_capture_source,
  4325. },
  4326. [ALC260_HP] = {
  4327. .mixers = { alc260_base_output_mixer,
  4328. alc260_input_mixer,
  4329. alc260_capture_alt_mixer },
  4330. .init_verbs = { alc260_init_verbs },
  4331. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4332. .dac_nids = alc260_dac_nids,
  4333. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4334. .adc_nids = alc260_hp_adc_nids,
  4335. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4336. .channel_mode = alc260_modes,
  4337. .input_mux = &alc260_capture_source,
  4338. },
  4339. [ALC260_HP_3013] = {
  4340. .mixers = { alc260_hp_3013_mixer,
  4341. alc260_input_mixer,
  4342. alc260_capture_alt_mixer },
  4343. .init_verbs = { alc260_hp_3013_init_verbs },
  4344. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4345. .dac_nids = alc260_dac_nids,
  4346. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4347. .adc_nids = alc260_hp_adc_nids,
  4348. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4349. .channel_mode = alc260_modes,
  4350. .input_mux = &alc260_capture_source,
  4351. },
  4352. [ALC260_FUJITSU_S702X] = {
  4353. .mixers = { alc260_fujitsu_mixer,
  4354. alc260_capture_mixer },
  4355. .init_verbs = { alc260_fujitsu_init_verbs },
  4356. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4357. .dac_nids = alc260_dac_nids,
  4358. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4359. .adc_nids = alc260_dual_adc_nids,
  4360. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4361. .channel_mode = alc260_modes,
  4362. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4363. .input_mux = alc260_fujitsu_capture_sources,
  4364. },
  4365. [ALC260_ACER] = {
  4366. .mixers = { alc260_acer_mixer,
  4367. alc260_capture_mixer },
  4368. .init_verbs = { alc260_acer_init_verbs },
  4369. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4370. .dac_nids = alc260_dac_nids,
  4371. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4372. .adc_nids = alc260_dual_adc_nids,
  4373. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4374. .channel_mode = alc260_modes,
  4375. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4376. .input_mux = alc260_acer_capture_sources,
  4377. },
  4378. [ALC260_WILL] = {
  4379. .mixers = { alc260_will_mixer,
  4380. alc260_capture_mixer },
  4381. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4382. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4383. .dac_nids = alc260_dac_nids,
  4384. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4385. .adc_nids = alc260_adc_nids,
  4386. .dig_out_nid = ALC260_DIGOUT_NID,
  4387. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4388. .channel_mode = alc260_modes,
  4389. .input_mux = &alc260_capture_source,
  4390. },
  4391. [ALC260_REPLACER_672V] = {
  4392. .mixers = { alc260_replacer_672v_mixer,
  4393. alc260_capture_mixer },
  4394. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4395. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4396. .dac_nids = alc260_dac_nids,
  4397. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4398. .adc_nids = alc260_adc_nids,
  4399. .dig_out_nid = ALC260_DIGOUT_NID,
  4400. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4401. .channel_mode = alc260_modes,
  4402. .input_mux = &alc260_capture_source,
  4403. .unsol_event = alc260_replacer_672v_unsol_event,
  4404. .init_hook = alc260_replacer_672v_automute,
  4405. },
  4406. #ifdef CONFIG_SND_DEBUG
  4407. [ALC260_TEST] = {
  4408. .mixers = { alc260_test_mixer,
  4409. alc260_capture_mixer },
  4410. .init_verbs = { alc260_test_init_verbs },
  4411. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4412. .dac_nids = alc260_test_dac_nids,
  4413. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4414. .adc_nids = alc260_test_adc_nids,
  4415. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4416. .channel_mode = alc260_modes,
  4417. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4418. .input_mux = alc260_test_capture_sources,
  4419. },
  4420. #endif
  4421. };
  4422. static int patch_alc260(struct hda_codec *codec)
  4423. {
  4424. struct alc_spec *spec;
  4425. int err, board_config;
  4426. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4427. if (spec == NULL)
  4428. return -ENOMEM;
  4429. codec->spec = spec;
  4430. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4431. alc260_models,
  4432. alc260_cfg_tbl);
  4433. if (board_config < 0) {
  4434. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4435. "trying auto-probe from BIOS...\n");
  4436. board_config = ALC260_AUTO;
  4437. }
  4438. if (board_config == ALC260_AUTO) {
  4439. /* automatic parse from the BIOS config */
  4440. err = alc260_parse_auto_config(codec);
  4441. if (err < 0) {
  4442. alc_free(codec);
  4443. return err;
  4444. } else if (!err) {
  4445. printk(KERN_INFO
  4446. "hda_codec: Cannot set up configuration "
  4447. "from BIOS. Using base mode...\n");
  4448. board_config = ALC260_BASIC;
  4449. }
  4450. }
  4451. if (board_config != ALC260_AUTO)
  4452. setup_preset(spec, &alc260_presets[board_config]);
  4453. spec->stream_name_analog = "ALC260 Analog";
  4454. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4455. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4456. spec->stream_name_digital = "ALC260 Digital";
  4457. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4458. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4459. codec->patch_ops = alc_patch_ops;
  4460. if (board_config == ALC260_AUTO)
  4461. spec->init_hook = alc260_auto_init;
  4462. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4463. if (!spec->loopback.amplist)
  4464. spec->loopback.amplist = alc260_loopbacks;
  4465. #endif
  4466. return 0;
  4467. }
  4468. /*
  4469. * ALC882 support
  4470. *
  4471. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4472. * configuration. Each pin widget can choose any input DACs and a mixer.
  4473. * Each ADC is connected from a mixer of all inputs. This makes possible
  4474. * 6-channel independent captures.
  4475. *
  4476. * In addition, an independent DAC for the multi-playback (not used in this
  4477. * driver yet).
  4478. */
  4479. #define ALC882_DIGOUT_NID 0x06
  4480. #define ALC882_DIGIN_NID 0x0a
  4481. static struct hda_channel_mode alc882_ch_modes[1] = {
  4482. { 8, NULL }
  4483. };
  4484. static hda_nid_t alc882_dac_nids[4] = {
  4485. /* front, rear, clfe, rear_surr */
  4486. 0x02, 0x03, 0x04, 0x05
  4487. };
  4488. /* identical with ALC880 */
  4489. #define alc882_adc_nids alc880_adc_nids
  4490. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4491. /* input MUX */
  4492. /* FIXME: should be a matrix-type input source selection */
  4493. static struct hda_input_mux alc882_capture_source = {
  4494. .num_items = 4,
  4495. .items = {
  4496. { "Mic", 0x0 },
  4497. { "Front Mic", 0x1 },
  4498. { "Line", 0x2 },
  4499. { "CD", 0x4 },
  4500. },
  4501. };
  4502. #define alc882_mux_enum_info alc_mux_enum_info
  4503. #define alc882_mux_enum_get alc_mux_enum_get
  4504. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4505. struct snd_ctl_elem_value *ucontrol)
  4506. {
  4507. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4508. struct alc_spec *spec = codec->spec;
  4509. const struct hda_input_mux *imux = spec->input_mux;
  4510. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4511. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4512. hda_nid_t nid = capture_mixers[adc_idx];
  4513. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4514. unsigned int i, idx;
  4515. idx = ucontrol->value.enumerated.item[0];
  4516. if (idx >= imux->num_items)
  4517. idx = imux->num_items - 1;
  4518. if (*cur_val == idx)
  4519. return 0;
  4520. for (i = 0; i < imux->num_items; i++) {
  4521. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4522. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4523. imux->items[i].index,
  4524. HDA_AMP_MUTE, v);
  4525. }
  4526. *cur_val = idx;
  4527. return 1;
  4528. }
  4529. /*
  4530. * 2ch mode
  4531. */
  4532. static struct hda_verb alc882_3ST_ch2_init[] = {
  4533. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4534. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4535. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4536. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4537. { } /* end */
  4538. };
  4539. /*
  4540. * 6ch mode
  4541. */
  4542. static struct hda_verb alc882_3ST_ch6_init[] = {
  4543. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4544. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4545. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4546. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4547. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4548. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4549. { } /* end */
  4550. };
  4551. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4552. { 2, alc882_3ST_ch2_init },
  4553. { 6, alc882_3ST_ch6_init },
  4554. };
  4555. /*
  4556. * 6ch mode
  4557. */
  4558. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4559. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4560. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4561. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4563. { } /* end */
  4564. };
  4565. /*
  4566. * 8ch mode
  4567. */
  4568. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4569. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4570. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4573. { } /* end */
  4574. };
  4575. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4576. { 6, alc882_sixstack_ch6_init },
  4577. { 8, alc882_sixstack_ch8_init },
  4578. };
  4579. /*
  4580. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4581. */
  4582. /*
  4583. * 2ch mode
  4584. */
  4585. static struct hda_verb alc885_mbp_ch2_init[] = {
  4586. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4587. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4589. { } /* end */
  4590. };
  4591. /*
  4592. * 6ch mode
  4593. */
  4594. static struct hda_verb alc885_mbp_ch6_init[] = {
  4595. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4596. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4597. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4598. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4599. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4600. { } /* end */
  4601. };
  4602. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4603. { 2, alc885_mbp_ch2_init },
  4604. { 6, alc885_mbp_ch6_init },
  4605. };
  4606. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4607. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4608. */
  4609. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4610. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4611. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4612. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4613. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4614. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4615. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4616. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4617. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4618. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4619. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4620. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4621. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4622. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4623. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4624. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4625. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4626. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4627. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4628. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4629. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4630. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4631. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4632. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4633. { } /* end */
  4634. };
  4635. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4636. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4637. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4638. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4639. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4640. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4641. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4642. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4643. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4644. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4645. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4646. { } /* end */
  4647. };
  4648. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4649. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4650. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4651. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4652. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4656. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4657. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4658. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4659. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4660. { } /* end */
  4661. };
  4662. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4663. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4664. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4665. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4666. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4667. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4668. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4669. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4670. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4671. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4672. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4673. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4674. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4675. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4676. { } /* end */
  4677. };
  4678. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4679. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4680. */
  4681. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4682. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4683. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4684. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4685. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4686. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4687. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4688. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4689. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4690. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4691. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4692. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4693. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4694. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4695. { } /* end */
  4696. };
  4697. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4698. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4699. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4700. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4701. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4702. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4703. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4704. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4705. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4706. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4707. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4708. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4709. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4710. { } /* end */
  4711. };
  4712. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4713. {
  4714. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4715. .name = "Channel Mode",
  4716. .info = alc_ch_mode_info,
  4717. .get = alc_ch_mode_get,
  4718. .put = alc_ch_mode_put,
  4719. },
  4720. { } /* end */
  4721. };
  4722. static struct hda_verb alc882_init_verbs[] = {
  4723. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4724. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4727. /* Rear mixer */
  4728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4729. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4730. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4731. /* CLFE mixer */
  4732. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4733. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4734. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4735. /* Side mixer */
  4736. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4737. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4738. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4739. /* Front Pin: output 0 (0x0c) */
  4740. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4741. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4742. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4743. /* Rear Pin: output 1 (0x0d) */
  4744. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4746. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4747. /* CLFE Pin: output 2 (0x0e) */
  4748. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4750. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4751. /* Side Pin: output 3 (0x0f) */
  4752. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4753. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4754. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4755. /* Mic (rear) pin: input vref at 80% */
  4756. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4757. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4758. /* Front Mic pin: input vref at 80% */
  4759. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4760. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4761. /* Line In pin: input */
  4762. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4763. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4764. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4765. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4766. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4767. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4768. /* CD pin widget for input */
  4769. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4770. /* FIXME: use matrix-type input source selection */
  4771. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4772. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4773. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4774. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4775. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4776. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4777. /* Input mixer2 */
  4778. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4780. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4781. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4782. /* Input mixer3 */
  4783. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4784. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4785. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4786. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4787. /* ADC1: mute amp left and right */
  4788. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4789. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4790. /* ADC2: mute amp left and right */
  4791. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4792. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4793. /* ADC3: mute amp left and right */
  4794. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4795. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4796. { }
  4797. };
  4798. static struct hda_verb alc882_eapd_verbs[] = {
  4799. /* change to EAPD mode */
  4800. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4801. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4802. { }
  4803. };
  4804. /* Mac Pro test */
  4805. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4806. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4807. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4808. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4809. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4810. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4811. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4812. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4813. { } /* end */
  4814. };
  4815. static struct hda_verb alc882_macpro_init_verbs[] = {
  4816. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4817. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4820. /* Front Pin: output 0 (0x0c) */
  4821. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4822. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4823. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4824. /* Front Mic pin: input vref at 80% */
  4825. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4826. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4827. /* Speaker: output */
  4828. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4829. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4830. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4831. /* Headphone output (output 0 - 0x0c) */
  4832. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4833. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4834. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4835. /* FIXME: use matrix-type input source selection */
  4836. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4837. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4838. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4841. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4842. /* Input mixer2 */
  4843. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4846. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4847. /* Input mixer3 */
  4848. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4851. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4852. /* ADC1: mute amp left and right */
  4853. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4854. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4855. /* ADC2: mute amp left and right */
  4856. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4857. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4858. /* ADC3: mute amp left and right */
  4859. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4860. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4861. { }
  4862. };
  4863. /* Macbook Pro rev3 */
  4864. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4865. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4866. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4868. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4869. /* Rear mixer */
  4870. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4871. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4872. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4873. /* Front Pin: output 0 (0x0c) */
  4874. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4875. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4876. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4877. /* HP Pin: output 0 (0x0d) */
  4878. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4879. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4880. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4881. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4882. /* Mic (rear) pin: input vref at 80% */
  4883. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4884. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4885. /* Front Mic pin: input vref at 80% */
  4886. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4887. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4888. /* Line In pin: use output 1 when in LineOut mode */
  4889. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4890. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4891. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4892. /* FIXME: use matrix-type input source selection */
  4893. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4894. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4895. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4897. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4898. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4899. /* Input mixer2 */
  4900. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4903. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4904. /* Input mixer3 */
  4905. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4909. /* ADC1: mute amp left and right */
  4910. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4911. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4912. /* ADC2: mute amp left and right */
  4913. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4914. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4915. /* ADC3: mute amp left and right */
  4916. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4917. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4918. { }
  4919. };
  4920. /* iMac 24 mixer. */
  4921. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4922. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4923. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4924. { } /* end */
  4925. };
  4926. /* iMac 24 init verbs. */
  4927. static struct hda_verb alc885_imac24_init_verbs[] = {
  4928. /* Internal speakers: output 0 (0x0c) */
  4929. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4930. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4931. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4932. /* Internal speakers: output 0 (0x0c) */
  4933. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4934. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4935. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4936. /* Headphone: output 0 (0x0c) */
  4937. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4938. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4939. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4940. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4941. /* Front Mic: input vref at 80% */
  4942. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4943. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4944. { }
  4945. };
  4946. /* Toggle speaker-output according to the hp-jack state */
  4947. static void alc885_imac24_automute(struct hda_codec *codec)
  4948. {
  4949. unsigned int present;
  4950. present = snd_hda_codec_read(codec, 0x14, 0,
  4951. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4952. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4953. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4954. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4955. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4956. }
  4957. /* Processes unsolicited events. */
  4958. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4959. unsigned int res)
  4960. {
  4961. /* Headphone insertion or removal. */
  4962. if ((res >> 26) == ALC880_HP_EVENT)
  4963. alc885_imac24_automute(codec);
  4964. }
  4965. static void alc885_mbp3_automute(struct hda_codec *codec)
  4966. {
  4967. unsigned int present;
  4968. present = snd_hda_codec_read(codec, 0x15, 0,
  4969. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4970. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4971. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4972. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4973. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4974. }
  4975. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4976. unsigned int res)
  4977. {
  4978. /* Headphone insertion or removal. */
  4979. if ((res >> 26) == ALC880_HP_EVENT)
  4980. alc885_mbp3_automute(codec);
  4981. }
  4982. static struct hda_verb alc882_targa_verbs[] = {
  4983. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4984. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4985. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4986. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4987. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4988. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4989. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4990. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4991. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4992. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4993. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4994. { } /* end */
  4995. };
  4996. /* toggle speaker-output according to the hp-jack state */
  4997. static void alc882_targa_automute(struct hda_codec *codec)
  4998. {
  4999. unsigned int present;
  5000. present = snd_hda_codec_read(codec, 0x14, 0,
  5001. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5002. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5003. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5004. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5005. present ? 1 : 3);
  5006. }
  5007. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5008. {
  5009. /* Looks like the unsol event is incompatible with the standard
  5010. * definition. 4bit tag is placed at 26 bit!
  5011. */
  5012. if (((res >> 26) == ALC880_HP_EVENT)) {
  5013. alc882_targa_automute(codec);
  5014. }
  5015. }
  5016. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5017. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5018. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5019. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5020. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5021. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5022. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5023. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5024. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5025. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5026. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5027. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5028. { } /* end */
  5029. };
  5030. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5031. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5032. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5033. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5034. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5035. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5036. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5037. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5038. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5039. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5040. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5041. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5042. { } /* end */
  5043. };
  5044. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5045. {
  5046. unsigned int gpiostate, gpiomask, gpiodir;
  5047. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5048. AC_VERB_GET_GPIO_DATA, 0);
  5049. if (!muted)
  5050. gpiostate |= (1 << pin);
  5051. else
  5052. gpiostate &= ~(1 << pin);
  5053. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5054. AC_VERB_GET_GPIO_MASK, 0);
  5055. gpiomask |= (1 << pin);
  5056. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5057. AC_VERB_GET_GPIO_DIRECTION, 0);
  5058. gpiodir |= (1 << pin);
  5059. snd_hda_codec_write(codec, codec->afg, 0,
  5060. AC_VERB_SET_GPIO_MASK, gpiomask);
  5061. snd_hda_codec_write(codec, codec->afg, 0,
  5062. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5063. msleep(1);
  5064. snd_hda_codec_write(codec, codec->afg, 0,
  5065. AC_VERB_SET_GPIO_DATA, gpiostate);
  5066. }
  5067. /* set up GPIO at initialization */
  5068. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5069. {
  5070. alc882_gpio_mute(codec, 0, 0);
  5071. alc882_gpio_mute(codec, 1, 0);
  5072. }
  5073. /* set up GPIO and update auto-muting at initialization */
  5074. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5075. {
  5076. alc885_macpro_init_hook(codec);
  5077. alc885_imac24_automute(codec);
  5078. }
  5079. /*
  5080. * generic initialization of ADC, input mixers and output mixers
  5081. */
  5082. static struct hda_verb alc882_auto_init_verbs[] = {
  5083. /*
  5084. * Unmute ADC0-2 and set the default input to mic-in
  5085. */
  5086. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5087. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5088. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5089. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5090. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5091. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5092. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5093. * mixer widget
  5094. * Note: PASD motherboards uses the Line In 2 as the input for
  5095. * front panel mic (mic 2)
  5096. */
  5097. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5098. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5099. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5103. /*
  5104. * Set up output mixers (0x0c - 0x0f)
  5105. */
  5106. /* set vol=0 to output mixers */
  5107. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5108. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5109. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5110. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5111. /* set up input amps for analog loopback */
  5112. /* Amp Indices: DAC = 0, mixer = 1 */
  5113. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5114. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5115. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5116. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5117. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5118. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5119. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5120. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5121. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5122. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5123. /* FIXME: use matrix-type input source selection */
  5124. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5125. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5126. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5128. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5129. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5130. /* Input mixer2 */
  5131. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5132. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5133. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5134. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5135. /* Input mixer3 */
  5136. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5137. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5139. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5140. { }
  5141. };
  5142. /* capture mixer elements */
  5143. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5144. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5145. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5146. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5147. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5148. {
  5149. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5150. /* The multiple "Capture Source" controls confuse alsamixer
  5151. * So call somewhat different..
  5152. * FIXME: the controls appear in the "playback" view!
  5153. */
  5154. /* .name = "Capture Source", */
  5155. .name = "Input Source",
  5156. .count = 2,
  5157. .info = alc882_mux_enum_info,
  5158. .get = alc882_mux_enum_get,
  5159. .put = alc882_mux_enum_put,
  5160. },
  5161. { } /* end */
  5162. };
  5163. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5164. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5165. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5166. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5167. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5168. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5169. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5170. {
  5171. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5172. /* The multiple "Capture Source" controls confuse alsamixer
  5173. * So call somewhat different..
  5174. * FIXME: the controls appear in the "playback" view!
  5175. */
  5176. /* .name = "Capture Source", */
  5177. .name = "Input Source",
  5178. .count = 3,
  5179. .info = alc882_mux_enum_info,
  5180. .get = alc882_mux_enum_get,
  5181. .put = alc882_mux_enum_put,
  5182. },
  5183. { } /* end */
  5184. };
  5185. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5186. #define alc882_loopbacks alc880_loopbacks
  5187. #endif
  5188. /* pcm configuration: identiacal with ALC880 */
  5189. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5190. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5191. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5192. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5193. /*
  5194. * configuration and preset
  5195. */
  5196. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5197. [ALC882_3ST_DIG] = "3stack-dig",
  5198. [ALC882_6ST_DIG] = "6stack-dig",
  5199. [ALC882_ARIMA] = "arima",
  5200. [ALC882_W2JC] = "w2jc",
  5201. [ALC882_TARGA] = "targa",
  5202. [ALC882_ASUS_A7J] = "asus-a7j",
  5203. [ALC882_ASUS_A7M] = "asus-a7m",
  5204. [ALC885_MACPRO] = "macpro",
  5205. [ALC885_MBP3] = "mbp3",
  5206. [ALC885_IMAC24] = "imac24",
  5207. [ALC882_AUTO] = "auto",
  5208. };
  5209. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5210. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5211. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5212. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5213. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5214. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5215. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5216. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5217. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5218. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5219. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5220. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5221. {}
  5222. };
  5223. static struct alc_config_preset alc882_presets[] = {
  5224. [ALC882_3ST_DIG] = {
  5225. .mixers = { alc882_base_mixer },
  5226. .init_verbs = { alc882_init_verbs },
  5227. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5228. .dac_nids = alc882_dac_nids,
  5229. .dig_out_nid = ALC882_DIGOUT_NID,
  5230. .dig_in_nid = ALC882_DIGIN_NID,
  5231. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5232. .channel_mode = alc882_ch_modes,
  5233. .need_dac_fix = 1,
  5234. .input_mux = &alc882_capture_source,
  5235. },
  5236. [ALC882_6ST_DIG] = {
  5237. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5238. .init_verbs = { alc882_init_verbs },
  5239. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5240. .dac_nids = alc882_dac_nids,
  5241. .dig_out_nid = ALC882_DIGOUT_NID,
  5242. .dig_in_nid = ALC882_DIGIN_NID,
  5243. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5244. .channel_mode = alc882_sixstack_modes,
  5245. .input_mux = &alc882_capture_source,
  5246. },
  5247. [ALC882_ARIMA] = {
  5248. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5249. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5250. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5251. .dac_nids = alc882_dac_nids,
  5252. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5253. .channel_mode = alc882_sixstack_modes,
  5254. .input_mux = &alc882_capture_source,
  5255. },
  5256. [ALC882_W2JC] = {
  5257. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5258. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5259. alc880_gpio1_init_verbs },
  5260. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5261. .dac_nids = alc882_dac_nids,
  5262. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5263. .channel_mode = alc880_threestack_modes,
  5264. .need_dac_fix = 1,
  5265. .input_mux = &alc882_capture_source,
  5266. .dig_out_nid = ALC882_DIGOUT_NID,
  5267. },
  5268. [ALC885_MBP3] = {
  5269. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5270. .init_verbs = { alc885_mbp3_init_verbs,
  5271. alc880_gpio1_init_verbs },
  5272. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5273. .dac_nids = alc882_dac_nids,
  5274. .channel_mode = alc885_mbp_6ch_modes,
  5275. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5276. .input_mux = &alc882_capture_source,
  5277. .dig_out_nid = ALC882_DIGOUT_NID,
  5278. .dig_in_nid = ALC882_DIGIN_NID,
  5279. .unsol_event = alc885_mbp3_unsol_event,
  5280. .init_hook = alc885_mbp3_automute,
  5281. },
  5282. [ALC885_MACPRO] = {
  5283. .mixers = { alc882_macpro_mixer },
  5284. .init_verbs = { alc882_macpro_init_verbs },
  5285. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5286. .dac_nids = alc882_dac_nids,
  5287. .dig_out_nid = ALC882_DIGOUT_NID,
  5288. .dig_in_nid = ALC882_DIGIN_NID,
  5289. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5290. .channel_mode = alc882_ch_modes,
  5291. .input_mux = &alc882_capture_source,
  5292. .init_hook = alc885_macpro_init_hook,
  5293. },
  5294. [ALC885_IMAC24] = {
  5295. .mixers = { alc885_imac24_mixer },
  5296. .init_verbs = { alc885_imac24_init_verbs },
  5297. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5298. .dac_nids = alc882_dac_nids,
  5299. .dig_out_nid = ALC882_DIGOUT_NID,
  5300. .dig_in_nid = ALC882_DIGIN_NID,
  5301. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5302. .channel_mode = alc882_ch_modes,
  5303. .input_mux = &alc882_capture_source,
  5304. .unsol_event = alc885_imac24_unsol_event,
  5305. .init_hook = alc885_imac24_init_hook,
  5306. },
  5307. [ALC882_TARGA] = {
  5308. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5309. alc882_capture_mixer },
  5310. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5311. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5312. .dac_nids = alc882_dac_nids,
  5313. .dig_out_nid = ALC882_DIGOUT_NID,
  5314. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5315. .adc_nids = alc882_adc_nids,
  5316. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5317. .channel_mode = alc882_3ST_6ch_modes,
  5318. .need_dac_fix = 1,
  5319. .input_mux = &alc882_capture_source,
  5320. .unsol_event = alc882_targa_unsol_event,
  5321. .init_hook = alc882_targa_automute,
  5322. },
  5323. [ALC882_ASUS_A7J] = {
  5324. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5325. alc882_capture_mixer },
  5326. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5327. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5328. .dac_nids = alc882_dac_nids,
  5329. .dig_out_nid = ALC882_DIGOUT_NID,
  5330. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5331. .adc_nids = alc882_adc_nids,
  5332. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5333. .channel_mode = alc882_3ST_6ch_modes,
  5334. .need_dac_fix = 1,
  5335. .input_mux = &alc882_capture_source,
  5336. },
  5337. [ALC882_ASUS_A7M] = {
  5338. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5339. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5340. alc880_gpio1_init_verbs,
  5341. alc882_asus_a7m_verbs },
  5342. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5343. .dac_nids = alc882_dac_nids,
  5344. .dig_out_nid = ALC882_DIGOUT_NID,
  5345. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5346. .channel_mode = alc880_threestack_modes,
  5347. .need_dac_fix = 1,
  5348. .input_mux = &alc882_capture_source,
  5349. },
  5350. };
  5351. /*
  5352. * Pin config fixes
  5353. */
  5354. enum {
  5355. PINFIX_ABIT_AW9D_MAX
  5356. };
  5357. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5358. { 0x15, 0x01080104 }, /* side */
  5359. { 0x16, 0x01011012 }, /* rear */
  5360. { 0x17, 0x01016011 }, /* clfe */
  5361. { }
  5362. };
  5363. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5364. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5365. };
  5366. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5367. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5368. {}
  5369. };
  5370. /*
  5371. * BIOS auto configuration
  5372. */
  5373. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5374. hda_nid_t nid, int pin_type,
  5375. int dac_idx)
  5376. {
  5377. /* set as output */
  5378. struct alc_spec *spec = codec->spec;
  5379. int idx;
  5380. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5381. idx = 4;
  5382. else
  5383. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5384. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5385. pin_type);
  5386. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5387. AMP_OUT_UNMUTE);
  5388. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5389. }
  5390. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5391. {
  5392. struct alc_spec *spec = codec->spec;
  5393. int i;
  5394. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5395. for (i = 0; i <= HDA_SIDE; i++) {
  5396. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5397. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5398. if (nid)
  5399. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5400. i);
  5401. }
  5402. }
  5403. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5404. {
  5405. struct alc_spec *spec = codec->spec;
  5406. hda_nid_t pin;
  5407. pin = spec->autocfg.hp_pins[0];
  5408. if (pin) /* connect to front */
  5409. /* use dac 0 */
  5410. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5411. }
  5412. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5413. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5414. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5415. {
  5416. struct alc_spec *spec = codec->spec;
  5417. int i;
  5418. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5419. hda_nid_t nid = spec->autocfg.input_pins[i];
  5420. if (alc882_is_input_pin(nid)) {
  5421. snd_hda_codec_write(codec, nid, 0,
  5422. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5423. i <= AUTO_PIN_FRONT_MIC ?
  5424. PIN_VREF80 : PIN_IN);
  5425. if (nid != ALC882_PIN_CD_NID)
  5426. snd_hda_codec_write(codec, nid, 0,
  5427. AC_VERB_SET_AMP_GAIN_MUTE,
  5428. AMP_OUT_MUTE);
  5429. }
  5430. }
  5431. }
  5432. /* add mic boosts if needed */
  5433. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5434. {
  5435. struct alc_spec *spec = codec->spec;
  5436. int err;
  5437. hda_nid_t nid;
  5438. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5439. if (nid) {
  5440. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5441. "Mic Boost",
  5442. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5443. if (err < 0)
  5444. return err;
  5445. }
  5446. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5447. if (nid) {
  5448. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5449. "Front Mic Boost",
  5450. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5451. if (err < 0)
  5452. return err;
  5453. }
  5454. return 0;
  5455. }
  5456. /* almost identical with ALC880 parser... */
  5457. static int alc882_parse_auto_config(struct hda_codec *codec)
  5458. {
  5459. struct alc_spec *spec = codec->spec;
  5460. int err = alc880_parse_auto_config(codec);
  5461. if (err < 0)
  5462. return err;
  5463. else if (!err)
  5464. return 0; /* no config found */
  5465. err = alc_auto_add_mic_boost(codec);
  5466. if (err < 0)
  5467. return err;
  5468. /* hack - override the init verbs */
  5469. spec->init_verbs[0] = alc882_auto_init_verbs;
  5470. return 1; /* config found */
  5471. }
  5472. /* additional initialization for auto-configuration model */
  5473. static void alc882_auto_init(struct hda_codec *codec)
  5474. {
  5475. alc882_auto_init_multi_out(codec);
  5476. alc882_auto_init_hp_out(codec);
  5477. alc882_auto_init_analog_input(codec);
  5478. }
  5479. static int patch_alc882(struct hda_codec *codec)
  5480. {
  5481. struct alc_spec *spec;
  5482. int err, board_config;
  5483. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5484. if (spec == NULL)
  5485. return -ENOMEM;
  5486. codec->spec = spec;
  5487. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5488. alc882_models,
  5489. alc882_cfg_tbl);
  5490. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5491. /* Pick up systems that don't supply PCI SSID */
  5492. switch (codec->subsystem_id) {
  5493. case 0x106b0c00: /* Mac Pro */
  5494. board_config = ALC885_MACPRO;
  5495. break;
  5496. case 0x106b1000: /* iMac 24 */
  5497. board_config = ALC885_IMAC24;
  5498. break;
  5499. case 0x106b2c00: /* Macbook Pro rev3 */
  5500. board_config = ALC885_MBP3;
  5501. break;
  5502. default:
  5503. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5504. "trying auto-probe from BIOS...\n");
  5505. board_config = ALC882_AUTO;
  5506. }
  5507. }
  5508. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5509. if (board_config == ALC882_AUTO) {
  5510. /* automatic parse from the BIOS config */
  5511. err = alc882_parse_auto_config(codec);
  5512. if (err < 0) {
  5513. alc_free(codec);
  5514. return err;
  5515. } else if (!err) {
  5516. printk(KERN_INFO
  5517. "hda_codec: Cannot set up configuration "
  5518. "from BIOS. Using base mode...\n");
  5519. board_config = ALC882_3ST_DIG;
  5520. }
  5521. }
  5522. if (board_config != ALC882_AUTO)
  5523. setup_preset(spec, &alc882_presets[board_config]);
  5524. spec->stream_name_analog = "ALC882 Analog";
  5525. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5526. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5527. spec->stream_name_digital = "ALC882 Digital";
  5528. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5529. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5530. if (!spec->adc_nids && spec->input_mux) {
  5531. /* check whether NID 0x07 is valid */
  5532. unsigned int wcap = get_wcaps(codec, 0x07);
  5533. /* get type */
  5534. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5535. if (wcap != AC_WID_AUD_IN) {
  5536. spec->adc_nids = alc882_adc_nids_alt;
  5537. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5538. spec->mixers[spec->num_mixers] =
  5539. alc882_capture_alt_mixer;
  5540. spec->num_mixers++;
  5541. } else {
  5542. spec->adc_nids = alc882_adc_nids;
  5543. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5544. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5545. spec->num_mixers++;
  5546. }
  5547. }
  5548. codec->patch_ops = alc_patch_ops;
  5549. if (board_config == ALC882_AUTO)
  5550. spec->init_hook = alc882_auto_init;
  5551. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5552. if (!spec->loopback.amplist)
  5553. spec->loopback.amplist = alc882_loopbacks;
  5554. #endif
  5555. return 0;
  5556. }
  5557. /*
  5558. * ALC883 support
  5559. *
  5560. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5561. * configuration. Each pin widget can choose any input DACs and a mixer.
  5562. * Each ADC is connected from a mixer of all inputs. This makes possible
  5563. * 6-channel independent captures.
  5564. *
  5565. * In addition, an independent DAC for the multi-playback (not used in this
  5566. * driver yet).
  5567. */
  5568. #define ALC883_DIGOUT_NID 0x06
  5569. #define ALC883_DIGIN_NID 0x0a
  5570. static hda_nid_t alc883_dac_nids[4] = {
  5571. /* front, rear, clfe, rear_surr */
  5572. 0x02, 0x04, 0x03, 0x05
  5573. };
  5574. static hda_nid_t alc883_adc_nids[2] = {
  5575. /* ADC1-2 */
  5576. 0x08, 0x09,
  5577. };
  5578. /* input MUX */
  5579. /* FIXME: should be a matrix-type input source selection */
  5580. static struct hda_input_mux alc883_capture_source = {
  5581. .num_items = 4,
  5582. .items = {
  5583. { "Mic", 0x0 },
  5584. { "Front Mic", 0x1 },
  5585. { "Line", 0x2 },
  5586. { "CD", 0x4 },
  5587. },
  5588. };
  5589. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5590. .num_items = 2,
  5591. .items = {
  5592. { "Mic", 0x1 },
  5593. { "Line", 0x2 },
  5594. },
  5595. };
  5596. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5597. .num_items = 4,
  5598. .items = {
  5599. { "Mic", 0x0 },
  5600. { "iMic", 0x1 },
  5601. { "Line", 0x2 },
  5602. { "CD", 0x4 },
  5603. },
  5604. };
  5605. #define alc883_mux_enum_info alc_mux_enum_info
  5606. #define alc883_mux_enum_get alc_mux_enum_get
  5607. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5608. struct snd_ctl_elem_value *ucontrol)
  5609. {
  5610. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5611. struct alc_spec *spec = codec->spec;
  5612. const struct hda_input_mux *imux = spec->input_mux;
  5613. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5614. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5615. hda_nid_t nid = capture_mixers[adc_idx];
  5616. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5617. unsigned int i, idx;
  5618. idx = ucontrol->value.enumerated.item[0];
  5619. if (idx >= imux->num_items)
  5620. idx = imux->num_items - 1;
  5621. if (*cur_val == idx)
  5622. return 0;
  5623. for (i = 0; i < imux->num_items; i++) {
  5624. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5625. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5626. imux->items[i].index,
  5627. HDA_AMP_MUTE, v);
  5628. }
  5629. *cur_val = idx;
  5630. return 1;
  5631. }
  5632. /*
  5633. * 2ch mode
  5634. */
  5635. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5636. { 2, NULL }
  5637. };
  5638. /*
  5639. * 2ch mode
  5640. */
  5641. static struct hda_verb alc883_3ST_ch2_init[] = {
  5642. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5643. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5644. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5645. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5646. { } /* end */
  5647. };
  5648. /*
  5649. * 4ch mode
  5650. */
  5651. static struct hda_verb alc883_3ST_ch4_init[] = {
  5652. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5653. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5654. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5655. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5656. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5657. { } /* end */
  5658. };
  5659. /*
  5660. * 6ch mode
  5661. */
  5662. static struct hda_verb alc883_3ST_ch6_init[] = {
  5663. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5664. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5665. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5666. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5667. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5668. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5669. { } /* end */
  5670. };
  5671. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5672. { 2, alc883_3ST_ch2_init },
  5673. { 4, alc883_3ST_ch4_init },
  5674. { 6, alc883_3ST_ch6_init },
  5675. };
  5676. /*
  5677. * 6ch mode
  5678. */
  5679. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5680. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5681. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5682. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5683. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5684. { } /* end */
  5685. };
  5686. /*
  5687. * 8ch mode
  5688. */
  5689. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5690. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5691. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5692. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5693. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5694. { } /* end */
  5695. };
  5696. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5697. { 6, alc883_sixstack_ch6_init },
  5698. { 8, alc883_sixstack_ch8_init },
  5699. };
  5700. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5701. /* eanable EAPD on medion laptop */
  5702. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5703. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5704. { }
  5705. };
  5706. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5707. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5708. */
  5709. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5710. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5711. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5712. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5713. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5714. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5715. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5716. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5717. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5718. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5719. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5720. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5721. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5722. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5723. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5724. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5726. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5727. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5728. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5729. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5730. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5731. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5732. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5733. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5734. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5735. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5736. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5737. {
  5738. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5739. /* .name = "Capture Source", */
  5740. .name = "Input Source",
  5741. .count = 2,
  5742. .info = alc883_mux_enum_info,
  5743. .get = alc883_mux_enum_get,
  5744. .put = alc883_mux_enum_put,
  5745. },
  5746. { } /* end */
  5747. };
  5748. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5749. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5750. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5751. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5752. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5753. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5754. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5755. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5756. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5757. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5758. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5759. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5761. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5762. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5763. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5764. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5765. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5766. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5767. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5768. {
  5769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5770. /* .name = "Capture Source", */
  5771. .name = "Input Source",
  5772. .count = 2,
  5773. .info = alc883_mux_enum_info,
  5774. .get = alc883_mux_enum_get,
  5775. .put = alc883_mux_enum_put,
  5776. },
  5777. { } /* end */
  5778. };
  5779. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5780. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5781. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5782. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5783. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5784. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5785. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5786. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5787. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5788. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5789. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5790. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5791. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5792. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5794. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5795. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5796. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5797. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5798. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5800. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, 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_fivestack_mixer[] = {
  5817. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5818. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5821. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5822. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5823. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5825. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5826. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5827. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5828. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5829. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5830. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5831. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5832. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5834. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5835. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5836. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5837. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5838. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5839. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5840. {
  5841. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5842. /* .name = "Capture Source", */
  5843. .name = "Input Source",
  5844. .count = 1,
  5845. .info = alc883_mux_enum_info,
  5846. .get = alc883_mux_enum_get,
  5847. .put = alc883_mux_enum_put,
  5848. },
  5849. { } /* end */
  5850. };
  5851. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5852. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5853. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5854. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5855. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5856. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5857. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5858. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5859. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5860. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5861. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5862. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5863. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5864. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5866. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5867. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5868. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5869. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5870. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5871. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5872. {
  5873. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5874. /* .name = "Capture Source", */
  5875. .name = "Input Source",
  5876. .count = 2,
  5877. .info = alc883_mux_enum_info,
  5878. .get = alc883_mux_enum_get,
  5879. .put = alc883_mux_enum_put,
  5880. },
  5881. { } /* end */
  5882. };
  5883. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5884. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5885. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5887. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5888. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5889. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5890. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5891. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5892. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5893. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5894. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5895. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5896. {
  5897. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5898. /* .name = "Capture Source", */
  5899. .name = "Input Source",
  5900. .count = 2,
  5901. .info = alc883_mux_enum_info,
  5902. .get = alc883_mux_enum_get,
  5903. .put = alc883_mux_enum_put,
  5904. },
  5905. { } /* end */
  5906. };
  5907. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5908. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5909. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5910. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5911. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5912. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5913. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5914. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5915. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5916. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5917. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5918. {
  5919. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5920. /* .name = "Capture Source", */
  5921. .name = "Input Source",
  5922. .count = 1,
  5923. .info = alc883_mux_enum_info,
  5924. .get = alc883_mux_enum_get,
  5925. .put = alc883_mux_enum_put,
  5926. },
  5927. { } /* end */
  5928. };
  5929. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5930. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5931. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5932. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5933. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5934. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5935. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5936. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5937. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5938. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5939. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5940. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5941. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5942. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5943. {
  5944. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5945. /* .name = "Capture Source", */
  5946. .name = "Input Source",
  5947. .count = 2,
  5948. .info = alc883_mux_enum_info,
  5949. .get = alc883_mux_enum_get,
  5950. .put = alc883_mux_enum_put,
  5951. },
  5952. { } /* end */
  5953. };
  5954. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5955. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5956. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5957. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5958. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5959. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5960. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5961. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5962. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5963. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5964. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5965. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5966. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5967. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5968. {
  5969. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5970. /* .name = "Capture Source", */
  5971. .name = "Input Source",
  5972. .count = 2,
  5973. .info = alc883_mux_enum_info,
  5974. .get = alc883_mux_enum_get,
  5975. .put = alc883_mux_enum_put,
  5976. },
  5977. { } /* end */
  5978. };
  5979. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5980. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5981. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5982. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5983. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5984. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5985. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5986. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5987. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5988. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5989. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5990. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5991. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5992. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5993. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5994. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5995. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5996. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5997. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5998. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5999. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6000. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6001. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6002. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6003. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6004. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6005. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6006. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6007. {
  6008. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6009. /* .name = "Capture Source", */
  6010. .name = "Input Source",
  6011. .count = 2,
  6012. .info = alc883_mux_enum_info,
  6013. .get = alc883_mux_enum_get,
  6014. .put = alc883_mux_enum_put,
  6015. },
  6016. { } /* end */
  6017. };
  6018. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6019. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6020. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6021. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6022. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6023. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6024. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6025. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6026. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6027. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6028. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6029. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6030. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6031. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6032. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6033. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6034. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6035. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6036. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6037. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6038. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6039. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6040. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6041. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6042. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6043. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6044. {
  6045. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6046. /* .name = "Capture Source", */
  6047. .name = "Input Source",
  6048. .count = 2,
  6049. .info = alc883_mux_enum_info,
  6050. .get = alc883_mux_enum_get,
  6051. .put = alc883_mux_enum_put,
  6052. },
  6053. { } /* end */
  6054. };
  6055. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6056. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6057. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6058. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6059. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6060. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6061. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6062. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6063. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6064. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6065. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6066. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6067. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6068. {
  6069. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6070. /* .name = "Capture Source", */
  6071. .name = "Input Source",
  6072. .count = 2,
  6073. .info = alc883_mux_enum_info,
  6074. .get = alc883_mux_enum_get,
  6075. .put = alc883_mux_enum_put,
  6076. },
  6077. { } /* end */
  6078. };
  6079. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6080. {
  6081. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6082. .name = "Channel Mode",
  6083. .info = alc_ch_mode_info,
  6084. .get = alc_ch_mode_get,
  6085. .put = alc_ch_mode_put,
  6086. },
  6087. { } /* end */
  6088. };
  6089. static struct hda_verb alc883_init_verbs[] = {
  6090. /* ADC1: mute amp left and right */
  6091. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6092. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6093. /* ADC2: mute amp left and right */
  6094. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6095. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6096. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6098. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6099. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6100. /* Rear mixer */
  6101. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6102. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6103. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6104. /* CLFE mixer */
  6105. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6106. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6107. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6108. /* Side mixer */
  6109. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6110. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6111. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6112. /* mute analog input loopbacks */
  6113. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6114. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6115. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6117. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6118. /* Front Pin: output 0 (0x0c) */
  6119. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6120. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6121. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6122. /* Rear Pin: output 1 (0x0d) */
  6123. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6124. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6125. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6126. /* CLFE Pin: output 2 (0x0e) */
  6127. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6128. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6129. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6130. /* Side Pin: output 3 (0x0f) */
  6131. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6132. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6133. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6134. /* Mic (rear) pin: input vref at 80% */
  6135. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6136. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6137. /* Front Mic pin: input vref at 80% */
  6138. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6139. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6140. /* Line In pin: input */
  6141. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6142. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6143. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6144. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6145. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6146. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6147. /* CD pin widget for input */
  6148. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6149. /* FIXME: use matrix-type input source selection */
  6150. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6151. /* Input mixer2 */
  6152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6155. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6156. /* Input mixer3 */
  6157. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6158. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6159. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6160. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6161. { }
  6162. };
  6163. static struct hda_verb alc883_tagra_verbs[] = {
  6164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6165. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6166. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6167. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6168. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6169. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6170. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6171. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6172. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6173. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6174. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6175. { } /* end */
  6176. };
  6177. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6178. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6179. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6180. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6181. { } /* end */
  6182. };
  6183. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6184. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6185. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6186. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6187. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6188. { } /* end */
  6189. };
  6190. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6193. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6194. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6195. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6196. { } /* end */
  6197. };
  6198. static struct hda_verb alc883_haier_w66_verbs[] = {
  6199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6200. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6201. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6202. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6203. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6204. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6205. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6206. { } /* end */
  6207. };
  6208. static struct hda_verb alc888_6st_hp_verbs[] = {
  6209. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6210. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6211. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6212. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6213. { }
  6214. };
  6215. static struct hda_verb alc888_3st_hp_verbs[] = {
  6216. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6217. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6218. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6219. { }
  6220. };
  6221. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6222. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6223. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6224. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6225. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6226. { }
  6227. };
  6228. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6229. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6230. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6231. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6232. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6233. { }
  6234. };
  6235. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6236. { 2, alc888_3st_hp_2ch_init },
  6237. { 6, alc888_3st_hp_6ch_init },
  6238. };
  6239. /* toggle front-jack and RCA according to the hp-jack state */
  6240. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6241. {
  6242. unsigned int present;
  6243. present = snd_hda_codec_read(codec, 0x1b, 0,
  6244. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6245. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6246. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6247. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6248. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6249. }
  6250. /* toggle RCA according to the front-jack state */
  6251. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6252. {
  6253. unsigned int present;
  6254. present = snd_hda_codec_read(codec, 0x14, 0,
  6255. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6256. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6257. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6258. }
  6259. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6260. unsigned int res)
  6261. {
  6262. if ((res >> 26) == ALC880_HP_EVENT)
  6263. alc888_lenovo_ms7195_front_automute(codec);
  6264. if ((res >> 26) == ALC880_FRONT_EVENT)
  6265. alc888_lenovo_ms7195_rca_automute(codec);
  6266. }
  6267. static struct hda_verb alc883_medion_md2_verbs[] = {
  6268. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6269. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6270. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6271. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6272. { } /* end */
  6273. };
  6274. /* toggle speaker-output according to the hp-jack state */
  6275. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6276. {
  6277. unsigned int present;
  6278. present = snd_hda_codec_read(codec, 0x14, 0,
  6279. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6280. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6281. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6282. }
  6283. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6284. unsigned int res)
  6285. {
  6286. if ((res >> 26) == ALC880_HP_EVENT)
  6287. alc883_medion_md2_automute(codec);
  6288. }
  6289. /* toggle speaker-output according to the hp-jack state */
  6290. static void alc883_tagra_automute(struct hda_codec *codec)
  6291. {
  6292. unsigned int present;
  6293. unsigned char bits;
  6294. present = snd_hda_codec_read(codec, 0x14, 0,
  6295. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6296. bits = present ? HDA_AMP_MUTE : 0;
  6297. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6298. HDA_AMP_MUTE, bits);
  6299. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6300. present ? 1 : 3);
  6301. }
  6302. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6303. {
  6304. if ((res >> 26) == ALC880_HP_EVENT)
  6305. alc883_tagra_automute(codec);
  6306. }
  6307. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6308. {
  6309. unsigned int present;
  6310. unsigned char bits;
  6311. present = snd_hda_codec_read(codec, 0x1b, 0,
  6312. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6313. bits = present ? 0x80 : 0;
  6314. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6315. 0x80, bits);
  6316. }
  6317. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6318. unsigned int res)
  6319. {
  6320. if ((res >> 26) == ALC880_HP_EVENT)
  6321. alc883_haier_w66_automute(codec);
  6322. }
  6323. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6324. {
  6325. unsigned int present;
  6326. unsigned char bits;
  6327. present = snd_hda_codec_read(codec, 0x14, 0,
  6328. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6329. bits = present ? HDA_AMP_MUTE : 0;
  6330. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6331. HDA_AMP_MUTE, bits);
  6332. }
  6333. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6334. {
  6335. unsigned int present;
  6336. unsigned char bits;
  6337. present = snd_hda_codec_read(codec, 0x1b, 0,
  6338. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6339. bits = present ? HDA_AMP_MUTE : 0;
  6340. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6341. HDA_AMP_MUTE, bits);
  6342. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6343. HDA_AMP_MUTE, bits);
  6344. }
  6345. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6346. unsigned int res)
  6347. {
  6348. if ((res >> 26) == ALC880_HP_EVENT)
  6349. alc883_lenovo_101e_all_automute(codec);
  6350. if ((res >> 26) == ALC880_FRONT_EVENT)
  6351. alc883_lenovo_101e_ispeaker_automute(codec);
  6352. }
  6353. /* toggle speaker-output according to the hp-jack state */
  6354. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6355. {
  6356. unsigned int present;
  6357. present = snd_hda_codec_read(codec, 0x14, 0,
  6358. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6359. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6360. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6361. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6362. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6363. }
  6364. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6365. unsigned int res)
  6366. {
  6367. if ((res >> 26) == ALC880_HP_EVENT)
  6368. alc883_acer_aspire_automute(codec);
  6369. }
  6370. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6371. /* HP Pin: output 0 (0x0c) */
  6372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6374. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6375. /* Front Pin: output 0 (0x0c) */
  6376. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6377. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6378. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6379. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6380. /* eanable EAPD on medion laptop */
  6381. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6382. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6383. /* enable unsolicited event */
  6384. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6385. { }
  6386. };
  6387. /*
  6388. * generic initialization of ADC, input mixers and output mixers
  6389. */
  6390. static struct hda_verb alc883_auto_init_verbs[] = {
  6391. /*
  6392. * Unmute ADC0-2 and set the default input to mic-in
  6393. */
  6394. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6395. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6396. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6397. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6398. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6399. * mixer widget
  6400. * Note: PASD motherboards uses the Line In 2 as the input for
  6401. * front panel mic (mic 2)
  6402. */
  6403. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6404. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6405. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6406. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6407. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6408. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6409. /*
  6410. * Set up output mixers (0x0c - 0x0f)
  6411. */
  6412. /* set vol=0 to output mixers */
  6413. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6414. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6415. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6416. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6417. /* set up input amps for analog loopback */
  6418. /* Amp Indices: DAC = 0, mixer = 1 */
  6419. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6420. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6421. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6422. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6423. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6424. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6425. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6426. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6427. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6428. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6429. /* FIXME: use matrix-type input source selection */
  6430. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6431. /* Input mixer1 */
  6432. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6433. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6434. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6435. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6436. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6437. /* Input mixer2 */
  6438. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6439. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6440. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6441. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6442. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6443. { }
  6444. };
  6445. /* capture mixer elements */
  6446. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6447. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6448. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6449. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6450. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6451. {
  6452. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6453. /* The multiple "Capture Source" controls confuse alsamixer
  6454. * So call somewhat different..
  6455. * FIXME: the controls appear in the "playback" view!
  6456. */
  6457. /* .name = "Capture Source", */
  6458. .name = "Input Source",
  6459. .count = 2,
  6460. .info = alc882_mux_enum_info,
  6461. .get = alc882_mux_enum_get,
  6462. .put = alc882_mux_enum_put,
  6463. },
  6464. { } /* end */
  6465. };
  6466. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6467. #define alc883_loopbacks alc880_loopbacks
  6468. #endif
  6469. /* pcm configuration: identiacal with ALC880 */
  6470. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6471. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6472. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6473. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6474. /*
  6475. * configuration and preset
  6476. */
  6477. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6478. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6479. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6480. [ALC883_3ST_6ch] = "3stack-6ch",
  6481. [ALC883_6ST_DIG] = "6stack-dig",
  6482. [ALC883_TARGA_DIG] = "targa-dig",
  6483. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6484. [ALC883_ACER] = "acer",
  6485. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6486. [ALC883_MEDION] = "medion",
  6487. [ALC883_MEDION_MD2] = "medion-md2",
  6488. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6489. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6490. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6491. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6492. [ALC883_HAIER_W66] = "haier-w66",
  6493. [ALC888_6ST_HP] = "6stack-hp",
  6494. [ALC888_3ST_HP] = "3stack-hp",
  6495. [ALC883_AUTO] = "auto",
  6496. };
  6497. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6498. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6499. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6500. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6501. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6502. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6503. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6504. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6505. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6506. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6507. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6508. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6509. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6510. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6511. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6512. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6513. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6514. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6515. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6516. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6517. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6518. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6519. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6520. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6521. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6522. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6523. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6524. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6525. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6526. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6527. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6528. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6529. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6530. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6531. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6532. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6533. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6534. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6535. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6536. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6537. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6538. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6539. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6540. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6541. {}
  6542. };
  6543. static struct alc_config_preset alc883_presets[] = {
  6544. [ALC883_3ST_2ch_DIG] = {
  6545. .mixers = { alc883_3ST_2ch_mixer },
  6546. .init_verbs = { alc883_init_verbs },
  6547. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6548. .dac_nids = alc883_dac_nids,
  6549. .dig_out_nid = ALC883_DIGOUT_NID,
  6550. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6551. .adc_nids = alc883_adc_nids,
  6552. .dig_in_nid = ALC883_DIGIN_NID,
  6553. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6554. .channel_mode = alc883_3ST_2ch_modes,
  6555. .input_mux = &alc883_capture_source,
  6556. },
  6557. [ALC883_3ST_6ch_DIG] = {
  6558. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6559. .init_verbs = { alc883_init_verbs },
  6560. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6561. .dac_nids = alc883_dac_nids,
  6562. .dig_out_nid = ALC883_DIGOUT_NID,
  6563. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6564. .adc_nids = alc883_adc_nids,
  6565. .dig_in_nid = ALC883_DIGIN_NID,
  6566. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6567. .channel_mode = alc883_3ST_6ch_modes,
  6568. .need_dac_fix = 1,
  6569. .input_mux = &alc883_capture_source,
  6570. },
  6571. [ALC883_3ST_6ch] = {
  6572. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6573. .init_verbs = { alc883_init_verbs },
  6574. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6575. .dac_nids = alc883_dac_nids,
  6576. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6577. .adc_nids = alc883_adc_nids,
  6578. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6579. .channel_mode = alc883_3ST_6ch_modes,
  6580. .need_dac_fix = 1,
  6581. .input_mux = &alc883_capture_source,
  6582. },
  6583. [ALC883_6ST_DIG] = {
  6584. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6585. .init_verbs = { alc883_init_verbs },
  6586. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6587. .dac_nids = alc883_dac_nids,
  6588. .dig_out_nid = ALC883_DIGOUT_NID,
  6589. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6590. .adc_nids = alc883_adc_nids,
  6591. .dig_in_nid = ALC883_DIGIN_NID,
  6592. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6593. .channel_mode = alc883_sixstack_modes,
  6594. .input_mux = &alc883_capture_source,
  6595. },
  6596. [ALC883_TARGA_DIG] = {
  6597. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6598. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6599. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6600. .dac_nids = alc883_dac_nids,
  6601. .dig_out_nid = ALC883_DIGOUT_NID,
  6602. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6603. .adc_nids = alc883_adc_nids,
  6604. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6605. .channel_mode = alc883_3ST_6ch_modes,
  6606. .need_dac_fix = 1,
  6607. .input_mux = &alc883_capture_source,
  6608. .unsol_event = alc883_tagra_unsol_event,
  6609. .init_hook = alc883_tagra_automute,
  6610. },
  6611. [ALC883_TARGA_2ch_DIG] = {
  6612. .mixers = { alc883_tagra_2ch_mixer},
  6613. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6614. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6615. .dac_nids = alc883_dac_nids,
  6616. .dig_out_nid = ALC883_DIGOUT_NID,
  6617. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6618. .adc_nids = alc883_adc_nids,
  6619. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6620. .channel_mode = alc883_3ST_2ch_modes,
  6621. .input_mux = &alc883_capture_source,
  6622. .unsol_event = alc883_tagra_unsol_event,
  6623. .init_hook = alc883_tagra_automute,
  6624. },
  6625. [ALC883_ACER] = {
  6626. .mixers = { alc883_base_mixer },
  6627. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6628. * and the headphone jack. Turn this on and rely on the
  6629. * standard mute methods whenever the user wants to turn
  6630. * these outputs off.
  6631. */
  6632. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6633. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6634. .dac_nids = alc883_dac_nids,
  6635. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6636. .adc_nids = alc883_adc_nids,
  6637. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6638. .channel_mode = alc883_3ST_2ch_modes,
  6639. .input_mux = &alc883_capture_source,
  6640. },
  6641. [ALC883_ACER_ASPIRE] = {
  6642. .mixers = { alc883_acer_aspire_mixer },
  6643. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6644. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6645. .dac_nids = alc883_dac_nids,
  6646. .dig_out_nid = ALC883_DIGOUT_NID,
  6647. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6648. .adc_nids = alc883_adc_nids,
  6649. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6650. .channel_mode = alc883_3ST_2ch_modes,
  6651. .input_mux = &alc883_capture_source,
  6652. .unsol_event = alc883_acer_aspire_unsol_event,
  6653. .init_hook = alc883_acer_aspire_automute,
  6654. },
  6655. [ALC883_MEDION] = {
  6656. .mixers = { alc883_fivestack_mixer,
  6657. alc883_chmode_mixer },
  6658. .init_verbs = { alc883_init_verbs,
  6659. alc883_medion_eapd_verbs },
  6660. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6661. .dac_nids = alc883_dac_nids,
  6662. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6663. .adc_nids = alc883_adc_nids,
  6664. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6665. .channel_mode = alc883_sixstack_modes,
  6666. .input_mux = &alc883_capture_source,
  6667. },
  6668. [ALC883_MEDION_MD2] = {
  6669. .mixers = { alc883_medion_md2_mixer},
  6670. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6671. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6672. .dac_nids = alc883_dac_nids,
  6673. .dig_out_nid = ALC883_DIGOUT_NID,
  6674. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6675. .adc_nids = alc883_adc_nids,
  6676. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6677. .channel_mode = alc883_3ST_2ch_modes,
  6678. .input_mux = &alc883_capture_source,
  6679. .unsol_event = alc883_medion_md2_unsol_event,
  6680. .init_hook = alc883_medion_md2_automute,
  6681. },
  6682. [ALC883_LAPTOP_EAPD] = {
  6683. .mixers = { alc883_base_mixer },
  6684. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6685. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6686. .dac_nids = alc883_dac_nids,
  6687. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6688. .adc_nids = alc883_adc_nids,
  6689. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6690. .channel_mode = alc883_3ST_2ch_modes,
  6691. .input_mux = &alc883_capture_source,
  6692. },
  6693. [ALC883_LENOVO_101E_2ch] = {
  6694. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6695. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6696. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6697. .dac_nids = alc883_dac_nids,
  6698. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6699. .adc_nids = alc883_adc_nids,
  6700. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6701. .channel_mode = alc883_3ST_2ch_modes,
  6702. .input_mux = &alc883_lenovo_101e_capture_source,
  6703. .unsol_event = alc883_lenovo_101e_unsol_event,
  6704. .init_hook = alc883_lenovo_101e_all_automute,
  6705. },
  6706. [ALC883_LENOVO_NB0763] = {
  6707. .mixers = { alc883_lenovo_nb0763_mixer },
  6708. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6709. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6710. .dac_nids = alc883_dac_nids,
  6711. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6712. .adc_nids = alc883_adc_nids,
  6713. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6714. .channel_mode = alc883_3ST_2ch_modes,
  6715. .need_dac_fix = 1,
  6716. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6717. .unsol_event = alc883_medion_md2_unsol_event,
  6718. .init_hook = alc883_medion_md2_automute,
  6719. },
  6720. [ALC888_LENOVO_MS7195_DIG] = {
  6721. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6722. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6723. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6724. .dac_nids = alc883_dac_nids,
  6725. .dig_out_nid = ALC883_DIGOUT_NID,
  6726. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6727. .adc_nids = alc883_adc_nids,
  6728. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6729. .channel_mode = alc883_3ST_6ch_modes,
  6730. .need_dac_fix = 1,
  6731. .input_mux = &alc883_capture_source,
  6732. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6733. .init_hook = alc888_lenovo_ms7195_front_automute,
  6734. },
  6735. [ALC883_HAIER_W66] = {
  6736. .mixers = { alc883_tagra_2ch_mixer},
  6737. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6738. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6739. .dac_nids = alc883_dac_nids,
  6740. .dig_out_nid = ALC883_DIGOUT_NID,
  6741. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6742. .adc_nids = alc883_adc_nids,
  6743. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6744. .channel_mode = alc883_3ST_2ch_modes,
  6745. .input_mux = &alc883_capture_source,
  6746. .unsol_event = alc883_haier_w66_unsol_event,
  6747. .init_hook = alc883_haier_w66_automute,
  6748. },
  6749. [ALC888_6ST_HP] = {
  6750. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6751. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6752. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6753. .dac_nids = alc883_dac_nids,
  6754. .dig_out_nid = ALC883_DIGOUT_NID,
  6755. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6756. .adc_nids = alc883_adc_nids,
  6757. .dig_in_nid = ALC883_DIGIN_NID,
  6758. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6759. .channel_mode = alc883_sixstack_modes,
  6760. .input_mux = &alc883_capture_source,
  6761. },
  6762. [ALC888_3ST_HP] = {
  6763. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6764. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6765. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6766. .dac_nids = alc883_dac_nids,
  6767. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6768. .adc_nids = alc883_adc_nids,
  6769. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6770. .channel_mode = alc888_3st_hp_modes,
  6771. .need_dac_fix = 1,
  6772. .input_mux = &alc883_capture_source,
  6773. },
  6774. };
  6775. /*
  6776. * BIOS auto configuration
  6777. */
  6778. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6779. hda_nid_t nid, int pin_type,
  6780. int dac_idx)
  6781. {
  6782. /* set as output */
  6783. struct alc_spec *spec = codec->spec;
  6784. int idx;
  6785. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6786. idx = 4;
  6787. else
  6788. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6789. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6790. pin_type);
  6791. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6792. AMP_OUT_UNMUTE);
  6793. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6794. }
  6795. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6796. {
  6797. struct alc_spec *spec = codec->spec;
  6798. int i;
  6799. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6800. for (i = 0; i <= HDA_SIDE; i++) {
  6801. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6802. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6803. if (nid)
  6804. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6805. i);
  6806. }
  6807. }
  6808. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6809. {
  6810. struct alc_spec *spec = codec->spec;
  6811. hda_nid_t pin;
  6812. pin = spec->autocfg.hp_pins[0];
  6813. if (pin) /* connect to front */
  6814. /* use dac 0 */
  6815. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6816. }
  6817. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6818. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6819. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6820. {
  6821. struct alc_spec *spec = codec->spec;
  6822. int i;
  6823. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6824. hda_nid_t nid = spec->autocfg.input_pins[i];
  6825. if (alc883_is_input_pin(nid)) {
  6826. snd_hda_codec_write(codec, nid, 0,
  6827. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6828. (i <= AUTO_PIN_FRONT_MIC ?
  6829. PIN_VREF80 : PIN_IN));
  6830. if (nid != ALC883_PIN_CD_NID)
  6831. snd_hda_codec_write(codec, nid, 0,
  6832. AC_VERB_SET_AMP_GAIN_MUTE,
  6833. AMP_OUT_MUTE);
  6834. }
  6835. }
  6836. }
  6837. /* almost identical with ALC880 parser... */
  6838. static int alc883_parse_auto_config(struct hda_codec *codec)
  6839. {
  6840. struct alc_spec *spec = codec->spec;
  6841. int err = alc880_parse_auto_config(codec);
  6842. if (err < 0)
  6843. return err;
  6844. else if (!err)
  6845. return 0; /* no config found */
  6846. err = alc_auto_add_mic_boost(codec);
  6847. if (err < 0)
  6848. return err;
  6849. /* hack - override the init verbs */
  6850. spec->init_verbs[0] = alc883_auto_init_verbs;
  6851. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6852. spec->num_mixers++;
  6853. return 1; /* config found */
  6854. }
  6855. /* additional initialization for auto-configuration model */
  6856. static void alc883_auto_init(struct hda_codec *codec)
  6857. {
  6858. alc883_auto_init_multi_out(codec);
  6859. alc883_auto_init_hp_out(codec);
  6860. alc883_auto_init_analog_input(codec);
  6861. }
  6862. static int patch_alc883(struct hda_codec *codec)
  6863. {
  6864. struct alc_spec *spec;
  6865. int err, board_config;
  6866. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6867. if (spec == NULL)
  6868. return -ENOMEM;
  6869. codec->spec = spec;
  6870. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6871. alc883_models,
  6872. alc883_cfg_tbl);
  6873. if (board_config < 0) {
  6874. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6875. "trying auto-probe from BIOS...\n");
  6876. board_config = ALC883_AUTO;
  6877. }
  6878. if (board_config == ALC883_AUTO) {
  6879. /* automatic parse from the BIOS config */
  6880. err = alc883_parse_auto_config(codec);
  6881. if (err < 0) {
  6882. alc_free(codec);
  6883. return err;
  6884. } else if (!err) {
  6885. printk(KERN_INFO
  6886. "hda_codec: Cannot set up configuration "
  6887. "from BIOS. Using base mode...\n");
  6888. board_config = ALC883_3ST_2ch_DIG;
  6889. }
  6890. }
  6891. if (board_config != ALC883_AUTO)
  6892. setup_preset(spec, &alc883_presets[board_config]);
  6893. spec->stream_name_analog = "ALC883 Analog";
  6894. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6895. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6896. spec->stream_name_digital = "ALC883 Digital";
  6897. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6898. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6899. if (!spec->adc_nids && spec->input_mux) {
  6900. spec->adc_nids = alc883_adc_nids;
  6901. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6902. }
  6903. codec->patch_ops = alc_patch_ops;
  6904. if (board_config == ALC883_AUTO)
  6905. spec->init_hook = alc883_auto_init;
  6906. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6907. if (!spec->loopback.amplist)
  6908. spec->loopback.amplist = alc883_loopbacks;
  6909. #endif
  6910. return 0;
  6911. }
  6912. /*
  6913. * ALC262 support
  6914. */
  6915. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6916. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6917. #define alc262_dac_nids alc260_dac_nids
  6918. #define alc262_adc_nids alc882_adc_nids
  6919. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6920. #define alc262_modes alc260_modes
  6921. #define alc262_capture_source alc882_capture_source
  6922. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6923. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6924. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6925. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6926. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6927. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6928. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6929. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6930. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6931. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6932. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6933. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6934. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6935. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6936. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6937. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6938. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6939. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6940. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6941. { } /* end */
  6942. };
  6943. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6944. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6945. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6946. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6947. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6948. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6949. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6950. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6951. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6952. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6953. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6954. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6955. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6956. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6957. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6958. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6959. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6960. { } /* end */
  6961. };
  6962. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6963. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6964. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6965. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6966. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6967. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6968. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6969. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6970. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6971. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6972. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6973. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6974. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6975. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6976. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6977. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6978. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6979. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6980. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6981. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6982. { } /* end */
  6983. };
  6984. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6985. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6986. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6987. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6988. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6989. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6990. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6991. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6992. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6993. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6994. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6995. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6996. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6997. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6998. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6999. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7000. { } /* end */
  7001. };
  7002. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7003. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7004. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7005. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7006. { } /* end */
  7007. };
  7008. /* bind hp and internal speaker mute (with plug check) */
  7009. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7010. struct snd_ctl_elem_value *ucontrol)
  7011. {
  7012. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7013. long *valp = ucontrol->value.integer.value;
  7014. int change;
  7015. /* change hp mute */
  7016. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7017. HDA_AMP_MUTE,
  7018. valp[0] ? 0 : HDA_AMP_MUTE);
  7019. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7020. HDA_AMP_MUTE,
  7021. valp[1] ? 0 : HDA_AMP_MUTE);
  7022. if (change) {
  7023. /* change speaker according to HP jack state */
  7024. struct alc_spec *spec = codec->spec;
  7025. unsigned int mute;
  7026. if (spec->jack_present)
  7027. mute = HDA_AMP_MUTE;
  7028. else
  7029. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7030. HDA_OUTPUT, 0);
  7031. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7032. HDA_AMP_MUTE, mute);
  7033. }
  7034. return change;
  7035. }
  7036. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7037. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7038. {
  7039. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7040. .name = "Master Playback Switch",
  7041. .info = snd_hda_mixer_amp_switch_info,
  7042. .get = snd_hda_mixer_amp_switch_get,
  7043. .put = alc262_sony_master_sw_put,
  7044. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7045. },
  7046. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7047. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7048. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7049. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7050. { } /* end */
  7051. };
  7052. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7053. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7054. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7055. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7058. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7059. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7060. { } /* end */
  7061. };
  7062. #define alc262_capture_mixer alc882_capture_mixer
  7063. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7064. /*
  7065. * generic initialization of ADC, input mixers and output mixers
  7066. */
  7067. static struct hda_verb alc262_init_verbs[] = {
  7068. /*
  7069. * Unmute ADC0-2 and set the default input to mic-in
  7070. */
  7071. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7072. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7073. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7074. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7075. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7076. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7077. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7078. * mixer widget
  7079. * Note: PASD motherboards uses the Line In 2 as the input for
  7080. * front panel mic (mic 2)
  7081. */
  7082. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7083. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7084. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7085. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7086. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7087. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7088. /*
  7089. * Set up output mixers (0x0c - 0x0e)
  7090. */
  7091. /* set vol=0 to output mixers */
  7092. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7093. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7094. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7095. /* set up input amps for analog loopback */
  7096. /* Amp Indices: DAC = 0, mixer = 1 */
  7097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7098. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7099. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7100. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7101. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7102. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7103. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7104. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7105. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7106. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7107. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7108. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7109. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7110. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7111. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7112. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7113. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7114. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7115. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7116. /* FIXME: use matrix-type input source selection */
  7117. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7118. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7119. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7120. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7121. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7122. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7123. /* Input mixer2 */
  7124. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7125. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7126. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7127. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7128. /* Input mixer3 */
  7129. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7130. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7131. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7132. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7133. { }
  7134. };
  7135. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7136. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7137. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7138. {}
  7139. };
  7140. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7141. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7142. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7143. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7144. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7145. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7146. {}
  7147. };
  7148. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7149. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7150. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7151. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7152. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7153. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7154. };
  7155. /* mute/unmute internal speaker according to the hp jack and mute state */
  7156. static void alc262_hippo_automute(struct hda_codec *codec)
  7157. {
  7158. struct alc_spec *spec = codec->spec;
  7159. unsigned int mute;
  7160. unsigned int present;
  7161. /* need to execute and sync at first */
  7162. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7163. present = snd_hda_codec_read(codec, 0x15, 0,
  7164. AC_VERB_GET_PIN_SENSE, 0);
  7165. spec->jack_present = (present & 0x80000000) != 0;
  7166. if (spec->jack_present) {
  7167. /* mute internal speaker */
  7168. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7169. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7170. } else {
  7171. /* unmute internal speaker if necessary */
  7172. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7173. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7174. HDA_AMP_MUTE, mute);
  7175. }
  7176. }
  7177. /* unsolicited event for HP jack sensing */
  7178. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7179. unsigned int res)
  7180. {
  7181. if ((res >> 26) != ALC880_HP_EVENT)
  7182. return;
  7183. alc262_hippo_automute(codec);
  7184. }
  7185. static void alc262_hippo1_automute(struct hda_codec *codec)
  7186. {
  7187. unsigned int mute;
  7188. unsigned int present;
  7189. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7190. present = snd_hda_codec_read(codec, 0x1b, 0,
  7191. AC_VERB_GET_PIN_SENSE, 0);
  7192. present = (present & 0x80000000) != 0;
  7193. if (present) {
  7194. /* mute internal speaker */
  7195. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7196. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7197. } else {
  7198. /* unmute internal speaker if necessary */
  7199. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7200. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7201. HDA_AMP_MUTE, mute);
  7202. }
  7203. }
  7204. /* unsolicited event for HP jack sensing */
  7205. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7206. unsigned int res)
  7207. {
  7208. if ((res >> 26) != ALC880_HP_EVENT)
  7209. return;
  7210. alc262_hippo1_automute(codec);
  7211. }
  7212. /*
  7213. * fujitsu model
  7214. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7215. */
  7216. #define ALC_HP_EVENT 0x37
  7217. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7218. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7219. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7220. {}
  7221. };
  7222. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7223. .num_items = 3,
  7224. .items = {
  7225. { "Mic", 0x0 },
  7226. { "Int Mic", 0x1 },
  7227. { "CD", 0x4 },
  7228. },
  7229. };
  7230. static struct hda_input_mux alc262_HP_capture_source = {
  7231. .num_items = 5,
  7232. .items = {
  7233. { "Mic", 0x0 },
  7234. { "Front Mic", 0x1 },
  7235. { "Line", 0x2 },
  7236. { "CD", 0x4 },
  7237. { "AUX IN", 0x6 },
  7238. },
  7239. };
  7240. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7241. .num_items = 4,
  7242. .items = {
  7243. { "Mic", 0x0 },
  7244. { "Front Mic", 0x2 },
  7245. { "Line", 0x1 },
  7246. { "CD", 0x4 },
  7247. },
  7248. };
  7249. /* mute/unmute internal speaker according to the hp jack and mute state */
  7250. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7251. {
  7252. struct alc_spec *spec = codec->spec;
  7253. unsigned int mute;
  7254. if (force || !spec->sense_updated) {
  7255. unsigned int present;
  7256. /* need to execute and sync at first */
  7257. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7258. present = snd_hda_codec_read(codec, 0x14, 0,
  7259. AC_VERB_GET_PIN_SENSE, 0);
  7260. spec->jack_present = (present & 0x80000000) != 0;
  7261. spec->sense_updated = 1;
  7262. }
  7263. if (spec->jack_present) {
  7264. /* mute internal speaker */
  7265. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7266. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7267. } else {
  7268. /* unmute internal speaker if necessary */
  7269. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7270. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7271. HDA_AMP_MUTE, mute);
  7272. }
  7273. }
  7274. /* unsolicited event for HP jack sensing */
  7275. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7276. unsigned int res)
  7277. {
  7278. if ((res >> 26) != ALC_HP_EVENT)
  7279. return;
  7280. alc262_fujitsu_automute(codec, 1);
  7281. }
  7282. /* bind volumes of both NID 0x0c and 0x0d */
  7283. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7284. .ops = &snd_hda_bind_vol,
  7285. .values = {
  7286. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7287. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7288. 0
  7289. },
  7290. };
  7291. /* bind hp and internal speaker mute (with plug check) */
  7292. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7293. struct snd_ctl_elem_value *ucontrol)
  7294. {
  7295. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7296. long *valp = ucontrol->value.integer.value;
  7297. int change;
  7298. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7299. HDA_AMP_MUTE,
  7300. valp[0] ? 0 : HDA_AMP_MUTE);
  7301. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7302. HDA_AMP_MUTE,
  7303. valp[1] ? 0 : HDA_AMP_MUTE);
  7304. if (change)
  7305. alc262_fujitsu_automute(codec, 0);
  7306. return change;
  7307. }
  7308. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7309. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7310. {
  7311. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7312. .name = "Master Playback Switch",
  7313. .info = snd_hda_mixer_amp_switch_info,
  7314. .get = snd_hda_mixer_amp_switch_get,
  7315. .put = alc262_fujitsu_master_sw_put,
  7316. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7317. },
  7318. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7319. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7320. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7321. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7322. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7323. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7324. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7325. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7326. { } /* end */
  7327. };
  7328. /* additional init verbs for Benq laptops */
  7329. static struct hda_verb alc262_EAPD_verbs[] = {
  7330. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7331. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7332. {}
  7333. };
  7334. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7335. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7336. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7337. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7338. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7339. {}
  7340. };
  7341. /* Samsung Q1 Ultra Vista model setup */
  7342. static struct snd_kcontrol_new alc262_ultra_mixer[] = {
  7343. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7344. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7345. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7346. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7347. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7348. HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
  7349. { } /* end */
  7350. };
  7351. static struct hda_verb alc262_ultra_verbs[] = {
  7352. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7353. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7355. /* Mic is on Node 0x19 */
  7356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7357. {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
  7358. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7359. {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
  7360. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7361. {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
  7362. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7363. {}
  7364. };
  7365. static struct hda_input_mux alc262_ultra_capture_source = {
  7366. .num_items = 1,
  7367. .items = {
  7368. { "Mic", 0x1 },
  7369. },
  7370. };
  7371. /* mute/unmute internal speaker according to the hp jack and mute state */
  7372. static void alc262_ultra_automute(struct hda_codec *codec)
  7373. {
  7374. struct alc_spec *spec = codec->spec;
  7375. unsigned int mute;
  7376. unsigned int present;
  7377. /* need to execute and sync at first */
  7378. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7379. present = snd_hda_codec_read(codec, 0x15, 0,
  7380. AC_VERB_GET_PIN_SENSE, 0);
  7381. spec->jack_present = (present & 0x80000000) != 0;
  7382. if (spec->jack_present) {
  7383. /* mute internal speaker */
  7384. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7385. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7386. } else {
  7387. /* unmute internal speaker if necessary */
  7388. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7389. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7390. HDA_AMP_MUTE, mute);
  7391. }
  7392. }
  7393. /* unsolicited event for HP jack sensing */
  7394. static void alc262_ultra_unsol_event(struct hda_codec *codec,
  7395. unsigned int res)
  7396. {
  7397. if ((res >> 26) != ALC880_HP_EVENT)
  7398. return;
  7399. alc262_ultra_automute(codec);
  7400. }
  7401. /* add playback controls from the parsed DAC table */
  7402. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7403. const struct auto_pin_cfg *cfg)
  7404. {
  7405. hda_nid_t nid;
  7406. int err;
  7407. spec->multiout.num_dacs = 1; /* only use one dac */
  7408. spec->multiout.dac_nids = spec->private_dac_nids;
  7409. spec->multiout.dac_nids[0] = 2;
  7410. nid = cfg->line_out_pins[0];
  7411. if (nid) {
  7412. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7413. "Front Playback Volume",
  7414. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7415. if (err < 0)
  7416. return err;
  7417. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7418. "Front Playback Switch",
  7419. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7420. if (err < 0)
  7421. return err;
  7422. }
  7423. nid = cfg->speaker_pins[0];
  7424. if (nid) {
  7425. if (nid == 0x16) {
  7426. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7427. "Speaker Playback Volume",
  7428. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7429. HDA_OUTPUT));
  7430. if (err < 0)
  7431. return err;
  7432. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7433. "Speaker Playback Switch",
  7434. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7435. HDA_OUTPUT));
  7436. if (err < 0)
  7437. return err;
  7438. } else {
  7439. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7440. "Speaker Playback Switch",
  7441. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7442. HDA_OUTPUT));
  7443. if (err < 0)
  7444. return err;
  7445. }
  7446. }
  7447. nid = cfg->hp_pins[0];
  7448. if (nid) {
  7449. /* spec->multiout.hp_nid = 2; */
  7450. if (nid == 0x16) {
  7451. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7452. "Headphone Playback Volume",
  7453. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7454. HDA_OUTPUT));
  7455. if (err < 0)
  7456. return err;
  7457. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7458. "Headphone Playback Switch",
  7459. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7460. HDA_OUTPUT));
  7461. if (err < 0)
  7462. return err;
  7463. } else {
  7464. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7465. "Headphone Playback Switch",
  7466. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7467. HDA_OUTPUT));
  7468. if (err < 0)
  7469. return err;
  7470. }
  7471. }
  7472. return 0;
  7473. }
  7474. /* identical with ALC880 */
  7475. #define alc262_auto_create_analog_input_ctls \
  7476. alc880_auto_create_analog_input_ctls
  7477. /*
  7478. * generic initialization of ADC, input mixers and output mixers
  7479. */
  7480. static struct hda_verb alc262_volume_init_verbs[] = {
  7481. /*
  7482. * Unmute ADC0-2 and set the default input to mic-in
  7483. */
  7484. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7485. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7486. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7487. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7488. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7489. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7490. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7491. * mixer widget
  7492. * Note: PASD motherboards uses the Line In 2 as the input for
  7493. * front panel mic (mic 2)
  7494. */
  7495. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7496. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7497. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7498. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7499. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7500. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7501. /*
  7502. * Set up output mixers (0x0c - 0x0f)
  7503. */
  7504. /* set vol=0 to output mixers */
  7505. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7506. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7507. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7508. /* set up input amps for analog loopback */
  7509. /* Amp Indices: DAC = 0, mixer = 1 */
  7510. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7511. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7512. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7514. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7515. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7516. /* FIXME: use matrix-type input source selection */
  7517. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7518. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7519. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7520. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7521. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7522. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7523. /* Input mixer2 */
  7524. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7525. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7526. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7527. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7528. /* Input mixer3 */
  7529. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7530. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7531. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7532. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7533. { }
  7534. };
  7535. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7536. /*
  7537. * Unmute ADC0-2 and set the default input to mic-in
  7538. */
  7539. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7540. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7541. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7542. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7543. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7545. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7546. * mixer widget
  7547. * Note: PASD motherboards uses the Line In 2 as the input for
  7548. * front panel mic (mic 2)
  7549. */
  7550. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7551. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7552. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7553. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7554. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7555. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7556. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7557. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7558. /*
  7559. * Set up output mixers (0x0c - 0x0e)
  7560. */
  7561. /* set vol=0 to output mixers */
  7562. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7563. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7564. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7565. /* set up input amps for analog loopback */
  7566. /* Amp Indices: DAC = 0, mixer = 1 */
  7567. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7569. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7570. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7571. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7572. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7573. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7574. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7575. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7576. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7577. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7578. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7579. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7580. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7581. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7582. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7583. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7584. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7585. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7586. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7587. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7588. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7589. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7590. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7591. /* FIXME: use matrix-type input source selection */
  7592. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7593. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7594. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7595. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7596. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7597. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7598. /* Input mixer2 */
  7599. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7600. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7601. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7602. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7603. /* Input mixer3 */
  7604. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7605. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7606. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7607. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7608. { }
  7609. };
  7610. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7611. /*
  7612. * Unmute ADC0-2 and set the default input to mic-in
  7613. */
  7614. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7615. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7616. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7617. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7618. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7619. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7620. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7621. * mixer widget
  7622. * Note: PASD motherboards uses the Line In 2 as the input for front
  7623. * panel mic (mic 2)
  7624. */
  7625. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7626. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7634. /*
  7635. * Set up output mixers (0x0c - 0x0e)
  7636. */
  7637. /* set vol=0 to output mixers */
  7638. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7639. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7640. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7641. /* set up input amps for analog loopback */
  7642. /* Amp Indices: DAC = 0, mixer = 1 */
  7643. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7644. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7645. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7646. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7647. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7648. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7649. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7650. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7651. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7652. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7653. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7654. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7655. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7656. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7657. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7658. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7659. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7660. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7661. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7662. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7663. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7664. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7665. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7666. /* FIXME: use matrix-type input source selection */
  7667. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7668. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7669. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7670. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7671. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7672. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7673. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7674. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7675. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7676. /* Input mixer2 */
  7677. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7678. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7679. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7680. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7681. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7682. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7683. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7684. /* Input mixer3 */
  7685. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7686. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7687. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7688. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7689. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7690. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7691. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7692. { }
  7693. };
  7694. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7695. #define alc262_loopbacks alc880_loopbacks
  7696. #endif
  7697. /* pcm configuration: identiacal with ALC880 */
  7698. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7699. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7700. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7701. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7702. /*
  7703. * BIOS auto configuration
  7704. */
  7705. static int alc262_parse_auto_config(struct hda_codec *codec)
  7706. {
  7707. struct alc_spec *spec = codec->spec;
  7708. int err;
  7709. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7710. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7711. alc262_ignore);
  7712. if (err < 0)
  7713. return err;
  7714. if (!spec->autocfg.line_outs)
  7715. return 0; /* can't find valid BIOS pin config */
  7716. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7717. if (err < 0)
  7718. return err;
  7719. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7720. if (err < 0)
  7721. return err;
  7722. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7723. if (spec->autocfg.dig_out_pin)
  7724. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7725. if (spec->autocfg.dig_in_pin)
  7726. spec->dig_in_nid = ALC262_DIGIN_NID;
  7727. if (spec->kctl_alloc)
  7728. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7729. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7730. spec->num_mux_defs = 1;
  7731. spec->input_mux = &spec->private_imux;
  7732. err = alc_auto_add_mic_boost(codec);
  7733. if (err < 0)
  7734. return err;
  7735. return 1;
  7736. }
  7737. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7738. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7739. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7740. /* init callback for auto-configuration model -- overriding the default init */
  7741. static void alc262_auto_init(struct hda_codec *codec)
  7742. {
  7743. alc262_auto_init_multi_out(codec);
  7744. alc262_auto_init_hp_out(codec);
  7745. alc262_auto_init_analog_input(codec);
  7746. }
  7747. /*
  7748. * configuration and preset
  7749. */
  7750. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7751. [ALC262_BASIC] = "basic",
  7752. [ALC262_HIPPO] = "hippo",
  7753. [ALC262_HIPPO_1] = "hippo_1",
  7754. [ALC262_FUJITSU] = "fujitsu",
  7755. [ALC262_HP_BPC] = "hp-bpc",
  7756. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7757. [ALC262_BENQ_ED8] = "benq",
  7758. [ALC262_BENQ_T31] = "benq-t31",
  7759. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7760. [ALC262_ULTRA] = "ultra",
  7761. [ALC262_AUTO] = "auto",
  7762. };
  7763. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7764. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7765. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7766. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7767. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7768. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7769. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7770. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7771. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7772. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7773. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7774. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7775. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7776. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7777. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7778. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7779. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7780. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7781. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7782. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7783. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7784. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7785. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7786. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7787. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7788. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7789. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7790. SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
  7791. {}
  7792. };
  7793. static struct alc_config_preset alc262_presets[] = {
  7794. [ALC262_BASIC] = {
  7795. .mixers = { alc262_base_mixer },
  7796. .init_verbs = { alc262_init_verbs },
  7797. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7798. .dac_nids = alc262_dac_nids,
  7799. .hp_nid = 0x03,
  7800. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7801. .channel_mode = alc262_modes,
  7802. .input_mux = &alc262_capture_source,
  7803. },
  7804. [ALC262_HIPPO] = {
  7805. .mixers = { alc262_base_mixer },
  7806. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7807. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7808. .dac_nids = alc262_dac_nids,
  7809. .hp_nid = 0x03,
  7810. .dig_out_nid = ALC262_DIGOUT_NID,
  7811. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7812. .channel_mode = alc262_modes,
  7813. .input_mux = &alc262_capture_source,
  7814. .unsol_event = alc262_hippo_unsol_event,
  7815. .init_hook = alc262_hippo_automute,
  7816. },
  7817. [ALC262_HIPPO_1] = {
  7818. .mixers = { alc262_hippo1_mixer },
  7819. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7820. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7821. .dac_nids = alc262_dac_nids,
  7822. .hp_nid = 0x02,
  7823. .dig_out_nid = ALC262_DIGOUT_NID,
  7824. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7825. .channel_mode = alc262_modes,
  7826. .input_mux = &alc262_capture_source,
  7827. .unsol_event = alc262_hippo1_unsol_event,
  7828. .init_hook = alc262_hippo1_automute,
  7829. },
  7830. [ALC262_FUJITSU] = {
  7831. .mixers = { alc262_fujitsu_mixer },
  7832. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7833. alc262_fujitsu_unsol_verbs },
  7834. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7835. .dac_nids = alc262_dac_nids,
  7836. .hp_nid = 0x03,
  7837. .dig_out_nid = ALC262_DIGOUT_NID,
  7838. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7839. .channel_mode = alc262_modes,
  7840. .input_mux = &alc262_fujitsu_capture_source,
  7841. .unsol_event = alc262_fujitsu_unsol_event,
  7842. },
  7843. [ALC262_HP_BPC] = {
  7844. .mixers = { alc262_HP_BPC_mixer },
  7845. .init_verbs = { alc262_HP_BPC_init_verbs },
  7846. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7847. .dac_nids = alc262_dac_nids,
  7848. .hp_nid = 0x03,
  7849. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7850. .channel_mode = alc262_modes,
  7851. .input_mux = &alc262_HP_capture_source,
  7852. },
  7853. [ALC262_HP_BPC_D7000_WF] = {
  7854. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7855. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7856. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7857. .dac_nids = alc262_dac_nids,
  7858. .hp_nid = 0x03,
  7859. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7860. .channel_mode = alc262_modes,
  7861. .input_mux = &alc262_HP_D7000_capture_source,
  7862. },
  7863. [ALC262_HP_BPC_D7000_WL] = {
  7864. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7865. alc262_HP_BPC_WildWest_option_mixer },
  7866. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7867. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7868. .dac_nids = alc262_dac_nids,
  7869. .hp_nid = 0x03,
  7870. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7871. .channel_mode = alc262_modes,
  7872. .input_mux = &alc262_HP_D7000_capture_source,
  7873. },
  7874. [ALC262_BENQ_ED8] = {
  7875. .mixers = { alc262_base_mixer },
  7876. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7877. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7878. .dac_nids = alc262_dac_nids,
  7879. .hp_nid = 0x03,
  7880. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7881. .channel_mode = alc262_modes,
  7882. .input_mux = &alc262_capture_source,
  7883. },
  7884. [ALC262_SONY_ASSAMD] = {
  7885. .mixers = { alc262_sony_mixer },
  7886. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7887. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7888. .dac_nids = alc262_dac_nids,
  7889. .hp_nid = 0x02,
  7890. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7891. .channel_mode = alc262_modes,
  7892. .input_mux = &alc262_capture_source,
  7893. .unsol_event = alc262_hippo_unsol_event,
  7894. .init_hook = alc262_hippo_automute,
  7895. },
  7896. [ALC262_BENQ_T31] = {
  7897. .mixers = { alc262_benq_t31_mixer },
  7898. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7899. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7900. .dac_nids = alc262_dac_nids,
  7901. .hp_nid = 0x03,
  7902. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7903. .channel_mode = alc262_modes,
  7904. .input_mux = &alc262_capture_source,
  7905. .unsol_event = alc262_hippo_unsol_event,
  7906. .init_hook = alc262_hippo_automute,
  7907. },
  7908. [ALC262_ULTRA] = {
  7909. .mixers = { alc262_ultra_mixer },
  7910. .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
  7911. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7912. .dac_nids = alc262_dac_nids,
  7913. .hp_nid = 0x03,
  7914. .dig_out_nid = ALC262_DIGOUT_NID,
  7915. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7916. .channel_mode = alc262_modes,
  7917. .input_mux = &alc262_ultra_capture_source,
  7918. .unsol_event = alc262_ultra_unsol_event,
  7919. .init_hook = alc262_ultra_automute,
  7920. },
  7921. };
  7922. static int patch_alc262(struct hda_codec *codec)
  7923. {
  7924. struct alc_spec *spec;
  7925. int board_config;
  7926. int err;
  7927. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7928. if (spec == NULL)
  7929. return -ENOMEM;
  7930. codec->spec = spec;
  7931. #if 0
  7932. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7933. * under-run
  7934. */
  7935. {
  7936. int tmp;
  7937. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7938. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7939. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7940. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7941. }
  7942. #endif
  7943. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7944. alc262_models,
  7945. alc262_cfg_tbl);
  7946. if (board_config < 0) {
  7947. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7948. "trying auto-probe from BIOS...\n");
  7949. board_config = ALC262_AUTO;
  7950. }
  7951. if (board_config == ALC262_AUTO) {
  7952. /* automatic parse from the BIOS config */
  7953. err = alc262_parse_auto_config(codec);
  7954. if (err < 0) {
  7955. alc_free(codec);
  7956. return err;
  7957. } else if (!err) {
  7958. printk(KERN_INFO
  7959. "hda_codec: Cannot set up configuration "
  7960. "from BIOS. Using base mode...\n");
  7961. board_config = ALC262_BASIC;
  7962. }
  7963. }
  7964. if (board_config != ALC262_AUTO)
  7965. setup_preset(spec, &alc262_presets[board_config]);
  7966. spec->stream_name_analog = "ALC262 Analog";
  7967. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7968. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7969. spec->stream_name_digital = "ALC262 Digital";
  7970. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7971. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7972. if (!spec->adc_nids && spec->input_mux) {
  7973. /* check whether NID 0x07 is valid */
  7974. unsigned int wcap = get_wcaps(codec, 0x07);
  7975. /* get type */
  7976. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7977. if (wcap != AC_WID_AUD_IN) {
  7978. spec->adc_nids = alc262_adc_nids_alt;
  7979. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7980. spec->mixers[spec->num_mixers] =
  7981. alc262_capture_alt_mixer;
  7982. spec->num_mixers++;
  7983. } else {
  7984. spec->adc_nids = alc262_adc_nids;
  7985. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7986. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7987. spec->num_mixers++;
  7988. }
  7989. }
  7990. codec->patch_ops = alc_patch_ops;
  7991. if (board_config == ALC262_AUTO)
  7992. spec->init_hook = alc262_auto_init;
  7993. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7994. if (!spec->loopback.amplist)
  7995. spec->loopback.amplist = alc262_loopbacks;
  7996. #endif
  7997. return 0;
  7998. }
  7999. /*
  8000. * ALC268 channel source setting (2 channel)
  8001. */
  8002. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  8003. #define alc268_modes alc260_modes
  8004. static hda_nid_t alc268_dac_nids[2] = {
  8005. /* front, hp */
  8006. 0x02, 0x03
  8007. };
  8008. static hda_nid_t alc268_adc_nids[2] = {
  8009. /* ADC0-1 */
  8010. 0x08, 0x07
  8011. };
  8012. static hda_nid_t alc268_adc_nids_alt[1] = {
  8013. /* ADC0 */
  8014. 0x08
  8015. };
  8016. static struct snd_kcontrol_new alc268_base_mixer[] = {
  8017. /* output mixer control */
  8018. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8019. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8020. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8021. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8022. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8023. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8024. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8025. { }
  8026. };
  8027. static struct hda_verb alc268_eapd_verbs[] = {
  8028. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8029. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8030. { }
  8031. };
  8032. /* Toshiba specific */
  8033. #define alc268_toshiba_automute alc262_hippo_automute
  8034. static struct hda_verb alc268_toshiba_verbs[] = {
  8035. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8036. { } /* end */
  8037. };
  8038. /* Acer specific */
  8039. /* bind volumes of both NID 0x02 and 0x03 */
  8040. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  8041. .ops = &snd_hda_bind_vol,
  8042. .values = {
  8043. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  8044. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  8045. 0
  8046. },
  8047. };
  8048. /* mute/unmute internal speaker according to the hp jack and mute state */
  8049. static void alc268_acer_automute(struct hda_codec *codec, int force)
  8050. {
  8051. struct alc_spec *spec = codec->spec;
  8052. unsigned int mute;
  8053. if (force || !spec->sense_updated) {
  8054. unsigned int present;
  8055. present = snd_hda_codec_read(codec, 0x14, 0,
  8056. AC_VERB_GET_PIN_SENSE, 0);
  8057. spec->jack_present = (present & 0x80000000) != 0;
  8058. spec->sense_updated = 1;
  8059. }
  8060. if (spec->jack_present)
  8061. mute = HDA_AMP_MUTE; /* mute internal speaker */
  8062. else /* unmute internal speaker if necessary */
  8063. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  8064. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  8065. HDA_AMP_MUTE, mute);
  8066. }
  8067. /* bind hp and internal speaker mute (with plug check) */
  8068. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  8069. struct snd_ctl_elem_value *ucontrol)
  8070. {
  8071. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8072. long *valp = ucontrol->value.integer.value;
  8073. int change;
  8074. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8075. HDA_AMP_MUTE,
  8076. valp[0] ? 0 : HDA_AMP_MUTE);
  8077. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8078. HDA_AMP_MUTE,
  8079. valp[1] ? 0 : HDA_AMP_MUTE);
  8080. if (change)
  8081. alc268_acer_automute(codec, 0);
  8082. return change;
  8083. }
  8084. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8085. /* output mixer control */
  8086. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8087. {
  8088. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8089. .name = "Master Playback Switch",
  8090. .info = snd_hda_mixer_amp_switch_info,
  8091. .get = snd_hda_mixer_amp_switch_get,
  8092. .put = alc268_acer_master_sw_put,
  8093. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8094. },
  8095. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8096. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8097. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8098. { }
  8099. };
  8100. static struct hda_verb alc268_acer_verbs[] = {
  8101. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8102. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8103. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8104. { }
  8105. };
  8106. /* unsolicited event for HP jack sensing */
  8107. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8108. unsigned int res)
  8109. {
  8110. if ((res >> 26) != ALC880_HP_EVENT)
  8111. return;
  8112. alc268_toshiba_automute(codec);
  8113. }
  8114. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8115. unsigned int res)
  8116. {
  8117. if ((res >> 26) != ALC880_HP_EVENT)
  8118. return;
  8119. alc268_acer_automute(codec, 1);
  8120. }
  8121. static void alc268_acer_init_hook(struct hda_codec *codec)
  8122. {
  8123. alc268_acer_automute(codec, 1);
  8124. }
  8125. /*
  8126. * generic initialization of ADC, input mixers and output mixers
  8127. */
  8128. static struct hda_verb alc268_base_init_verbs[] = {
  8129. /* Unmute DAC0-1 and set vol = 0 */
  8130. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8131. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8132. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8133. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8134. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8135. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8136. /*
  8137. * Set up output mixers (0x0c - 0x0e)
  8138. */
  8139. /* set vol=0 to output mixers */
  8140. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8141. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8142. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8143. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8144. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8145. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8146. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8147. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8148. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8149. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8150. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8151. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8152. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8153. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8154. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8155. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8156. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8157. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8158. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8159. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8160. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8161. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8162. /* FIXME: use matrix-type input source selection */
  8163. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  8164. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8165. /* Input mixer2 */
  8166. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8167. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8168. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8169. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8170. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8171. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8172. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8173. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8174. { }
  8175. };
  8176. /*
  8177. * generic initialization of ADC, input mixers and output mixers
  8178. */
  8179. static struct hda_verb alc268_volume_init_verbs[] = {
  8180. /* set output DAC */
  8181. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8182. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8183. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8184. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8185. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8186. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8187. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8188. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8189. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8190. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8193. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8194. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8195. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8196. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8197. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8198. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8199. /* set PCBEEP vol = 0 */
  8200. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8201. { }
  8202. };
  8203. #define alc268_mux_enum_info alc_mux_enum_info
  8204. #define alc268_mux_enum_get alc_mux_enum_get
  8205. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8206. struct snd_ctl_elem_value *ucontrol)
  8207. {
  8208. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8209. struct alc_spec *spec = codec->spec;
  8210. const struct hda_input_mux *imux = spec->input_mux;
  8211. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8212. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8213. hda_nid_t nid = capture_mixers[adc_idx];
  8214. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8215. unsigned int i, idx;
  8216. idx = ucontrol->value.enumerated.item[0];
  8217. if (idx >= imux->num_items)
  8218. idx = imux->num_items - 1;
  8219. if (*cur_val == idx)
  8220. return 0;
  8221. for (i = 0; i < imux->num_items; i++) {
  8222. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8223. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8224. imux->items[i].index,
  8225. HDA_AMP_MUTE, v);
  8226. snd_hda_codec_write_cache(codec, nid, 0,
  8227. AC_VERB_SET_CONNECT_SEL,
  8228. idx );
  8229. }
  8230. *cur_val = idx;
  8231. return 1;
  8232. }
  8233. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8234. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8235. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8236. {
  8237. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8238. /* The multiple "Capture Source" controls confuse alsamixer
  8239. * So call somewhat different..
  8240. * FIXME: the controls appear in the "playback" view!
  8241. */
  8242. /* .name = "Capture Source", */
  8243. .name = "Input Source",
  8244. .count = 1,
  8245. .info = alc268_mux_enum_info,
  8246. .get = alc268_mux_enum_get,
  8247. .put = alc268_mux_enum_put,
  8248. },
  8249. { } /* end */
  8250. };
  8251. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8252. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8253. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8254. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8255. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8256. {
  8257. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8258. /* The multiple "Capture Source" controls confuse alsamixer
  8259. * So call somewhat different..
  8260. * FIXME: the controls appear in the "playback" view!
  8261. */
  8262. /* .name = "Capture Source", */
  8263. .name = "Input Source",
  8264. .count = 2,
  8265. .info = alc268_mux_enum_info,
  8266. .get = alc268_mux_enum_get,
  8267. .put = alc268_mux_enum_put,
  8268. },
  8269. { } /* end */
  8270. };
  8271. static struct hda_input_mux alc268_capture_source = {
  8272. .num_items = 4,
  8273. .items = {
  8274. { "Mic", 0x0 },
  8275. { "Front Mic", 0x1 },
  8276. { "Line", 0x2 },
  8277. { "CD", 0x3 },
  8278. },
  8279. };
  8280. /* create input playback/capture controls for the given pin */
  8281. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8282. const char *ctlname, int idx)
  8283. {
  8284. char name[32];
  8285. int err;
  8286. sprintf(name, "%s Playback Volume", ctlname);
  8287. if (nid == 0x14) {
  8288. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8289. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8290. HDA_OUTPUT));
  8291. if (err < 0)
  8292. return err;
  8293. } else if (nid == 0x15) {
  8294. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8295. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8296. HDA_OUTPUT));
  8297. if (err < 0)
  8298. return err;
  8299. } else
  8300. return -1;
  8301. sprintf(name, "%s Playback Switch", ctlname);
  8302. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8303. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8304. if (err < 0)
  8305. return err;
  8306. return 0;
  8307. }
  8308. /* add playback controls from the parsed DAC table */
  8309. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8310. const struct auto_pin_cfg *cfg)
  8311. {
  8312. hda_nid_t nid;
  8313. int err;
  8314. spec->multiout.num_dacs = 2; /* only use one dac */
  8315. spec->multiout.dac_nids = spec->private_dac_nids;
  8316. spec->multiout.dac_nids[0] = 2;
  8317. spec->multiout.dac_nids[1] = 3;
  8318. nid = cfg->line_out_pins[0];
  8319. if (nid)
  8320. alc268_new_analog_output(spec, nid, "Front", 0);
  8321. nid = cfg->speaker_pins[0];
  8322. if (nid == 0x1d) {
  8323. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8324. "Speaker Playback Volume",
  8325. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8326. if (err < 0)
  8327. return err;
  8328. }
  8329. nid = cfg->hp_pins[0];
  8330. if (nid)
  8331. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8332. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8333. if (nid == 0x16) {
  8334. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8335. "Mono Playback Switch",
  8336. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8337. if (err < 0)
  8338. return err;
  8339. }
  8340. return 0;
  8341. }
  8342. /* create playback/capture controls for input pins */
  8343. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8344. const struct auto_pin_cfg *cfg)
  8345. {
  8346. struct hda_input_mux *imux = &spec->private_imux;
  8347. int i, idx1;
  8348. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8349. switch(cfg->input_pins[i]) {
  8350. case 0x18:
  8351. idx1 = 0; /* Mic 1 */
  8352. break;
  8353. case 0x19:
  8354. idx1 = 1; /* Mic 2 */
  8355. break;
  8356. case 0x1a:
  8357. idx1 = 2; /* Line In */
  8358. break;
  8359. case 0x1c:
  8360. idx1 = 3; /* CD */
  8361. break;
  8362. default:
  8363. continue;
  8364. }
  8365. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8366. imux->items[imux->num_items].index = idx1;
  8367. imux->num_items++;
  8368. }
  8369. return 0;
  8370. }
  8371. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8372. {
  8373. struct alc_spec *spec = codec->spec;
  8374. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8375. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8376. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8377. unsigned int dac_vol1, dac_vol2;
  8378. if (speaker_nid) {
  8379. snd_hda_codec_write(codec, speaker_nid, 0,
  8380. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8381. snd_hda_codec_write(codec, 0x0f, 0,
  8382. AC_VERB_SET_AMP_GAIN_MUTE,
  8383. AMP_IN_UNMUTE(1));
  8384. snd_hda_codec_write(codec, 0x10, 0,
  8385. AC_VERB_SET_AMP_GAIN_MUTE,
  8386. AMP_IN_UNMUTE(1));
  8387. } else {
  8388. snd_hda_codec_write(codec, 0x0f, 0,
  8389. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8390. snd_hda_codec_write(codec, 0x10, 0,
  8391. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8392. }
  8393. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8394. if (line_nid == 0x14)
  8395. dac_vol2 = AMP_OUT_ZERO;
  8396. else if (line_nid == 0x15)
  8397. dac_vol1 = AMP_OUT_ZERO;
  8398. if (hp_nid == 0x14)
  8399. dac_vol2 = AMP_OUT_ZERO;
  8400. else if (hp_nid == 0x15)
  8401. dac_vol1 = AMP_OUT_ZERO;
  8402. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8403. spec->autocfg.line_out_pins[1] != 0x16 ||
  8404. spec->autocfg.line_out_pins[2] != 0x16)
  8405. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8406. snd_hda_codec_write(codec, 0x02, 0,
  8407. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8408. snd_hda_codec_write(codec, 0x03, 0,
  8409. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8410. }
  8411. /* pcm configuration: identiacal with ALC880 */
  8412. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8413. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8414. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8415. /*
  8416. * BIOS auto configuration
  8417. */
  8418. static int alc268_parse_auto_config(struct hda_codec *codec)
  8419. {
  8420. struct alc_spec *spec = codec->spec;
  8421. int err;
  8422. static hda_nid_t alc268_ignore[] = { 0 };
  8423. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8424. alc268_ignore);
  8425. if (err < 0)
  8426. return err;
  8427. if (!spec->autocfg.line_outs)
  8428. return 0; /* can't find valid BIOS pin config */
  8429. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8430. if (err < 0)
  8431. return err;
  8432. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8433. if (err < 0)
  8434. return err;
  8435. spec->multiout.max_channels = 2;
  8436. /* digital only support output */
  8437. if (spec->autocfg.dig_out_pin)
  8438. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8439. if (spec->kctl_alloc)
  8440. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8441. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8442. spec->num_mux_defs = 1;
  8443. spec->input_mux = &spec->private_imux;
  8444. err = alc_auto_add_mic_boost(codec);
  8445. if (err < 0)
  8446. return err;
  8447. return 1;
  8448. }
  8449. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8450. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8451. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8452. /* init callback for auto-configuration model -- overriding the default init */
  8453. static void alc268_auto_init(struct hda_codec *codec)
  8454. {
  8455. alc268_auto_init_multi_out(codec);
  8456. alc268_auto_init_hp_out(codec);
  8457. alc268_auto_init_mono_speaker_out(codec);
  8458. alc268_auto_init_analog_input(codec);
  8459. }
  8460. /*
  8461. * configuration and preset
  8462. */
  8463. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8464. [ALC268_3ST] = "3stack",
  8465. [ALC268_TOSHIBA] = "toshiba",
  8466. [ALC268_ACER] = "acer",
  8467. [ALC268_AUTO] = "auto",
  8468. };
  8469. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8470. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8471. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8472. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8473. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8474. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8475. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8476. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8477. {}
  8478. };
  8479. static struct alc_config_preset alc268_presets[] = {
  8480. [ALC268_3ST] = {
  8481. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8482. .init_verbs = { alc268_base_init_verbs },
  8483. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8484. .dac_nids = alc268_dac_nids,
  8485. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8486. .adc_nids = alc268_adc_nids_alt,
  8487. .hp_nid = 0x03,
  8488. .dig_out_nid = ALC268_DIGOUT_NID,
  8489. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8490. .channel_mode = alc268_modes,
  8491. .input_mux = &alc268_capture_source,
  8492. },
  8493. [ALC268_TOSHIBA] = {
  8494. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8495. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8496. alc268_toshiba_verbs },
  8497. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8498. .dac_nids = alc268_dac_nids,
  8499. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8500. .adc_nids = alc268_adc_nids_alt,
  8501. .hp_nid = 0x03,
  8502. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8503. .channel_mode = alc268_modes,
  8504. .input_mux = &alc268_capture_source,
  8505. .unsol_event = alc268_toshiba_unsol_event,
  8506. .init_hook = alc268_toshiba_automute,
  8507. },
  8508. [ALC268_ACER] = {
  8509. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8510. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8511. alc268_acer_verbs },
  8512. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8513. .dac_nids = alc268_dac_nids,
  8514. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8515. .adc_nids = alc268_adc_nids_alt,
  8516. .hp_nid = 0x02,
  8517. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8518. .channel_mode = alc268_modes,
  8519. .input_mux = &alc268_capture_source,
  8520. .unsol_event = alc268_acer_unsol_event,
  8521. .init_hook = alc268_acer_init_hook,
  8522. },
  8523. };
  8524. static int patch_alc268(struct hda_codec *codec)
  8525. {
  8526. struct alc_spec *spec;
  8527. int board_config;
  8528. int err;
  8529. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8530. if (spec == NULL)
  8531. return -ENOMEM;
  8532. codec->spec = spec;
  8533. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8534. alc268_models,
  8535. alc268_cfg_tbl);
  8536. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8537. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8538. "trying auto-probe from BIOS...\n");
  8539. board_config = ALC268_AUTO;
  8540. }
  8541. if (board_config == ALC268_AUTO) {
  8542. /* automatic parse from the BIOS config */
  8543. err = alc268_parse_auto_config(codec);
  8544. if (err < 0) {
  8545. alc_free(codec);
  8546. return err;
  8547. } else if (!err) {
  8548. printk(KERN_INFO
  8549. "hda_codec: Cannot set up configuration "
  8550. "from BIOS. Using base mode...\n");
  8551. board_config = ALC268_3ST;
  8552. }
  8553. }
  8554. if (board_config != ALC268_AUTO)
  8555. setup_preset(spec, &alc268_presets[board_config]);
  8556. spec->stream_name_analog = "ALC268 Analog";
  8557. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8558. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8559. spec->stream_name_digital = "ALC268 Digital";
  8560. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8561. if (board_config == ALC268_AUTO) {
  8562. if (!spec->adc_nids && spec->input_mux) {
  8563. /* check whether NID 0x07 is valid */
  8564. unsigned int wcap = get_wcaps(codec, 0x07);
  8565. /* get type */
  8566. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8567. if (wcap != AC_WID_AUD_IN) {
  8568. spec->adc_nids = alc268_adc_nids_alt;
  8569. spec->num_adc_nids =
  8570. ARRAY_SIZE(alc268_adc_nids_alt);
  8571. spec->mixers[spec->num_mixers] =
  8572. alc268_capture_alt_mixer;
  8573. spec->num_mixers++;
  8574. } else {
  8575. spec->adc_nids = alc268_adc_nids;
  8576. spec->num_adc_nids =
  8577. ARRAY_SIZE(alc268_adc_nids);
  8578. spec->mixers[spec->num_mixers] =
  8579. alc268_capture_mixer;
  8580. spec->num_mixers++;
  8581. }
  8582. }
  8583. }
  8584. codec->patch_ops = alc_patch_ops;
  8585. if (board_config == ALC268_AUTO)
  8586. spec->init_hook = alc268_auto_init;
  8587. return 0;
  8588. }
  8589. /*
  8590. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8591. */
  8592. /*
  8593. * set the path ways for 2 channel output
  8594. * need to set the codec line out and mic 1 pin widgets to inputs
  8595. */
  8596. static struct hda_verb alc861_threestack_ch2_init[] = {
  8597. /* set pin widget 1Ah (line in) for input */
  8598. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8599. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8600. * the vref
  8601. */
  8602. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8603. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8604. #if 0
  8605. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8606. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8607. #endif
  8608. { } /* end */
  8609. };
  8610. /*
  8611. * 6ch mode
  8612. * need to set the codec line out and mic 1 pin widgets to outputs
  8613. */
  8614. static struct hda_verb alc861_threestack_ch6_init[] = {
  8615. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8616. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8617. /* set pin widget 18h (mic1) for output (CLFE)*/
  8618. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8619. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8620. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8621. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8622. #if 0
  8623. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8624. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8625. #endif
  8626. { } /* end */
  8627. };
  8628. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8629. { 2, alc861_threestack_ch2_init },
  8630. { 6, alc861_threestack_ch6_init },
  8631. };
  8632. /* Set mic1 as input and unmute the mixer */
  8633. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8634. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8635. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8636. { } /* end */
  8637. };
  8638. /* Set mic1 as output and mute mixer */
  8639. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8640. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8641. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8642. { } /* end */
  8643. };
  8644. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8645. { 2, alc861_uniwill_m31_ch2_init },
  8646. { 4, alc861_uniwill_m31_ch4_init },
  8647. };
  8648. /* Set mic1 and line-in as input and unmute the mixer */
  8649. static struct hda_verb alc861_asus_ch2_init[] = {
  8650. /* set pin widget 1Ah (line in) for input */
  8651. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8652. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8653. * the vref
  8654. */
  8655. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8656. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8657. #if 0
  8658. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8659. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8660. #endif
  8661. { } /* end */
  8662. };
  8663. /* Set mic1 nad line-in as output and mute mixer */
  8664. static struct hda_verb alc861_asus_ch6_init[] = {
  8665. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8666. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8667. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8668. /* set pin widget 18h (mic1) for output (CLFE)*/
  8669. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8670. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8671. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8672. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8673. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8674. #if 0
  8675. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8676. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8677. #endif
  8678. { } /* end */
  8679. };
  8680. static struct hda_channel_mode alc861_asus_modes[2] = {
  8681. { 2, alc861_asus_ch2_init },
  8682. { 6, alc861_asus_ch6_init },
  8683. };
  8684. /* patch-ALC861 */
  8685. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8686. /* output mixer control */
  8687. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8688. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8689. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8690. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8691. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8692. /*Input mixer control */
  8693. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8694. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8695. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8696. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8697. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8698. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8699. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8700. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8701. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8702. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8703. /* Capture mixer control */
  8704. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8705. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8706. {
  8707. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8708. .name = "Capture Source",
  8709. .count = 1,
  8710. .info = alc_mux_enum_info,
  8711. .get = alc_mux_enum_get,
  8712. .put = alc_mux_enum_put,
  8713. },
  8714. { } /* end */
  8715. };
  8716. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8717. /* output mixer control */
  8718. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8719. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8720. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8721. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8722. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8723. /* Input mixer control */
  8724. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8725. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8726. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8727. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8728. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8729. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8731. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8732. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8733. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8734. /* Capture mixer control */
  8735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8737. {
  8738. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8739. .name = "Capture Source",
  8740. .count = 1,
  8741. .info = alc_mux_enum_info,
  8742. .get = alc_mux_enum_get,
  8743. .put = alc_mux_enum_put,
  8744. },
  8745. {
  8746. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8747. .name = "Channel Mode",
  8748. .info = alc_ch_mode_info,
  8749. .get = alc_ch_mode_get,
  8750. .put = alc_ch_mode_put,
  8751. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8752. },
  8753. { } /* end */
  8754. };
  8755. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8756. /* output mixer control */
  8757. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8758. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8759. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8760. /*Capture mixer control */
  8761. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8762. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8763. {
  8764. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8765. .name = "Capture Source",
  8766. .count = 1,
  8767. .info = alc_mux_enum_info,
  8768. .get = alc_mux_enum_get,
  8769. .put = alc_mux_enum_put,
  8770. },
  8771. { } /* end */
  8772. };
  8773. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8774. /* output mixer control */
  8775. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8776. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8777. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8778. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8779. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8780. /* Input mixer control */
  8781. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8782. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8783. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8784. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8785. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8786. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8787. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8788. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8789. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8790. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8791. /* Capture mixer control */
  8792. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8793. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8794. {
  8795. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8796. .name = "Capture Source",
  8797. .count = 1,
  8798. .info = alc_mux_enum_info,
  8799. .get = alc_mux_enum_get,
  8800. .put = alc_mux_enum_put,
  8801. },
  8802. {
  8803. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8804. .name = "Channel Mode",
  8805. .info = alc_ch_mode_info,
  8806. .get = alc_ch_mode_get,
  8807. .put = alc_ch_mode_put,
  8808. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8809. },
  8810. { } /* end */
  8811. };
  8812. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8813. /* output mixer control */
  8814. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8815. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8816. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8817. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8818. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8819. /* Input mixer control */
  8820. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8821. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8822. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8823. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8824. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8825. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8826. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8827. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8828. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8829. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8830. /* Capture mixer control */
  8831. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8832. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8833. {
  8834. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8835. .name = "Capture Source",
  8836. .count = 1,
  8837. .info = alc_mux_enum_info,
  8838. .get = alc_mux_enum_get,
  8839. .put = alc_mux_enum_put,
  8840. },
  8841. {
  8842. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8843. .name = "Channel Mode",
  8844. .info = alc_ch_mode_info,
  8845. .get = alc_ch_mode_get,
  8846. .put = alc_ch_mode_put,
  8847. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8848. },
  8849. { }
  8850. };
  8851. /* additional mixer */
  8852. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8853. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8854. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8855. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8856. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8857. { }
  8858. };
  8859. /*
  8860. * generic initialization of ADC, input mixers and output mixers
  8861. */
  8862. static struct hda_verb alc861_base_init_verbs[] = {
  8863. /*
  8864. * Unmute ADC0 and set the default input to mic-in
  8865. */
  8866. /* port-A for surround (rear panel) */
  8867. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8868. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8869. /* port-B for mic-in (rear panel) with vref */
  8870. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8871. /* port-C for line-in (rear panel) */
  8872. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8873. /* port-D for Front */
  8874. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8875. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8876. /* port-E for HP out (front panel) */
  8877. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8878. /* route front PCM to HP */
  8879. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8880. /* port-F for mic-in (front panel) with vref */
  8881. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8882. /* port-G for CLFE (rear panel) */
  8883. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8884. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8885. /* port-H for side (rear panel) */
  8886. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8887. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8888. /* CD-in */
  8889. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8890. /* route front mic to ADC1*/
  8891. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8892. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8893. /* Unmute DAC0~3 & spdif out*/
  8894. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8895. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8896. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8897. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8898. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8899. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8900. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8901. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8902. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8903. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8904. /* Unmute Stereo Mixer 15 */
  8905. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8906. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8908. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8909. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8910. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8911. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8912. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8913. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8914. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8915. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8916. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8917. /* hp used DAC 3 (Front) */
  8918. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8919. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8920. { }
  8921. };
  8922. static struct hda_verb alc861_threestack_init_verbs[] = {
  8923. /*
  8924. * Unmute ADC0 and set the default input to mic-in
  8925. */
  8926. /* port-A for surround (rear panel) */
  8927. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8928. /* port-B for mic-in (rear panel) with vref */
  8929. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8930. /* port-C for line-in (rear panel) */
  8931. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8932. /* port-D for Front */
  8933. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8934. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8935. /* port-E for HP out (front panel) */
  8936. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8937. /* route front PCM to HP */
  8938. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8939. /* port-F for mic-in (front panel) with vref */
  8940. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8941. /* port-G for CLFE (rear panel) */
  8942. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8943. /* port-H for side (rear panel) */
  8944. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8945. /* CD-in */
  8946. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8947. /* route front mic to ADC1*/
  8948. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8949. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8950. /* Unmute DAC0~3 & spdif out*/
  8951. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8952. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8953. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8954. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8955. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8956. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8957. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8958. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8959. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8960. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8961. /* Unmute Stereo Mixer 15 */
  8962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8963. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8964. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8965. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8966. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8967. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8968. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8969. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8970. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8971. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8972. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8973. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8974. /* hp used DAC 3 (Front) */
  8975. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8976. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8977. { }
  8978. };
  8979. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8980. /*
  8981. * Unmute ADC0 and set the default input to mic-in
  8982. */
  8983. /* port-A for surround (rear panel) */
  8984. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8985. /* port-B for mic-in (rear panel) with vref */
  8986. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8987. /* port-C for line-in (rear panel) */
  8988. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8989. /* port-D for Front */
  8990. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8991. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8992. /* port-E for HP out (front panel) */
  8993. /* this has to be set to VREF80 */
  8994. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8995. /* route front PCM to HP */
  8996. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8997. /* port-F for mic-in (front panel) with vref */
  8998. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8999. /* port-G for CLFE (rear panel) */
  9000. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9001. /* port-H for side (rear panel) */
  9002. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9003. /* CD-in */
  9004. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9005. /* route front mic to ADC1*/
  9006. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9007. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9008. /* Unmute DAC0~3 & spdif out*/
  9009. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9010. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9011. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9012. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9013. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9014. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9015. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9016. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9017. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9018. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9019. /* Unmute Stereo Mixer 15 */
  9020. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9021. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9022. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9023. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9024. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9025. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9026. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9027. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9028. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9029. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9030. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9031. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9032. /* hp used DAC 3 (Front) */
  9033. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9034. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9035. { }
  9036. };
  9037. static struct hda_verb alc861_asus_init_verbs[] = {
  9038. /*
  9039. * Unmute ADC0 and set the default input to mic-in
  9040. */
  9041. /* port-A for surround (rear panel)
  9042. * according to codec#0 this is the HP jack
  9043. */
  9044. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  9045. /* route front PCM to HP */
  9046. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9047. /* port-B for mic-in (rear panel) with vref */
  9048. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9049. /* port-C for line-in (rear panel) */
  9050. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9051. /* port-D for Front */
  9052. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9053. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9054. /* port-E for HP out (front panel) */
  9055. /* this has to be set to VREF80 */
  9056. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9057. /* route front PCM to HP */
  9058. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9059. /* port-F for mic-in (front panel) with vref */
  9060. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9061. /* port-G for CLFE (rear panel) */
  9062. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9063. /* port-H for side (rear panel) */
  9064. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9065. /* CD-in */
  9066. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9067. /* route front mic to ADC1*/
  9068. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9069. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9070. /* Unmute DAC0~3 & spdif out*/
  9071. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9072. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9073. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9074. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9075. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9076. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9077. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9078. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9079. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9080. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9081. /* Unmute Stereo Mixer 15 */
  9082. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9083. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9084. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9085. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9086. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9087. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9088. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9089. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9090. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9091. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9092. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9093. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9094. /* hp used DAC 3 (Front) */
  9095. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9096. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9097. { }
  9098. };
  9099. /* additional init verbs for ASUS laptops */
  9100. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9101. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9102. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9103. { }
  9104. };
  9105. /*
  9106. * generic initialization of ADC, input mixers and output mixers
  9107. */
  9108. static struct hda_verb alc861_auto_init_verbs[] = {
  9109. /*
  9110. * Unmute ADC0 and set the default input to mic-in
  9111. */
  9112. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9113. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9114. /* Unmute DAC0~3 & spdif out*/
  9115. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9116. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9117. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9118. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9119. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9120. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9121. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9122. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9123. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9124. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9125. /* Unmute Stereo Mixer 15 */
  9126. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9127. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9128. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9129. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9130. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9131. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9132. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9133. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9134. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9135. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9136. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9137. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9138. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9139. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9140. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9141. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9142. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9143. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9144. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9145. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9146. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9147. { }
  9148. };
  9149. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9150. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9151. { }
  9152. };
  9153. /* toggle speaker-output according to the hp-jack state */
  9154. static void alc861_toshiba_automute(struct hda_codec *codec)
  9155. {
  9156. unsigned int present;
  9157. present = snd_hda_codec_read(codec, 0x0f, 0,
  9158. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9159. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9160. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9161. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9162. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9163. }
  9164. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9165. unsigned int res)
  9166. {
  9167. if ((res >> 26) == ALC880_HP_EVENT)
  9168. alc861_toshiba_automute(codec);
  9169. }
  9170. /* pcm configuration: identiacal with ALC880 */
  9171. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9172. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9173. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9174. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9175. #define ALC861_DIGOUT_NID 0x07
  9176. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9177. { 8, NULL }
  9178. };
  9179. static hda_nid_t alc861_dac_nids[4] = {
  9180. /* front, surround, clfe, side */
  9181. 0x03, 0x06, 0x05, 0x04
  9182. };
  9183. static hda_nid_t alc660_dac_nids[3] = {
  9184. /* front, clfe, surround */
  9185. 0x03, 0x05, 0x06
  9186. };
  9187. static hda_nid_t alc861_adc_nids[1] = {
  9188. /* ADC0-2 */
  9189. 0x08,
  9190. };
  9191. static struct hda_input_mux alc861_capture_source = {
  9192. .num_items = 5,
  9193. .items = {
  9194. { "Mic", 0x0 },
  9195. { "Front Mic", 0x3 },
  9196. { "Line", 0x1 },
  9197. { "CD", 0x4 },
  9198. { "Mixer", 0x5 },
  9199. },
  9200. };
  9201. /* fill in the dac_nids table from the parsed pin configuration */
  9202. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9203. const struct auto_pin_cfg *cfg)
  9204. {
  9205. int i;
  9206. hda_nid_t nid;
  9207. spec->multiout.dac_nids = spec->private_dac_nids;
  9208. for (i = 0; i < cfg->line_outs; i++) {
  9209. nid = cfg->line_out_pins[i];
  9210. if (nid) {
  9211. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9212. continue;
  9213. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9214. }
  9215. }
  9216. spec->multiout.num_dacs = cfg->line_outs;
  9217. return 0;
  9218. }
  9219. /* add playback controls from the parsed DAC table */
  9220. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9221. const struct auto_pin_cfg *cfg)
  9222. {
  9223. char name[32];
  9224. static const char *chname[4] = {
  9225. "Front", "Surround", NULL /*CLFE*/, "Side"
  9226. };
  9227. hda_nid_t nid;
  9228. int i, idx, err;
  9229. for (i = 0; i < cfg->line_outs; i++) {
  9230. nid = spec->multiout.dac_nids[i];
  9231. if (!nid)
  9232. continue;
  9233. if (nid == 0x05) {
  9234. /* Center/LFE */
  9235. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9236. "Center Playback Switch",
  9237. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9238. HDA_OUTPUT));
  9239. if (err < 0)
  9240. return err;
  9241. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9242. "LFE Playback Switch",
  9243. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9244. HDA_OUTPUT));
  9245. if (err < 0)
  9246. return err;
  9247. } else {
  9248. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9249. idx++)
  9250. if (nid == alc861_dac_nids[idx])
  9251. break;
  9252. sprintf(name, "%s Playback Switch", chname[idx]);
  9253. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9254. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9255. HDA_OUTPUT));
  9256. if (err < 0)
  9257. return err;
  9258. }
  9259. }
  9260. return 0;
  9261. }
  9262. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9263. {
  9264. int err;
  9265. hda_nid_t nid;
  9266. if (!pin)
  9267. return 0;
  9268. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9269. nid = 0x03;
  9270. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9271. "Headphone Playback Switch",
  9272. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9273. if (err < 0)
  9274. return err;
  9275. spec->multiout.hp_nid = nid;
  9276. }
  9277. return 0;
  9278. }
  9279. /* create playback/capture controls for input pins */
  9280. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9281. const struct auto_pin_cfg *cfg)
  9282. {
  9283. struct hda_input_mux *imux = &spec->private_imux;
  9284. int i, err, idx, idx1;
  9285. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9286. switch (cfg->input_pins[i]) {
  9287. case 0x0c:
  9288. idx1 = 1;
  9289. idx = 2; /* Line In */
  9290. break;
  9291. case 0x0f:
  9292. idx1 = 2;
  9293. idx = 2; /* Line In */
  9294. break;
  9295. case 0x0d:
  9296. idx1 = 0;
  9297. idx = 1; /* Mic In */
  9298. break;
  9299. case 0x10:
  9300. idx1 = 3;
  9301. idx = 1; /* Mic In */
  9302. break;
  9303. case 0x11:
  9304. idx1 = 4;
  9305. idx = 0; /* CD */
  9306. break;
  9307. default:
  9308. continue;
  9309. }
  9310. err = new_analog_input(spec, cfg->input_pins[i],
  9311. auto_pin_cfg_labels[i], idx, 0x15);
  9312. if (err < 0)
  9313. return err;
  9314. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9315. imux->items[imux->num_items].index = idx1;
  9316. imux->num_items++;
  9317. }
  9318. return 0;
  9319. }
  9320. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9321. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9322. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9323. {
  9324. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9325. /* The multiple "Capture Source" controls confuse alsamixer
  9326. * So call somewhat different..
  9327. *FIXME: the controls appear in the "playback" view!
  9328. */
  9329. /* .name = "Capture Source", */
  9330. .name = "Input Source",
  9331. .count = 1,
  9332. .info = alc_mux_enum_info,
  9333. .get = alc_mux_enum_get,
  9334. .put = alc_mux_enum_put,
  9335. },
  9336. { } /* end */
  9337. };
  9338. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9339. hda_nid_t nid,
  9340. int pin_type, int dac_idx)
  9341. {
  9342. /* set as output */
  9343. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9344. pin_type);
  9345. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9346. AMP_OUT_UNMUTE);
  9347. }
  9348. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9349. {
  9350. struct alc_spec *spec = codec->spec;
  9351. int i;
  9352. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9353. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9354. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9355. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9356. if (nid)
  9357. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9358. spec->multiout.dac_nids[i]);
  9359. }
  9360. }
  9361. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9362. {
  9363. struct alc_spec *spec = codec->spec;
  9364. hda_nid_t pin;
  9365. pin = spec->autocfg.hp_pins[0];
  9366. if (pin) /* connect to front */
  9367. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9368. spec->multiout.dac_nids[0]);
  9369. }
  9370. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9371. {
  9372. struct alc_spec *spec = codec->spec;
  9373. int i;
  9374. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9375. hda_nid_t nid = spec->autocfg.input_pins[i];
  9376. if (nid >= 0x0c && nid <= 0x11) {
  9377. snd_hda_codec_write(codec, nid, 0,
  9378. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9379. i <= AUTO_PIN_FRONT_MIC ?
  9380. PIN_VREF80 : PIN_IN);
  9381. }
  9382. }
  9383. }
  9384. /* parse the BIOS configuration and set up the alc_spec */
  9385. /* return 1 if successful, 0 if the proper config is not found,
  9386. * or a negative error code
  9387. */
  9388. static int alc861_parse_auto_config(struct hda_codec *codec)
  9389. {
  9390. struct alc_spec *spec = codec->spec;
  9391. int err;
  9392. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9393. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9394. alc861_ignore);
  9395. if (err < 0)
  9396. return err;
  9397. if (!spec->autocfg.line_outs)
  9398. return 0; /* can't find valid BIOS pin config */
  9399. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9400. if (err < 0)
  9401. return err;
  9402. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9403. if (err < 0)
  9404. return err;
  9405. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9406. if (err < 0)
  9407. return err;
  9408. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9409. if (err < 0)
  9410. return err;
  9411. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9412. if (spec->autocfg.dig_out_pin)
  9413. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9414. if (spec->kctl_alloc)
  9415. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9416. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9417. spec->num_mux_defs = 1;
  9418. spec->input_mux = &spec->private_imux;
  9419. spec->adc_nids = alc861_adc_nids;
  9420. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9421. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9422. spec->num_mixers++;
  9423. return 1;
  9424. }
  9425. /* additional initialization for auto-configuration model */
  9426. static void alc861_auto_init(struct hda_codec *codec)
  9427. {
  9428. alc861_auto_init_multi_out(codec);
  9429. alc861_auto_init_hp_out(codec);
  9430. alc861_auto_init_analog_input(codec);
  9431. }
  9432. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9433. static struct hda_amp_list alc861_loopbacks[] = {
  9434. { 0x15, HDA_INPUT, 0 },
  9435. { 0x15, HDA_INPUT, 1 },
  9436. { 0x15, HDA_INPUT, 2 },
  9437. { 0x15, HDA_INPUT, 3 },
  9438. { } /* end */
  9439. };
  9440. #endif
  9441. /*
  9442. * configuration and preset
  9443. */
  9444. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9445. [ALC861_3ST] = "3stack",
  9446. [ALC660_3ST] = "3stack-660",
  9447. [ALC861_3ST_DIG] = "3stack-dig",
  9448. [ALC861_6ST_DIG] = "6stack-dig",
  9449. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9450. [ALC861_TOSHIBA] = "toshiba",
  9451. [ALC861_ASUS] = "asus",
  9452. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9453. [ALC861_AUTO] = "auto",
  9454. };
  9455. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9456. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9457. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9458. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9459. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9460. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9461. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9462. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9463. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9464. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9465. * Any other models that need this preset?
  9466. */
  9467. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9468. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9469. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9470. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9471. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9472. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9473. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9474. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9475. {}
  9476. };
  9477. static struct alc_config_preset alc861_presets[] = {
  9478. [ALC861_3ST] = {
  9479. .mixers = { alc861_3ST_mixer },
  9480. .init_verbs = { alc861_threestack_init_verbs },
  9481. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9482. .dac_nids = alc861_dac_nids,
  9483. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9484. .channel_mode = alc861_threestack_modes,
  9485. .need_dac_fix = 1,
  9486. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9487. .adc_nids = alc861_adc_nids,
  9488. .input_mux = &alc861_capture_source,
  9489. },
  9490. [ALC861_3ST_DIG] = {
  9491. .mixers = { alc861_base_mixer },
  9492. .init_verbs = { alc861_threestack_init_verbs },
  9493. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9494. .dac_nids = alc861_dac_nids,
  9495. .dig_out_nid = ALC861_DIGOUT_NID,
  9496. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9497. .channel_mode = alc861_threestack_modes,
  9498. .need_dac_fix = 1,
  9499. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9500. .adc_nids = alc861_adc_nids,
  9501. .input_mux = &alc861_capture_source,
  9502. },
  9503. [ALC861_6ST_DIG] = {
  9504. .mixers = { alc861_base_mixer },
  9505. .init_verbs = { alc861_base_init_verbs },
  9506. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9507. .dac_nids = alc861_dac_nids,
  9508. .dig_out_nid = ALC861_DIGOUT_NID,
  9509. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9510. .channel_mode = alc861_8ch_modes,
  9511. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9512. .adc_nids = alc861_adc_nids,
  9513. .input_mux = &alc861_capture_source,
  9514. },
  9515. [ALC660_3ST] = {
  9516. .mixers = { alc861_3ST_mixer },
  9517. .init_verbs = { alc861_threestack_init_verbs },
  9518. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9519. .dac_nids = alc660_dac_nids,
  9520. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9521. .channel_mode = alc861_threestack_modes,
  9522. .need_dac_fix = 1,
  9523. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9524. .adc_nids = alc861_adc_nids,
  9525. .input_mux = &alc861_capture_source,
  9526. },
  9527. [ALC861_UNIWILL_M31] = {
  9528. .mixers = { alc861_uniwill_m31_mixer },
  9529. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9530. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9531. .dac_nids = alc861_dac_nids,
  9532. .dig_out_nid = ALC861_DIGOUT_NID,
  9533. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9534. .channel_mode = alc861_uniwill_m31_modes,
  9535. .need_dac_fix = 1,
  9536. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9537. .adc_nids = alc861_adc_nids,
  9538. .input_mux = &alc861_capture_source,
  9539. },
  9540. [ALC861_TOSHIBA] = {
  9541. .mixers = { alc861_toshiba_mixer },
  9542. .init_verbs = { alc861_base_init_verbs,
  9543. alc861_toshiba_init_verbs },
  9544. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9545. .dac_nids = alc861_dac_nids,
  9546. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9547. .channel_mode = alc883_3ST_2ch_modes,
  9548. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9549. .adc_nids = alc861_adc_nids,
  9550. .input_mux = &alc861_capture_source,
  9551. .unsol_event = alc861_toshiba_unsol_event,
  9552. .init_hook = alc861_toshiba_automute,
  9553. },
  9554. [ALC861_ASUS] = {
  9555. .mixers = { alc861_asus_mixer },
  9556. .init_verbs = { alc861_asus_init_verbs },
  9557. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9558. .dac_nids = alc861_dac_nids,
  9559. .dig_out_nid = ALC861_DIGOUT_NID,
  9560. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9561. .channel_mode = alc861_asus_modes,
  9562. .need_dac_fix = 1,
  9563. .hp_nid = 0x06,
  9564. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9565. .adc_nids = alc861_adc_nids,
  9566. .input_mux = &alc861_capture_source,
  9567. },
  9568. [ALC861_ASUS_LAPTOP] = {
  9569. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9570. .init_verbs = { alc861_asus_init_verbs,
  9571. alc861_asus_laptop_init_verbs },
  9572. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9573. .dac_nids = alc861_dac_nids,
  9574. .dig_out_nid = ALC861_DIGOUT_NID,
  9575. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9576. .channel_mode = alc883_3ST_2ch_modes,
  9577. .need_dac_fix = 1,
  9578. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9579. .adc_nids = alc861_adc_nids,
  9580. .input_mux = &alc861_capture_source,
  9581. },
  9582. };
  9583. static int patch_alc861(struct hda_codec *codec)
  9584. {
  9585. struct alc_spec *spec;
  9586. int board_config;
  9587. int err;
  9588. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9589. if (spec == NULL)
  9590. return -ENOMEM;
  9591. codec->spec = spec;
  9592. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9593. alc861_models,
  9594. alc861_cfg_tbl);
  9595. if (board_config < 0) {
  9596. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9597. "trying auto-probe from BIOS...\n");
  9598. board_config = ALC861_AUTO;
  9599. }
  9600. if (board_config == ALC861_AUTO) {
  9601. /* automatic parse from the BIOS config */
  9602. err = alc861_parse_auto_config(codec);
  9603. if (err < 0) {
  9604. alc_free(codec);
  9605. return err;
  9606. } else if (!err) {
  9607. printk(KERN_INFO
  9608. "hda_codec: Cannot set up configuration "
  9609. "from BIOS. Using base mode...\n");
  9610. board_config = ALC861_3ST_DIG;
  9611. }
  9612. }
  9613. if (board_config != ALC861_AUTO)
  9614. setup_preset(spec, &alc861_presets[board_config]);
  9615. spec->stream_name_analog = "ALC861 Analog";
  9616. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9617. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9618. spec->stream_name_digital = "ALC861 Digital";
  9619. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9620. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9621. codec->patch_ops = alc_patch_ops;
  9622. if (board_config == ALC861_AUTO)
  9623. spec->init_hook = alc861_auto_init;
  9624. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9625. if (!spec->loopback.amplist)
  9626. spec->loopback.amplist = alc861_loopbacks;
  9627. #endif
  9628. return 0;
  9629. }
  9630. /*
  9631. * ALC861-VD support
  9632. *
  9633. * Based on ALC882
  9634. *
  9635. * In addition, an independent DAC
  9636. */
  9637. #define ALC861VD_DIGOUT_NID 0x06
  9638. static hda_nid_t alc861vd_dac_nids[4] = {
  9639. /* front, surr, clfe, side surr */
  9640. 0x02, 0x03, 0x04, 0x05
  9641. };
  9642. /* dac_nids for ALC660vd are in a different order - according to
  9643. * Realtek's driver.
  9644. * This should probably tesult in a different mixer for 6stack models
  9645. * of ALC660vd codecs, but for now there is only 3stack mixer
  9646. * - and it is the same as in 861vd.
  9647. * adc_nids in ALC660vd are (is) the same as in 861vd
  9648. */
  9649. static hda_nid_t alc660vd_dac_nids[3] = {
  9650. /* front, rear, clfe, rear_surr */
  9651. 0x02, 0x04, 0x03
  9652. };
  9653. static hda_nid_t alc861vd_adc_nids[1] = {
  9654. /* ADC0 */
  9655. 0x09,
  9656. };
  9657. /* input MUX */
  9658. /* FIXME: should be a matrix-type input source selection */
  9659. static struct hda_input_mux alc861vd_capture_source = {
  9660. .num_items = 4,
  9661. .items = {
  9662. { "Mic", 0x0 },
  9663. { "Front Mic", 0x1 },
  9664. { "Line", 0x2 },
  9665. { "CD", 0x4 },
  9666. },
  9667. };
  9668. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9669. .num_items = 3,
  9670. .items = {
  9671. { "Front Mic", 0x0 },
  9672. { "ATAPI Mic", 0x1 },
  9673. { "Line In", 0x5 },
  9674. },
  9675. };
  9676. static struct hda_input_mux alc861vd_hp_capture_source = {
  9677. .num_items = 2,
  9678. .items = {
  9679. { "Front Mic", 0x0 },
  9680. { "ATAPI Mic", 0x1 },
  9681. },
  9682. };
  9683. #define alc861vd_mux_enum_info alc_mux_enum_info
  9684. #define alc861vd_mux_enum_get alc_mux_enum_get
  9685. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9686. struct snd_ctl_elem_value *ucontrol)
  9687. {
  9688. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9689. struct alc_spec *spec = codec->spec;
  9690. const struct hda_input_mux *imux = spec->input_mux;
  9691. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9692. static hda_nid_t capture_mixers[1] = { 0x22 };
  9693. hda_nid_t nid = capture_mixers[adc_idx];
  9694. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9695. unsigned int i, idx;
  9696. idx = ucontrol->value.enumerated.item[0];
  9697. if (idx >= imux->num_items)
  9698. idx = imux->num_items - 1;
  9699. if (*cur_val == idx)
  9700. return 0;
  9701. for (i = 0; i < imux->num_items; i++) {
  9702. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9703. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9704. imux->items[i].index,
  9705. HDA_AMP_MUTE, v);
  9706. }
  9707. *cur_val = idx;
  9708. return 1;
  9709. }
  9710. /*
  9711. * 2ch mode
  9712. */
  9713. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9714. { 2, NULL }
  9715. };
  9716. /*
  9717. * 6ch mode
  9718. */
  9719. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9720. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9721. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9722. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9723. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9724. { } /* end */
  9725. };
  9726. /*
  9727. * 8ch mode
  9728. */
  9729. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9730. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9731. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9732. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9733. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9734. { } /* end */
  9735. };
  9736. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9737. { 6, alc861vd_6stack_ch6_init },
  9738. { 8, alc861vd_6stack_ch8_init },
  9739. };
  9740. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9741. {
  9742. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9743. .name = "Channel Mode",
  9744. .info = alc_ch_mode_info,
  9745. .get = alc_ch_mode_get,
  9746. .put = alc_ch_mode_put,
  9747. },
  9748. { } /* end */
  9749. };
  9750. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9751. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9752. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9753. {
  9754. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9755. /* The multiple "Capture Source" controls confuse alsamixer
  9756. * So call somewhat different..
  9757. *FIXME: the controls appear in the "playback" view!
  9758. */
  9759. /* .name = "Capture Source", */
  9760. .name = "Input Source",
  9761. .count = 1,
  9762. .info = alc861vd_mux_enum_info,
  9763. .get = alc861vd_mux_enum_get,
  9764. .put = alc861vd_mux_enum_put,
  9765. },
  9766. { } /* end */
  9767. };
  9768. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9769. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9770. */
  9771. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9772. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9773. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9774. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9775. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9776. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9777. HDA_OUTPUT),
  9778. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9779. HDA_OUTPUT),
  9780. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9781. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9782. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9783. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9784. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9785. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9786. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9787. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9788. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9789. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9790. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9791. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9792. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9793. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9794. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9795. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9796. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9797. { } /* end */
  9798. };
  9799. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9800. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9801. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9802. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9803. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9804. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9805. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9806. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9807. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9808. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9809. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9810. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9811. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9812. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9813. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9814. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9815. { } /* end */
  9816. };
  9817. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9818. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9819. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9820. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9821. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9822. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9823. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9824. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9825. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9826. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9827. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9828. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9829. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9830. { } /* end */
  9831. };
  9832. /* Pin assignment: Front=0x14, HP = 0x15,
  9833. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9834. */
  9835. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9836. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9837. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9838. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9839. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9840. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9841. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9842. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9843. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9844. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9845. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9846. { } /* end */
  9847. };
  9848. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9849. * Front Mic=0x18, ATAPI Mic = 0x19,
  9850. */
  9851. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9852. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9853. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9854. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9855. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9856. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9857. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9858. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9859. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9860. { } /* end */
  9861. };
  9862. /*
  9863. * generic initialization of ADC, input mixers and output mixers
  9864. */
  9865. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9866. /*
  9867. * Unmute ADC0 and set the default input to mic-in
  9868. */
  9869. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9870. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9871. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9872. * the analog-loopback mixer widget
  9873. */
  9874. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9875. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9880. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9881. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9882. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9883. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9884. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9885. /*
  9886. * Set up output mixers (0x02 - 0x05)
  9887. */
  9888. /* set vol=0 to output mixers */
  9889. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9890. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9891. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9892. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9893. /* set up input amps for analog loopback */
  9894. /* Amp Indices: DAC = 0, mixer = 1 */
  9895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9896. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9897. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9898. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9899. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9900. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9901. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9902. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9903. { }
  9904. };
  9905. /*
  9906. * 3-stack pin configuration:
  9907. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9908. */
  9909. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9910. /*
  9911. * Set pin mode and muting
  9912. */
  9913. /* set front pin widgets 0x14 for output */
  9914. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9915. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9916. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9917. /* Mic (rear) pin: input vref at 80% */
  9918. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9919. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9920. /* Front Mic pin: input vref at 80% */
  9921. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9922. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9923. /* Line In pin: input */
  9924. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9925. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9926. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9927. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9928. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9929. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9930. /* CD pin widget for input */
  9931. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9932. { }
  9933. };
  9934. /*
  9935. * 6-stack pin configuration:
  9936. */
  9937. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9938. /*
  9939. * Set pin mode and muting
  9940. */
  9941. /* set front pin widgets 0x14 for output */
  9942. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9943. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9944. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9945. /* Rear Pin: output 1 (0x0d) */
  9946. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9947. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9948. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9949. /* CLFE Pin: output 2 (0x0e) */
  9950. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9951. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9952. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9953. /* Side Pin: output 3 (0x0f) */
  9954. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9955. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9956. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9957. /* Mic (rear) pin: input vref at 80% */
  9958. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9959. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9960. /* Front Mic pin: input vref at 80% */
  9961. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9962. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9963. /* Line In pin: input */
  9964. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9965. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9966. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9967. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9968. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9969. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9970. /* CD pin widget for input */
  9971. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9972. { }
  9973. };
  9974. static struct hda_verb alc861vd_eapd_verbs[] = {
  9975. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9976. { }
  9977. };
  9978. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9979. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9980. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9982. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9983. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9984. {}
  9985. };
  9986. /* toggle speaker-output according to the hp-jack state */
  9987. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9988. {
  9989. unsigned int present;
  9990. unsigned char bits;
  9991. present = snd_hda_codec_read(codec, 0x1b, 0,
  9992. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9993. bits = present ? HDA_AMP_MUTE : 0;
  9994. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9995. HDA_AMP_MUTE, bits);
  9996. }
  9997. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9998. {
  9999. unsigned int present;
  10000. unsigned char bits;
  10001. present = snd_hda_codec_read(codec, 0x18, 0,
  10002. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10003. bits = present ? HDA_AMP_MUTE : 0;
  10004. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  10005. HDA_AMP_MUTE, bits);
  10006. }
  10007. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  10008. {
  10009. alc861vd_lenovo_hp_automute(codec);
  10010. alc861vd_lenovo_mic_automute(codec);
  10011. }
  10012. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  10013. unsigned int res)
  10014. {
  10015. switch (res >> 26) {
  10016. case ALC880_HP_EVENT:
  10017. alc861vd_lenovo_hp_automute(codec);
  10018. break;
  10019. case ALC880_MIC_EVENT:
  10020. alc861vd_lenovo_mic_automute(codec);
  10021. break;
  10022. }
  10023. }
  10024. static struct hda_verb alc861vd_dallas_verbs[] = {
  10025. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10026. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10027. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10028. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10032. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10034. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10035. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10036. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10037. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10038. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10039. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10040. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10041. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10042. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10043. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10044. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10045. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10046. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10047. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10048. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10049. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10050. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10051. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10052. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10053. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10054. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10055. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10056. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10057. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10058. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10059. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10060. { } /* end */
  10061. };
  10062. /* toggle speaker-output according to the hp-jack state */
  10063. static void alc861vd_dallas_automute(struct hda_codec *codec)
  10064. {
  10065. unsigned int present;
  10066. present = snd_hda_codec_read(codec, 0x15, 0,
  10067. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10068. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10069. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  10070. }
  10071. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  10072. {
  10073. if ((res >> 26) == ALC880_HP_EVENT)
  10074. alc861vd_dallas_automute(codec);
  10075. }
  10076. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10077. #define alc861vd_loopbacks alc880_loopbacks
  10078. #endif
  10079. /* pcm configuration: identiacal with ALC880 */
  10080. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10081. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10082. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10083. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10084. /*
  10085. * configuration and preset
  10086. */
  10087. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10088. [ALC660VD_3ST] = "3stack-660",
  10089. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10090. [ALC861VD_3ST] = "3stack",
  10091. [ALC861VD_3ST_DIG] = "3stack-digout",
  10092. [ALC861VD_6ST_DIG] = "6stack-digout",
  10093. [ALC861VD_LENOVO] = "lenovo",
  10094. [ALC861VD_DALLAS] = "dallas",
  10095. [ALC861VD_HP] = "hp",
  10096. [ALC861VD_AUTO] = "auto",
  10097. };
  10098. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10099. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10100. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10101. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10102. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10103. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10104. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10105. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10106. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10107. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10108. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10109. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10110. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10111. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10112. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10113. {}
  10114. };
  10115. static struct alc_config_preset alc861vd_presets[] = {
  10116. [ALC660VD_3ST] = {
  10117. .mixers = { alc861vd_3st_mixer },
  10118. .init_verbs = { alc861vd_volume_init_verbs,
  10119. alc861vd_3stack_init_verbs },
  10120. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10121. .dac_nids = alc660vd_dac_nids,
  10122. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10123. .adc_nids = alc861vd_adc_nids,
  10124. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10125. .channel_mode = alc861vd_3stack_2ch_modes,
  10126. .input_mux = &alc861vd_capture_source,
  10127. },
  10128. [ALC660VD_3ST_DIG] = {
  10129. .mixers = { alc861vd_3st_mixer },
  10130. .init_verbs = { alc861vd_volume_init_verbs,
  10131. alc861vd_3stack_init_verbs },
  10132. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10133. .dac_nids = alc660vd_dac_nids,
  10134. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10135. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10136. .adc_nids = alc861vd_adc_nids,
  10137. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10138. .channel_mode = alc861vd_3stack_2ch_modes,
  10139. .input_mux = &alc861vd_capture_source,
  10140. },
  10141. [ALC861VD_3ST] = {
  10142. .mixers = { alc861vd_3st_mixer },
  10143. .init_verbs = { alc861vd_volume_init_verbs,
  10144. alc861vd_3stack_init_verbs },
  10145. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10146. .dac_nids = alc861vd_dac_nids,
  10147. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10148. .channel_mode = alc861vd_3stack_2ch_modes,
  10149. .input_mux = &alc861vd_capture_source,
  10150. },
  10151. [ALC861VD_3ST_DIG] = {
  10152. .mixers = { alc861vd_3st_mixer },
  10153. .init_verbs = { alc861vd_volume_init_verbs,
  10154. alc861vd_3stack_init_verbs },
  10155. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10156. .dac_nids = alc861vd_dac_nids,
  10157. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10158. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10159. .channel_mode = alc861vd_3stack_2ch_modes,
  10160. .input_mux = &alc861vd_capture_source,
  10161. },
  10162. [ALC861VD_6ST_DIG] = {
  10163. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10164. .init_verbs = { alc861vd_volume_init_verbs,
  10165. alc861vd_6stack_init_verbs },
  10166. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10167. .dac_nids = alc861vd_dac_nids,
  10168. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10169. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10170. .channel_mode = alc861vd_6stack_modes,
  10171. .input_mux = &alc861vd_capture_source,
  10172. },
  10173. [ALC861VD_LENOVO] = {
  10174. .mixers = { alc861vd_lenovo_mixer },
  10175. .init_verbs = { alc861vd_volume_init_verbs,
  10176. alc861vd_3stack_init_verbs,
  10177. alc861vd_eapd_verbs,
  10178. alc861vd_lenovo_unsol_verbs },
  10179. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10180. .dac_nids = alc660vd_dac_nids,
  10181. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10182. .adc_nids = alc861vd_adc_nids,
  10183. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10184. .channel_mode = alc861vd_3stack_2ch_modes,
  10185. .input_mux = &alc861vd_capture_source,
  10186. .unsol_event = alc861vd_lenovo_unsol_event,
  10187. .init_hook = alc861vd_lenovo_automute,
  10188. },
  10189. [ALC861VD_DALLAS] = {
  10190. .mixers = { alc861vd_dallas_mixer },
  10191. .init_verbs = { alc861vd_dallas_verbs },
  10192. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10193. .dac_nids = alc861vd_dac_nids,
  10194. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10195. .adc_nids = alc861vd_adc_nids,
  10196. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10197. .channel_mode = alc861vd_3stack_2ch_modes,
  10198. .input_mux = &alc861vd_dallas_capture_source,
  10199. .unsol_event = alc861vd_dallas_unsol_event,
  10200. .init_hook = alc861vd_dallas_automute,
  10201. },
  10202. [ALC861VD_HP] = {
  10203. .mixers = { alc861vd_hp_mixer },
  10204. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10205. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10206. .dac_nids = alc861vd_dac_nids,
  10207. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10208. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10209. .adc_nids = alc861vd_adc_nids,
  10210. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10211. .channel_mode = alc861vd_3stack_2ch_modes,
  10212. .input_mux = &alc861vd_hp_capture_source,
  10213. .unsol_event = alc861vd_dallas_unsol_event,
  10214. .init_hook = alc861vd_dallas_automute,
  10215. },
  10216. };
  10217. /*
  10218. * BIOS auto configuration
  10219. */
  10220. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10221. hda_nid_t nid, int pin_type, int dac_idx)
  10222. {
  10223. /* set as output */
  10224. snd_hda_codec_write(codec, nid, 0,
  10225. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10226. snd_hda_codec_write(codec, nid, 0,
  10227. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10228. }
  10229. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10230. {
  10231. struct alc_spec *spec = codec->spec;
  10232. int i;
  10233. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10234. for (i = 0; i <= HDA_SIDE; i++) {
  10235. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10236. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10237. if (nid)
  10238. alc861vd_auto_set_output_and_unmute(codec, nid,
  10239. pin_type, i);
  10240. }
  10241. }
  10242. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10243. {
  10244. struct alc_spec *spec = codec->spec;
  10245. hda_nid_t pin;
  10246. pin = spec->autocfg.hp_pins[0];
  10247. if (pin) /* connect to front and use dac 0 */
  10248. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10249. }
  10250. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10251. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10252. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10253. {
  10254. struct alc_spec *spec = codec->spec;
  10255. int i;
  10256. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10257. hda_nid_t nid = spec->autocfg.input_pins[i];
  10258. if (alc861vd_is_input_pin(nid)) {
  10259. snd_hda_codec_write(codec, nid, 0,
  10260. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10261. i <= AUTO_PIN_FRONT_MIC ?
  10262. PIN_VREF80 : PIN_IN);
  10263. if (nid != ALC861VD_PIN_CD_NID)
  10264. snd_hda_codec_write(codec, nid, 0,
  10265. AC_VERB_SET_AMP_GAIN_MUTE,
  10266. AMP_OUT_MUTE);
  10267. }
  10268. }
  10269. }
  10270. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10271. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10272. /* add playback controls from the parsed DAC table */
  10273. /* Based on ALC880 version. But ALC861VD has separate,
  10274. * different NIDs for mute/unmute switch and volume control */
  10275. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10276. const struct auto_pin_cfg *cfg)
  10277. {
  10278. char name[32];
  10279. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10280. hda_nid_t nid_v, nid_s;
  10281. int i, err;
  10282. for (i = 0; i < cfg->line_outs; i++) {
  10283. if (!spec->multiout.dac_nids[i])
  10284. continue;
  10285. nid_v = alc861vd_idx_to_mixer_vol(
  10286. alc880_dac_to_idx(
  10287. spec->multiout.dac_nids[i]));
  10288. nid_s = alc861vd_idx_to_mixer_switch(
  10289. alc880_dac_to_idx(
  10290. spec->multiout.dac_nids[i]));
  10291. if (i == 2) {
  10292. /* Center/LFE */
  10293. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10294. "Center Playback Volume",
  10295. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10296. HDA_OUTPUT));
  10297. if (err < 0)
  10298. return err;
  10299. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10300. "LFE Playback Volume",
  10301. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10302. HDA_OUTPUT));
  10303. if (err < 0)
  10304. return err;
  10305. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10306. "Center Playback Switch",
  10307. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10308. HDA_INPUT));
  10309. if (err < 0)
  10310. return err;
  10311. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10312. "LFE Playback Switch",
  10313. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10314. HDA_INPUT));
  10315. if (err < 0)
  10316. return err;
  10317. } else {
  10318. sprintf(name, "%s Playback Volume", chname[i]);
  10319. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10320. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10321. HDA_OUTPUT));
  10322. if (err < 0)
  10323. return err;
  10324. sprintf(name, "%s Playback Switch", chname[i]);
  10325. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10326. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10327. HDA_INPUT));
  10328. if (err < 0)
  10329. return err;
  10330. }
  10331. }
  10332. return 0;
  10333. }
  10334. /* add playback controls for speaker and HP outputs */
  10335. /* Based on ALC880 version. But ALC861VD has separate,
  10336. * different NIDs for mute/unmute switch and volume control */
  10337. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10338. hda_nid_t pin, const char *pfx)
  10339. {
  10340. hda_nid_t nid_v, nid_s;
  10341. int err;
  10342. char name[32];
  10343. if (!pin)
  10344. return 0;
  10345. if (alc880_is_fixed_pin(pin)) {
  10346. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10347. /* specify the DAC as the extra output */
  10348. if (!spec->multiout.hp_nid)
  10349. spec->multiout.hp_nid = nid_v;
  10350. else
  10351. spec->multiout.extra_out_nid[0] = nid_v;
  10352. /* control HP volume/switch on the output mixer amp */
  10353. nid_v = alc861vd_idx_to_mixer_vol(
  10354. alc880_fixed_pin_idx(pin));
  10355. nid_s = alc861vd_idx_to_mixer_switch(
  10356. alc880_fixed_pin_idx(pin));
  10357. sprintf(name, "%s Playback Volume", pfx);
  10358. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10359. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10360. if (err < 0)
  10361. return err;
  10362. sprintf(name, "%s Playback Switch", pfx);
  10363. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10364. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10365. if (err < 0)
  10366. return err;
  10367. } else if (alc880_is_multi_pin(pin)) {
  10368. /* set manual connection */
  10369. /* we have only a switch on HP-out PIN */
  10370. sprintf(name, "%s Playback Switch", pfx);
  10371. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10372. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10373. if (err < 0)
  10374. return err;
  10375. }
  10376. return 0;
  10377. }
  10378. /* parse the BIOS configuration and set up the alc_spec
  10379. * return 1 if successful, 0 if the proper config is not found,
  10380. * or a negative error code
  10381. * Based on ALC880 version - had to change it to override
  10382. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10383. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10384. {
  10385. struct alc_spec *spec = codec->spec;
  10386. int err;
  10387. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10388. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10389. alc861vd_ignore);
  10390. if (err < 0)
  10391. return err;
  10392. if (!spec->autocfg.line_outs)
  10393. return 0; /* can't find valid BIOS pin config */
  10394. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10395. if (err < 0)
  10396. return err;
  10397. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10398. if (err < 0)
  10399. return err;
  10400. err = alc861vd_auto_create_extra_out(spec,
  10401. spec->autocfg.speaker_pins[0],
  10402. "Speaker");
  10403. if (err < 0)
  10404. return err;
  10405. err = alc861vd_auto_create_extra_out(spec,
  10406. spec->autocfg.hp_pins[0],
  10407. "Headphone");
  10408. if (err < 0)
  10409. return err;
  10410. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10411. if (err < 0)
  10412. return err;
  10413. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10414. if (spec->autocfg.dig_out_pin)
  10415. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10416. if (spec->kctl_alloc)
  10417. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10418. spec->init_verbs[spec->num_init_verbs++]
  10419. = alc861vd_volume_init_verbs;
  10420. spec->num_mux_defs = 1;
  10421. spec->input_mux = &spec->private_imux;
  10422. err = alc_auto_add_mic_boost(codec);
  10423. if (err < 0)
  10424. return err;
  10425. return 1;
  10426. }
  10427. /* additional initialization for auto-configuration model */
  10428. static void alc861vd_auto_init(struct hda_codec *codec)
  10429. {
  10430. alc861vd_auto_init_multi_out(codec);
  10431. alc861vd_auto_init_hp_out(codec);
  10432. alc861vd_auto_init_analog_input(codec);
  10433. }
  10434. static int patch_alc861vd(struct hda_codec *codec)
  10435. {
  10436. struct alc_spec *spec;
  10437. int err, board_config;
  10438. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10439. if (spec == NULL)
  10440. return -ENOMEM;
  10441. codec->spec = spec;
  10442. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10443. alc861vd_models,
  10444. alc861vd_cfg_tbl);
  10445. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10446. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10447. "ALC861VD, trying auto-probe from BIOS...\n");
  10448. board_config = ALC861VD_AUTO;
  10449. }
  10450. if (board_config == ALC861VD_AUTO) {
  10451. /* automatic parse from the BIOS config */
  10452. err = alc861vd_parse_auto_config(codec);
  10453. if (err < 0) {
  10454. alc_free(codec);
  10455. return err;
  10456. } else if (!err) {
  10457. printk(KERN_INFO
  10458. "hda_codec: Cannot set up configuration "
  10459. "from BIOS. Using base mode...\n");
  10460. board_config = ALC861VD_3ST;
  10461. }
  10462. }
  10463. if (board_config != ALC861VD_AUTO)
  10464. setup_preset(spec, &alc861vd_presets[board_config]);
  10465. spec->stream_name_analog = "ALC861VD Analog";
  10466. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10467. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10468. spec->stream_name_digital = "ALC861VD Digital";
  10469. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10470. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10471. spec->adc_nids = alc861vd_adc_nids;
  10472. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10473. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10474. spec->num_mixers++;
  10475. codec->patch_ops = alc_patch_ops;
  10476. if (board_config == ALC861VD_AUTO)
  10477. spec->init_hook = alc861vd_auto_init;
  10478. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10479. if (!spec->loopback.amplist)
  10480. spec->loopback.amplist = alc861vd_loopbacks;
  10481. #endif
  10482. return 0;
  10483. }
  10484. /*
  10485. * ALC662 support
  10486. *
  10487. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10488. * configuration. Each pin widget can choose any input DACs and a mixer.
  10489. * Each ADC is connected from a mixer of all inputs. This makes possible
  10490. * 6-channel independent captures.
  10491. *
  10492. * In addition, an independent DAC for the multi-playback (not used in this
  10493. * driver yet).
  10494. */
  10495. #define ALC662_DIGOUT_NID 0x06
  10496. #define ALC662_DIGIN_NID 0x0a
  10497. static hda_nid_t alc662_dac_nids[4] = {
  10498. /* front, rear, clfe, rear_surr */
  10499. 0x02, 0x03, 0x04
  10500. };
  10501. static hda_nid_t alc662_adc_nids[1] = {
  10502. /* ADC1-2 */
  10503. 0x09,
  10504. };
  10505. /* input MUX */
  10506. /* FIXME: should be a matrix-type input source selection */
  10507. static struct hda_input_mux alc662_capture_source = {
  10508. .num_items = 4,
  10509. .items = {
  10510. { "Mic", 0x0 },
  10511. { "Front Mic", 0x1 },
  10512. { "Line", 0x2 },
  10513. { "CD", 0x4 },
  10514. },
  10515. };
  10516. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10517. .num_items = 2,
  10518. .items = {
  10519. { "Mic", 0x1 },
  10520. { "Line", 0x2 },
  10521. },
  10522. };
  10523. static struct hda_input_mux alc662_eeepc_capture_source = {
  10524. .num_items = 2,
  10525. .items = {
  10526. { "i-Mic", 0x1 },
  10527. { "e-Mic", 0x0 },
  10528. },
  10529. };
  10530. #define alc662_mux_enum_info alc_mux_enum_info
  10531. #define alc662_mux_enum_get alc_mux_enum_get
  10532. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10533. struct snd_ctl_elem_value *ucontrol)
  10534. {
  10535. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10536. struct alc_spec *spec = codec->spec;
  10537. const struct hda_input_mux *imux = spec->input_mux;
  10538. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10539. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10540. hda_nid_t nid = capture_mixers[adc_idx];
  10541. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10542. unsigned int i, idx;
  10543. idx = ucontrol->value.enumerated.item[0];
  10544. if (idx >= imux->num_items)
  10545. idx = imux->num_items - 1;
  10546. if (*cur_val == idx)
  10547. return 0;
  10548. for (i = 0; i < imux->num_items; i++) {
  10549. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10550. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10551. imux->items[i].index,
  10552. HDA_AMP_MUTE, v);
  10553. }
  10554. *cur_val = idx;
  10555. return 1;
  10556. }
  10557. /*
  10558. * 2ch mode
  10559. */
  10560. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10561. { 2, NULL }
  10562. };
  10563. /*
  10564. * 2ch mode
  10565. */
  10566. static struct hda_verb alc662_3ST_ch2_init[] = {
  10567. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10568. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10569. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10570. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10571. { } /* end */
  10572. };
  10573. /*
  10574. * 6ch mode
  10575. */
  10576. static struct hda_verb alc662_3ST_ch6_init[] = {
  10577. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10578. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10579. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10580. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10581. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10582. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10583. { } /* end */
  10584. };
  10585. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10586. { 2, alc662_3ST_ch2_init },
  10587. { 6, alc662_3ST_ch6_init },
  10588. };
  10589. /*
  10590. * 2ch mode
  10591. */
  10592. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10593. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10594. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10595. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10596. { } /* end */
  10597. };
  10598. /*
  10599. * 6ch mode
  10600. */
  10601. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10602. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10603. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10604. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10605. { } /* end */
  10606. };
  10607. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10608. { 2, alc662_sixstack_ch6_init },
  10609. { 6, alc662_sixstack_ch8_init },
  10610. };
  10611. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10612. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10613. */
  10614. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10615. /* output mixer control */
  10616. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10617. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10618. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10619. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10620. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10621. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10622. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10623. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10624. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10625. /*Input mixer control */
  10626. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10627. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10628. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10629. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10630. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10631. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10632. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10633. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10634. /* Capture mixer control */
  10635. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10636. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10637. {
  10638. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10639. .name = "Capture Source",
  10640. .count = 1,
  10641. .info = alc_mux_enum_info,
  10642. .get = alc_mux_enum_get,
  10643. .put = alc_mux_enum_put,
  10644. },
  10645. { } /* end */
  10646. };
  10647. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10648. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10649. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10650. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10651. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10652. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10655. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10656. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10657. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10658. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10659. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10660. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10661. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10662. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10663. {
  10664. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10665. /* .name = "Capture Source", */
  10666. .name = "Input Source",
  10667. .count = 1,
  10668. .info = alc662_mux_enum_info,
  10669. .get = alc662_mux_enum_get,
  10670. .put = alc662_mux_enum_put,
  10671. },
  10672. { } /* end */
  10673. };
  10674. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10675. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10676. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10677. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10678. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10679. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10680. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10681. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10682. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10683. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10684. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10685. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10686. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10687. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10688. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10689. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10690. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10691. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10692. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10693. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10694. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10695. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10696. {
  10697. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10698. /* .name = "Capture Source", */
  10699. .name = "Input Source",
  10700. .count = 1,
  10701. .info = alc662_mux_enum_info,
  10702. .get = alc662_mux_enum_get,
  10703. .put = alc662_mux_enum_put,
  10704. },
  10705. { } /* end */
  10706. };
  10707. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10708. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10709. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10710. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10711. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10712. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10713. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10714. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10715. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10716. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10717. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10718. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10719. {
  10720. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10721. /* .name = "Capture Source", */
  10722. .name = "Input Source",
  10723. .count = 1,
  10724. .info = alc662_mux_enum_info,
  10725. .get = alc662_mux_enum_get,
  10726. .put = alc662_mux_enum_put,
  10727. },
  10728. { } /* end */
  10729. };
  10730. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  10731. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10732. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10733. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10734. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  10735. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10736. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10737. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  10738. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10739. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10740. { } /* end */
  10741. };
  10742. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10743. {
  10744. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10745. .name = "Channel Mode",
  10746. .info = alc_ch_mode_info,
  10747. .get = alc_ch_mode_get,
  10748. .put = alc_ch_mode_put,
  10749. },
  10750. { } /* end */
  10751. };
  10752. static struct hda_verb alc662_init_verbs[] = {
  10753. /* ADC: mute amp left and right */
  10754. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10755. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10756. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10762. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10763. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10764. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10765. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10766. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10767. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10768. /* Front Pin: output 0 (0x0c) */
  10769. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10770. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10771. /* Rear Pin: output 1 (0x0d) */
  10772. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10773. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10774. /* CLFE Pin: output 2 (0x0e) */
  10775. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10776. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10777. /* Mic (rear) pin: input vref at 80% */
  10778. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10779. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10780. /* Front Mic pin: input vref at 80% */
  10781. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10782. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10783. /* Line In pin: input */
  10784. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10785. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10786. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10787. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10788. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10789. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10790. /* CD pin widget for input */
  10791. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10792. /* FIXME: use matrix-type input source selection */
  10793. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10794. /* Input mixer */
  10795. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10796. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10797. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10798. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10799. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10800. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10801. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10802. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10803. { }
  10804. };
  10805. static struct hda_verb alc662_sue_init_verbs[] = {
  10806. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10807. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10808. {}
  10809. };
  10810. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  10811. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10812. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10813. {}
  10814. };
  10815. /*
  10816. * generic initialization of ADC, input mixers and output mixers
  10817. */
  10818. static struct hda_verb alc662_auto_init_verbs[] = {
  10819. /*
  10820. * Unmute ADC and set the default input to mic-in
  10821. */
  10822. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10823. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10824. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10825. * mixer widget
  10826. * Note: PASD motherboards uses the Line In 2 as the input for front
  10827. * panel mic (mic 2)
  10828. */
  10829. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10830. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10831. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10832. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10833. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10834. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10835. /*
  10836. * Set up output mixers (0x0c - 0x0f)
  10837. */
  10838. /* set vol=0 to output mixers */
  10839. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10840. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10841. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10842. /* set up input amps for analog loopback */
  10843. /* Amp Indices: DAC = 0, mixer = 1 */
  10844. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10845. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10846. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10847. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10848. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10849. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10850. /* FIXME: use matrix-type input source selection */
  10851. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10852. /* Input mixer */
  10853. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10854. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10855. { }
  10856. };
  10857. /* capture mixer elements */
  10858. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10859. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10860. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10861. {
  10862. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10863. /* The multiple "Capture Source" controls confuse alsamixer
  10864. * So call somewhat different..
  10865. * FIXME: the controls appear in the "playback" view!
  10866. */
  10867. /* .name = "Capture Source", */
  10868. .name = "Input Source",
  10869. .count = 1,
  10870. .info = alc882_mux_enum_info,
  10871. .get = alc882_mux_enum_get,
  10872. .put = alc882_mux_enum_put,
  10873. },
  10874. { } /* end */
  10875. };
  10876. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10877. {
  10878. unsigned int present;
  10879. unsigned char bits;
  10880. present = snd_hda_codec_read(codec, 0x14, 0,
  10881. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10882. bits = present ? HDA_AMP_MUTE : 0;
  10883. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10884. HDA_AMP_MUTE, bits);
  10885. }
  10886. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10887. {
  10888. unsigned int present;
  10889. unsigned char bits;
  10890. present = snd_hda_codec_read(codec, 0x1b, 0,
  10891. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10892. bits = present ? HDA_AMP_MUTE : 0;
  10893. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10894. HDA_AMP_MUTE, bits);
  10895. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10896. HDA_AMP_MUTE, bits);
  10897. }
  10898. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10899. unsigned int res)
  10900. {
  10901. if ((res >> 26) == ALC880_HP_EVENT)
  10902. alc662_lenovo_101e_all_automute(codec);
  10903. if ((res >> 26) == ALC880_FRONT_EVENT)
  10904. alc662_lenovo_101e_ispeaker_automute(codec);
  10905. }
  10906. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  10907. {
  10908. unsigned int present;
  10909. present = snd_hda_codec_read(codec, 0x18, 0,
  10910. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10911. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10912. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10913. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10914. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10915. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10916. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10917. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10918. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10919. }
  10920. /* unsolicited event for HP jack sensing */
  10921. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  10922. unsigned int res)
  10923. {
  10924. if ((res >> 26) == ALC880_HP_EVENT)
  10925. alc262_hippo1_automute( codec );
  10926. if ((res >> 26) == ALC880_MIC_EVENT)
  10927. alc662_eeepc_mic_automute(codec);
  10928. }
  10929. static void alc662_eeepc_inithook(struct hda_codec *codec)
  10930. {
  10931. alc262_hippo1_automute( codec );
  10932. alc662_eeepc_mic_automute(codec);
  10933. }
  10934. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10935. #define alc662_loopbacks alc880_loopbacks
  10936. #endif
  10937. /* pcm configuration: identiacal with ALC880 */
  10938. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10939. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10940. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10941. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10942. /*
  10943. * configuration and preset
  10944. */
  10945. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10946. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10947. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10948. [ALC662_3ST_6ch] = "3stack-6ch",
  10949. [ALC662_5ST_DIG] = "6stack-dig",
  10950. [ALC662_LENOVO_101E] = "lenovo-101e",
  10951. [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
  10952. [ALC662_AUTO] = "auto",
  10953. };
  10954. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10955. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10956. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  10957. {}
  10958. };
  10959. static struct alc_config_preset alc662_presets[] = {
  10960. [ALC662_3ST_2ch_DIG] = {
  10961. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  10962. .init_verbs = { alc662_init_verbs },
  10963. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10964. .dac_nids = alc662_dac_nids,
  10965. .dig_out_nid = ALC662_DIGOUT_NID,
  10966. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10967. .adc_nids = alc662_adc_nids,
  10968. .dig_in_nid = ALC662_DIGIN_NID,
  10969. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10970. .channel_mode = alc662_3ST_2ch_modes,
  10971. .input_mux = &alc662_capture_source,
  10972. },
  10973. [ALC662_3ST_6ch_DIG] = {
  10974. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10975. alc662_capture_mixer },
  10976. .init_verbs = { alc662_init_verbs },
  10977. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10978. .dac_nids = alc662_dac_nids,
  10979. .dig_out_nid = ALC662_DIGOUT_NID,
  10980. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10981. .adc_nids = alc662_adc_nids,
  10982. .dig_in_nid = ALC662_DIGIN_NID,
  10983. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10984. .channel_mode = alc662_3ST_6ch_modes,
  10985. .need_dac_fix = 1,
  10986. .input_mux = &alc662_capture_source,
  10987. },
  10988. [ALC662_3ST_6ch] = {
  10989. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10990. alc662_capture_mixer },
  10991. .init_verbs = { alc662_init_verbs },
  10992. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10993. .dac_nids = alc662_dac_nids,
  10994. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10995. .adc_nids = alc662_adc_nids,
  10996. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10997. .channel_mode = alc662_3ST_6ch_modes,
  10998. .need_dac_fix = 1,
  10999. .input_mux = &alc662_capture_source,
  11000. },
  11001. [ALC662_5ST_DIG] = {
  11002. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  11003. alc662_capture_mixer },
  11004. .init_verbs = { alc662_init_verbs },
  11005. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11006. .dac_nids = alc662_dac_nids,
  11007. .dig_out_nid = ALC662_DIGOUT_NID,
  11008. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11009. .adc_nids = alc662_adc_nids,
  11010. .dig_in_nid = ALC662_DIGIN_NID,
  11011. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  11012. .channel_mode = alc662_5stack_modes,
  11013. .input_mux = &alc662_capture_source,
  11014. },
  11015. [ALC662_LENOVO_101E] = {
  11016. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  11017. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  11018. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11019. .dac_nids = alc662_dac_nids,
  11020. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11021. .adc_nids = alc662_adc_nids,
  11022. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11023. .channel_mode = alc662_3ST_2ch_modes,
  11024. .input_mux = &alc662_lenovo_101e_capture_source,
  11025. .unsol_event = alc662_lenovo_101e_unsol_event,
  11026. .init_hook = alc662_lenovo_101e_all_automute,
  11027. },
  11028. [ALC662_ASUS_EEEPC_P701] = {
  11029. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  11030. .init_verbs = { alc662_init_verbs,
  11031. alc662_eeepc_sue_init_verbs },
  11032. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11033. .dac_nids = alc662_dac_nids,
  11034. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  11035. .adc_nids = alc662_adc_nids,
  11036. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11037. .channel_mode = alc662_3ST_2ch_modes,
  11038. .input_mux = &alc662_eeepc_capture_source,
  11039. .unsol_event = alc662_eeepc_unsol_event,
  11040. .init_hook = alc662_eeepc_inithook,
  11041. },
  11042. };
  11043. /*
  11044. * BIOS auto configuration
  11045. */
  11046. /* add playback controls from the parsed DAC table */
  11047. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  11048. const struct auto_pin_cfg *cfg)
  11049. {
  11050. char name[32];
  11051. static const char *chname[4] = {
  11052. "Front", "Surround", NULL /*CLFE*/, "Side"
  11053. };
  11054. hda_nid_t nid;
  11055. int i, err;
  11056. for (i = 0; i < cfg->line_outs; i++) {
  11057. if (!spec->multiout.dac_nids[i])
  11058. continue;
  11059. nid = alc880_idx_to_dac(i);
  11060. if (i == 2) {
  11061. /* Center/LFE */
  11062. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11063. "Center Playback Volume",
  11064. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  11065. HDA_OUTPUT));
  11066. if (err < 0)
  11067. return err;
  11068. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11069. "LFE Playback Volume",
  11070. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  11071. HDA_OUTPUT));
  11072. if (err < 0)
  11073. return err;
  11074. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11075. "Center Playback Switch",
  11076. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11077. HDA_INPUT));
  11078. if (err < 0)
  11079. return err;
  11080. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11081. "LFE Playback Switch",
  11082. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11083. HDA_INPUT));
  11084. if (err < 0)
  11085. return err;
  11086. } else {
  11087. sprintf(name, "%s Playback Volume", chname[i]);
  11088. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11089. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11090. HDA_OUTPUT));
  11091. if (err < 0)
  11092. return err;
  11093. sprintf(name, "%s Playback Switch", chname[i]);
  11094. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11095. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11096. HDA_INPUT));
  11097. if (err < 0)
  11098. return err;
  11099. }
  11100. }
  11101. return 0;
  11102. }
  11103. /* add playback controls for speaker and HP outputs */
  11104. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11105. const char *pfx)
  11106. {
  11107. hda_nid_t nid;
  11108. int err;
  11109. char name[32];
  11110. if (!pin)
  11111. return 0;
  11112. if (alc880_is_fixed_pin(pin)) {
  11113. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11114. /* printk("DAC nid=%x\n",nid); */
  11115. /* specify the DAC as the extra output */
  11116. if (!spec->multiout.hp_nid)
  11117. spec->multiout.hp_nid = nid;
  11118. else
  11119. spec->multiout.extra_out_nid[0] = nid;
  11120. /* control HP volume/switch on the output mixer amp */
  11121. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11122. sprintf(name, "%s Playback Volume", pfx);
  11123. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11124. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11125. if (err < 0)
  11126. return err;
  11127. sprintf(name, "%s Playback Switch", pfx);
  11128. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11129. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11130. if (err < 0)
  11131. return err;
  11132. } else if (alc880_is_multi_pin(pin)) {
  11133. /* set manual connection */
  11134. /* we have only a switch on HP-out PIN */
  11135. sprintf(name, "%s Playback Switch", pfx);
  11136. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11137. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11138. if (err < 0)
  11139. return err;
  11140. }
  11141. return 0;
  11142. }
  11143. /* create playback/capture controls for input pins */
  11144. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11145. const struct auto_pin_cfg *cfg)
  11146. {
  11147. struct hda_input_mux *imux = &spec->private_imux;
  11148. int i, err, idx;
  11149. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11150. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11151. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11152. err = new_analog_input(spec, cfg->input_pins[i],
  11153. auto_pin_cfg_labels[i],
  11154. idx, 0x0b);
  11155. if (err < 0)
  11156. return err;
  11157. imux->items[imux->num_items].label =
  11158. auto_pin_cfg_labels[i];
  11159. imux->items[imux->num_items].index =
  11160. alc880_input_pin_idx(cfg->input_pins[i]);
  11161. imux->num_items++;
  11162. }
  11163. }
  11164. return 0;
  11165. }
  11166. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11167. hda_nid_t nid, int pin_type,
  11168. int dac_idx)
  11169. {
  11170. /* set as output */
  11171. snd_hda_codec_write(codec, nid, 0,
  11172. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11173. snd_hda_codec_write(codec, nid, 0,
  11174. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11175. /* need the manual connection? */
  11176. if (alc880_is_multi_pin(nid)) {
  11177. struct alc_spec *spec = codec->spec;
  11178. int idx = alc880_multi_pin_idx(nid);
  11179. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11180. AC_VERB_SET_CONNECT_SEL,
  11181. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11182. }
  11183. }
  11184. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11185. {
  11186. struct alc_spec *spec = codec->spec;
  11187. int i;
  11188. for (i = 0; i <= HDA_SIDE; i++) {
  11189. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11190. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11191. if (nid)
  11192. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11193. i);
  11194. }
  11195. }
  11196. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11197. {
  11198. struct alc_spec *spec = codec->spec;
  11199. hda_nid_t pin;
  11200. pin = spec->autocfg.hp_pins[0];
  11201. if (pin) /* connect to front */
  11202. /* use dac 0 */
  11203. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11204. }
  11205. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11206. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11207. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11208. {
  11209. struct alc_spec *spec = codec->spec;
  11210. int i;
  11211. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11212. hda_nid_t nid = spec->autocfg.input_pins[i];
  11213. if (alc662_is_input_pin(nid)) {
  11214. snd_hda_codec_write(codec, nid, 0,
  11215. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11216. (i <= AUTO_PIN_FRONT_MIC ?
  11217. PIN_VREF80 : PIN_IN));
  11218. if (nid != ALC662_PIN_CD_NID)
  11219. snd_hda_codec_write(codec, nid, 0,
  11220. AC_VERB_SET_AMP_GAIN_MUTE,
  11221. AMP_OUT_MUTE);
  11222. }
  11223. }
  11224. }
  11225. static int alc662_parse_auto_config(struct hda_codec *codec)
  11226. {
  11227. struct alc_spec *spec = codec->spec;
  11228. int err;
  11229. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11230. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11231. alc662_ignore);
  11232. if (err < 0)
  11233. return err;
  11234. if (!spec->autocfg.line_outs)
  11235. return 0; /* can't find valid BIOS pin config */
  11236. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11237. if (err < 0)
  11238. return err;
  11239. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11240. if (err < 0)
  11241. return err;
  11242. err = alc662_auto_create_extra_out(spec,
  11243. spec->autocfg.speaker_pins[0],
  11244. "Speaker");
  11245. if (err < 0)
  11246. return err;
  11247. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11248. "Headphone");
  11249. if (err < 0)
  11250. return err;
  11251. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11252. if (err < 0)
  11253. return err;
  11254. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11255. if (spec->autocfg.dig_out_pin)
  11256. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11257. if (spec->kctl_alloc)
  11258. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11259. spec->num_mux_defs = 1;
  11260. spec->input_mux = &spec->private_imux;
  11261. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11262. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11263. spec->num_mixers++;
  11264. return 1;
  11265. }
  11266. /* additional initialization for auto-configuration model */
  11267. static void alc662_auto_init(struct hda_codec *codec)
  11268. {
  11269. alc662_auto_init_multi_out(codec);
  11270. alc662_auto_init_hp_out(codec);
  11271. alc662_auto_init_analog_input(codec);
  11272. }
  11273. static int patch_alc662(struct hda_codec *codec)
  11274. {
  11275. struct alc_spec *spec;
  11276. int err, board_config;
  11277. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11278. if (!spec)
  11279. return -ENOMEM;
  11280. codec->spec = spec;
  11281. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11282. alc662_models,
  11283. alc662_cfg_tbl);
  11284. if (board_config < 0) {
  11285. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11286. "trying auto-probe from BIOS...\n");
  11287. board_config = ALC662_AUTO;
  11288. }
  11289. if (board_config == ALC662_AUTO) {
  11290. /* automatic parse from the BIOS config */
  11291. err = alc662_parse_auto_config(codec);
  11292. if (err < 0) {
  11293. alc_free(codec);
  11294. return err;
  11295. } else if (!err) {
  11296. printk(KERN_INFO
  11297. "hda_codec: Cannot set up configuration "
  11298. "from BIOS. Using base mode...\n");
  11299. board_config = ALC662_3ST_2ch_DIG;
  11300. }
  11301. }
  11302. if (board_config != ALC662_AUTO)
  11303. setup_preset(spec, &alc662_presets[board_config]);
  11304. spec->stream_name_analog = "ALC662 Analog";
  11305. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11306. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11307. spec->stream_name_digital = "ALC662 Digital";
  11308. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11309. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11310. if (!spec->adc_nids && spec->input_mux) {
  11311. spec->adc_nids = alc662_adc_nids;
  11312. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11313. }
  11314. codec->patch_ops = alc_patch_ops;
  11315. if (board_config == ALC662_AUTO)
  11316. spec->init_hook = alc662_auto_init;
  11317. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11318. if (!spec->loopback.amplist)
  11319. spec->loopback.amplist = alc662_loopbacks;
  11320. #endif
  11321. return 0;
  11322. }
  11323. /*
  11324. * patch entries
  11325. */
  11326. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11327. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11328. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11329. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11330. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11331. .patch = patch_alc861 },
  11332. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11333. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11334. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11335. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11336. .patch = patch_alc883 },
  11337. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11338. .patch = patch_alc662 },
  11339. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11340. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11341. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11342. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11343. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11344. {} /* terminator */
  11345. };