patch_realtek.c 233 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860
  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. /* ALC880 board config type */
  34. enum {
  35. ALC880_3ST,
  36. ALC880_3ST_DIG,
  37. ALC880_5ST,
  38. ALC880_5ST_DIG,
  39. ALC880_W810,
  40. ALC880_Z71V,
  41. ALC880_6ST,
  42. ALC880_6ST_DIG,
  43. ALC880_F1734,
  44. ALC880_ASUS,
  45. ALC880_ASUS_DIG,
  46. ALC880_ASUS_W1V,
  47. ALC880_ASUS_DIG2,
  48. ALC880_UNIWILL_DIG,
  49. ALC880_CLEVO,
  50. ALC880_TCL_S700,
  51. ALC880_LG,
  52. ALC880_LG_LW,
  53. #ifdef CONFIG_SND_DEBUG
  54. ALC880_TEST,
  55. #endif
  56. ALC880_AUTO,
  57. ALC880_MODEL_LAST /* last tag */
  58. };
  59. /* ALC260 models */
  60. enum {
  61. ALC260_BASIC,
  62. ALC260_HP,
  63. ALC260_HP_3013,
  64. ALC260_FUJITSU_S702X,
  65. ALC260_ACER,
  66. #ifdef CONFIG_SND_DEBUG
  67. ALC260_TEST,
  68. #endif
  69. ALC260_AUTO,
  70. ALC260_MODEL_LAST /* last tag */
  71. };
  72. /* ALC262 models */
  73. enum {
  74. ALC262_BASIC,
  75. ALC262_FUJITSU,
  76. ALC262_HP_BPC,
  77. ALC262_BENQ_ED8,
  78. ALC262_AUTO,
  79. ALC262_MODEL_LAST /* last tag */
  80. };
  81. /* ALC861 models */
  82. enum {
  83. ALC861_3ST,
  84. ALC660_3ST,
  85. ALC861_3ST_DIG,
  86. ALC861_6ST_DIG,
  87. ALC861_UNIWILL_M31,
  88. ALC861_AUTO,
  89. ALC861_MODEL_LAST,
  90. };
  91. /* ALC882 models */
  92. enum {
  93. ALC882_3ST_DIG,
  94. ALC882_6ST_DIG,
  95. ALC882_ARIMA,
  96. ALC882_AUTO,
  97. ALC882_MODEL_LAST,
  98. };
  99. /* ALC883 models */
  100. enum {
  101. ALC883_3ST_2ch_DIG,
  102. ALC883_3ST_6ch_DIG,
  103. ALC883_3ST_6ch,
  104. ALC883_6ST_DIG,
  105. ALC888_DEMO_BOARD,
  106. ALC883_ACER,
  107. ALC883_AUTO,
  108. ALC883_MODEL_LAST,
  109. };
  110. /* for GPIO Poll */
  111. #define GPIO_MASK 0x03
  112. struct alc_spec {
  113. /* codec parameterization */
  114. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  115. unsigned int num_mixers;
  116. const struct hda_verb *init_verbs[5]; /* initialization verbs
  117. * don't forget NULL
  118. * termination!
  119. */
  120. unsigned int num_init_verbs;
  121. char *stream_name_analog; /* analog PCM stream */
  122. struct hda_pcm_stream *stream_analog_playback;
  123. struct hda_pcm_stream *stream_analog_capture;
  124. char *stream_name_digital; /* digital PCM stream */
  125. struct hda_pcm_stream *stream_digital_playback;
  126. struct hda_pcm_stream *stream_digital_capture;
  127. /* playback */
  128. struct hda_multi_out multiout; /* playback set-up
  129. * max_channels, dacs must be set
  130. * dig_out_nid and hp_nid are optional
  131. */
  132. /* capture */
  133. unsigned int num_adc_nids;
  134. hda_nid_t *adc_nids;
  135. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  136. /* capture source */
  137. unsigned int num_mux_defs;
  138. const struct hda_input_mux *input_mux;
  139. unsigned int cur_mux[3];
  140. /* channel model */
  141. const struct hda_channel_mode *channel_mode;
  142. int num_channel_mode;
  143. int need_dac_fix;
  144. /* PCM information */
  145. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  146. /* dynamic controls, init_verbs and input_mux */
  147. struct auto_pin_cfg autocfg;
  148. unsigned int num_kctl_alloc, num_kctl_used;
  149. struct snd_kcontrol_new *kctl_alloc;
  150. struct hda_input_mux private_imux;
  151. hda_nid_t private_dac_nids[5];
  152. /* hooks */
  153. void (*init_hook)(struct hda_codec *codec);
  154. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  155. /* for pin sensing */
  156. unsigned int sense_updated: 1;
  157. unsigned int jack_present: 1;
  158. };
  159. /*
  160. * configuration template - to be copied to the spec instance
  161. */
  162. struct alc_config_preset {
  163. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  164. * with spec
  165. */
  166. const struct hda_verb *init_verbs[5];
  167. unsigned int num_dacs;
  168. hda_nid_t *dac_nids;
  169. hda_nid_t dig_out_nid; /* optional */
  170. hda_nid_t hp_nid; /* optional */
  171. unsigned int num_adc_nids;
  172. hda_nid_t *adc_nids;
  173. hda_nid_t dig_in_nid;
  174. unsigned int num_channel_mode;
  175. const struct hda_channel_mode *channel_mode;
  176. int need_dac_fix;
  177. unsigned int num_mux_defs;
  178. const struct hda_input_mux *input_mux;
  179. void (*unsol_event)(struct hda_codec *, unsigned int);
  180. void (*init_hook)(struct hda_codec *);
  181. };
  182. /*
  183. * input MUX handling
  184. */
  185. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  186. struct snd_ctl_elem_info *uinfo)
  187. {
  188. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  189. struct alc_spec *spec = codec->spec;
  190. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  191. if (mux_idx >= spec->num_mux_defs)
  192. mux_idx = 0;
  193. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  194. }
  195. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  196. struct snd_ctl_elem_value *ucontrol)
  197. {
  198. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  199. struct alc_spec *spec = codec->spec;
  200. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  201. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  202. return 0;
  203. }
  204. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  205. struct snd_ctl_elem_value *ucontrol)
  206. {
  207. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  208. struct alc_spec *spec = codec->spec;
  209. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  210. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  211. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  212. spec->adc_nids[adc_idx],
  213. &spec->cur_mux[adc_idx]);
  214. }
  215. /*
  216. * channel mode setting
  217. */
  218. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  219. struct snd_ctl_elem_info *uinfo)
  220. {
  221. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  222. struct alc_spec *spec = codec->spec;
  223. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  224. spec->num_channel_mode);
  225. }
  226. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  227. struct snd_ctl_elem_value *ucontrol)
  228. {
  229. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  230. struct alc_spec *spec = codec->spec;
  231. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  232. spec->num_channel_mode,
  233. spec->multiout.max_channels);
  234. }
  235. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  236. struct snd_ctl_elem_value *ucontrol)
  237. {
  238. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  239. struct alc_spec *spec = codec->spec;
  240. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  241. spec->num_channel_mode,
  242. &spec->multiout.max_channels);
  243. if (! err && spec->need_dac_fix)
  244. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  245. return err;
  246. }
  247. /*
  248. * Control the mode of pin widget settings via the mixer. "pc" is used
  249. * instead of "%" to avoid consequences of accidently treating the % as
  250. * being part of a format specifier. Maximum allowed length of a value is
  251. * 63 characters plus NULL terminator.
  252. *
  253. * Note: some retasking pin complexes seem to ignore requests for input
  254. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  255. * are requested. Therefore order this list so that this behaviour will not
  256. * cause problems when mixer clients move through the enum sequentially.
  257. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  258. * March 2006.
  259. */
  260. static char *alc_pin_mode_names[] = {
  261. "Mic 50pc bias", "Mic 80pc bias",
  262. "Line in", "Line out", "Headphone out",
  263. };
  264. static unsigned char alc_pin_mode_values[] = {
  265. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  266. };
  267. /* The control can present all 5 options, or it can limit the options based
  268. * in the pin being assumed to be exclusively an input or an output pin. In
  269. * addition, "input" pins may or may not process the mic bias option
  270. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  271. * accept requests for bias as of chip versions up to March 2006) and/or
  272. * wiring in the computer.
  273. */
  274. #define ALC_PIN_DIR_IN 0x00
  275. #define ALC_PIN_DIR_OUT 0x01
  276. #define ALC_PIN_DIR_INOUT 0x02
  277. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  278. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  279. /* Info about the pin modes supported by the different pin direction modes.
  280. * For each direction the minimum and maximum values are given.
  281. */
  282. static signed char alc_pin_mode_dir_info[5][2] = {
  283. { 0, 2 }, /* ALC_PIN_DIR_IN */
  284. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  285. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  286. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  287. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  288. };
  289. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  290. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  291. #define alc_pin_mode_n_items(_dir) \
  292. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  293. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  294. struct snd_ctl_elem_info *uinfo)
  295. {
  296. unsigned int item_num = uinfo->value.enumerated.item;
  297. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  298. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  299. uinfo->count = 1;
  300. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  301. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  302. item_num = alc_pin_mode_min(dir);
  303. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  304. return 0;
  305. }
  306. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  307. struct snd_ctl_elem_value *ucontrol)
  308. {
  309. unsigned int i;
  310. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  311. hda_nid_t nid = kcontrol->private_value & 0xffff;
  312. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  313. long *valp = ucontrol->value.integer.value;
  314. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  315. AC_VERB_GET_PIN_WIDGET_CONTROL,
  316. 0x00);
  317. /* Find enumerated value for current pinctl setting */
  318. i = alc_pin_mode_min(dir);
  319. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  320. i++;
  321. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  322. return 0;
  323. }
  324. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  325. struct snd_ctl_elem_value *ucontrol)
  326. {
  327. signed int change;
  328. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  329. hda_nid_t nid = kcontrol->private_value & 0xffff;
  330. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  331. long val = *ucontrol->value.integer.value;
  332. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  333. AC_VERB_GET_PIN_WIDGET_CONTROL,
  334. 0x00);
  335. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  336. val = alc_pin_mode_min(dir);
  337. change = pinctl != alc_pin_mode_values[val];
  338. if (change) {
  339. /* Set pin mode to that requested */
  340. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  341. alc_pin_mode_values[val]);
  342. /* Also enable the retasking pin's input/output as required
  343. * for the requested pin mode. Enum values of 2 or less are
  344. * input modes.
  345. *
  346. * Dynamically switching the input/output buffers probably
  347. * reduces noise slightly (particularly on input) so we'll
  348. * do it. However, having both input and output buffers
  349. * enabled simultaneously doesn't seem to be problematic if
  350. * this turns out to be necessary in the future.
  351. */
  352. if (val <= 2) {
  353. snd_hda_codec_write(codec, nid, 0,
  354. AC_VERB_SET_AMP_GAIN_MUTE,
  355. AMP_OUT_MUTE);
  356. snd_hda_codec_write(codec, nid, 0,
  357. AC_VERB_SET_AMP_GAIN_MUTE,
  358. AMP_IN_UNMUTE(0));
  359. } else {
  360. snd_hda_codec_write(codec, nid, 0,
  361. AC_VERB_SET_AMP_GAIN_MUTE,
  362. AMP_IN_MUTE(0));
  363. snd_hda_codec_write(codec, nid, 0,
  364. AC_VERB_SET_AMP_GAIN_MUTE,
  365. AMP_OUT_UNMUTE);
  366. }
  367. }
  368. return change;
  369. }
  370. #define ALC_PIN_MODE(xname, nid, dir) \
  371. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  372. .info = alc_pin_mode_info, \
  373. .get = alc_pin_mode_get, \
  374. .put = alc_pin_mode_put, \
  375. .private_value = nid | (dir<<16) }
  376. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  377. * together using a mask with more than one bit set. This control is
  378. * currently used only by the ALC260 test model. At this stage they are not
  379. * needed for any "production" models.
  380. */
  381. #ifdef CONFIG_SND_DEBUG
  382. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  383. struct snd_ctl_elem_info *uinfo)
  384. {
  385. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  386. uinfo->count = 1;
  387. uinfo->value.integer.min = 0;
  388. uinfo->value.integer.max = 1;
  389. return 0;
  390. }
  391. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  392. struct snd_ctl_elem_value *ucontrol)
  393. {
  394. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  395. hda_nid_t nid = kcontrol->private_value & 0xffff;
  396. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  397. long *valp = ucontrol->value.integer.value;
  398. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  399. AC_VERB_GET_GPIO_DATA, 0x00);
  400. *valp = (val & mask) != 0;
  401. return 0;
  402. }
  403. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  404. struct snd_ctl_elem_value *ucontrol)
  405. {
  406. signed int change;
  407. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  408. hda_nid_t nid = kcontrol->private_value & 0xffff;
  409. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  410. long val = *ucontrol->value.integer.value;
  411. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  412. AC_VERB_GET_GPIO_DATA,
  413. 0x00);
  414. /* Set/unset the masked GPIO bit(s) as needed */
  415. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  416. if (val == 0)
  417. gpio_data &= ~mask;
  418. else
  419. gpio_data |= mask;
  420. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  421. return change;
  422. }
  423. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  424. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  425. .info = alc_gpio_data_info, \
  426. .get = alc_gpio_data_get, \
  427. .put = alc_gpio_data_put, \
  428. .private_value = nid | (mask<<16) }
  429. #endif /* CONFIG_SND_DEBUG */
  430. /* A switch control to allow the enabling of the digital IO pins on the
  431. * ALC260. This is incredibly simplistic; the intention of this control is
  432. * to provide something in the test model allowing digital outputs to be
  433. * identified if present. If models are found which can utilise these
  434. * outputs a more complete mixer control can be devised for those models if
  435. * necessary.
  436. */
  437. #ifdef CONFIG_SND_DEBUG
  438. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  439. struct snd_ctl_elem_info *uinfo)
  440. {
  441. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  442. uinfo->count = 1;
  443. uinfo->value.integer.min = 0;
  444. uinfo->value.integer.max = 1;
  445. return 0;
  446. }
  447. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  448. struct snd_ctl_elem_value *ucontrol)
  449. {
  450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  451. hda_nid_t nid = kcontrol->private_value & 0xffff;
  452. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  453. long *valp = ucontrol->value.integer.value;
  454. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_DIGI_CONVERT, 0x00);
  456. *valp = (val & mask) != 0;
  457. return 0;
  458. }
  459. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  460. struct snd_ctl_elem_value *ucontrol)
  461. {
  462. signed int change;
  463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  464. hda_nid_t nid = kcontrol->private_value & 0xffff;
  465. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  466. long val = *ucontrol->value.integer.value;
  467. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_DIGI_CONVERT,
  469. 0x00);
  470. /* Set/unset the masked control bit(s) as needed */
  471. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  472. if (val==0)
  473. ctrl_data &= ~mask;
  474. else
  475. ctrl_data |= mask;
  476. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  477. ctrl_data);
  478. return change;
  479. }
  480. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  481. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  482. .info = alc_spdif_ctrl_info, \
  483. .get = alc_spdif_ctrl_get, \
  484. .put = alc_spdif_ctrl_put, \
  485. .private_value = nid | (mask<<16) }
  486. #endif /* CONFIG_SND_DEBUG */
  487. /*
  488. * set up from the preset table
  489. */
  490. static void setup_preset(struct alc_spec *spec,
  491. const struct alc_config_preset *preset)
  492. {
  493. int i;
  494. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  495. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  496. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  497. i++)
  498. spec->init_verbs[spec->num_init_verbs++] =
  499. preset->init_verbs[i];
  500. spec->channel_mode = preset->channel_mode;
  501. spec->num_channel_mode = preset->num_channel_mode;
  502. spec->need_dac_fix = preset->need_dac_fix;
  503. spec->multiout.max_channels = spec->channel_mode[0].channels;
  504. spec->multiout.num_dacs = preset->num_dacs;
  505. spec->multiout.dac_nids = preset->dac_nids;
  506. spec->multiout.dig_out_nid = preset->dig_out_nid;
  507. spec->multiout.hp_nid = preset->hp_nid;
  508. spec->num_mux_defs = preset->num_mux_defs;
  509. if (! spec->num_mux_defs)
  510. spec->num_mux_defs = 1;
  511. spec->input_mux = preset->input_mux;
  512. spec->num_adc_nids = preset->num_adc_nids;
  513. spec->adc_nids = preset->adc_nids;
  514. spec->dig_in_nid = preset->dig_in_nid;
  515. spec->unsol_event = preset->unsol_event;
  516. spec->init_hook = preset->init_hook;
  517. }
  518. /*
  519. * ALC880 3-stack model
  520. *
  521. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  522. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  523. * F-Mic = 0x1b, HP = 0x19
  524. */
  525. static hda_nid_t alc880_dac_nids[4] = {
  526. /* front, rear, clfe, rear_surr */
  527. 0x02, 0x05, 0x04, 0x03
  528. };
  529. static hda_nid_t alc880_adc_nids[3] = {
  530. /* ADC0-2 */
  531. 0x07, 0x08, 0x09,
  532. };
  533. /* The datasheet says the node 0x07 is connected from inputs,
  534. * but it shows zero connection in the real implementation on some devices.
  535. * Note: this is a 915GAV bug, fixed on 915GLV
  536. */
  537. static hda_nid_t alc880_adc_nids_alt[2] = {
  538. /* ADC1-2 */
  539. 0x08, 0x09,
  540. };
  541. #define ALC880_DIGOUT_NID 0x06
  542. #define ALC880_DIGIN_NID 0x0a
  543. static struct hda_input_mux alc880_capture_source = {
  544. .num_items = 4,
  545. .items = {
  546. { "Mic", 0x0 },
  547. { "Front Mic", 0x3 },
  548. { "Line", 0x2 },
  549. { "CD", 0x4 },
  550. },
  551. };
  552. /* channel source setting (2/6 channel selection for 3-stack) */
  553. /* 2ch mode */
  554. static struct hda_verb alc880_threestack_ch2_init[] = {
  555. /* set line-in to input, mute it */
  556. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  557. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  558. /* set mic-in to input vref 80%, mute it */
  559. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  560. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  561. { } /* end */
  562. };
  563. /* 6ch mode */
  564. static struct hda_verb alc880_threestack_ch6_init[] = {
  565. /* set line-in to output, unmute it */
  566. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  567. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  568. /* set mic-in to output, unmute it */
  569. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  570. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  571. { } /* end */
  572. };
  573. static struct hda_channel_mode alc880_threestack_modes[2] = {
  574. { 2, alc880_threestack_ch2_init },
  575. { 6, alc880_threestack_ch6_init },
  576. };
  577. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  578. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  579. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  580. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  581. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  582. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  583. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  584. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  585. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  586. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  587. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  588. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  589. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  590. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  591. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  592. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  593. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  594. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  595. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  596. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  597. {
  598. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  599. .name = "Channel Mode",
  600. .info = alc_ch_mode_info,
  601. .get = alc_ch_mode_get,
  602. .put = alc_ch_mode_put,
  603. },
  604. { } /* end */
  605. };
  606. /* capture mixer elements */
  607. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  608. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  609. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  610. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  611. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  612. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  613. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  614. {
  615. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  616. /* The multiple "Capture Source" controls confuse alsamixer
  617. * So call somewhat different..
  618. * FIXME: the controls appear in the "playback" view!
  619. */
  620. /* .name = "Capture Source", */
  621. .name = "Input Source",
  622. .count = 3,
  623. .info = alc_mux_enum_info,
  624. .get = alc_mux_enum_get,
  625. .put = alc_mux_enum_put,
  626. },
  627. { } /* end */
  628. };
  629. /* capture mixer elements (in case NID 0x07 not available) */
  630. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  631. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  632. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  633. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  634. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  635. {
  636. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  637. /* The multiple "Capture Source" controls confuse alsamixer
  638. * So call somewhat different..
  639. * FIXME: the controls appear in the "playback" view!
  640. */
  641. /* .name = "Capture Source", */
  642. .name = "Input Source",
  643. .count = 2,
  644. .info = alc_mux_enum_info,
  645. .get = alc_mux_enum_get,
  646. .put = alc_mux_enum_put,
  647. },
  648. { } /* end */
  649. };
  650. /*
  651. * ALC880 5-stack model
  652. *
  653. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  654. * Side = 0x02 (0xd)
  655. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  656. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  657. */
  658. /* additional mixers to alc880_three_stack_mixer */
  659. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  660. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  661. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  662. { } /* end */
  663. };
  664. /* channel source setting (6/8 channel selection for 5-stack) */
  665. /* 6ch mode */
  666. static struct hda_verb alc880_fivestack_ch6_init[] = {
  667. /* set line-in to input, mute it */
  668. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  669. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  670. { } /* end */
  671. };
  672. /* 8ch mode */
  673. static struct hda_verb alc880_fivestack_ch8_init[] = {
  674. /* set line-in to output, unmute it */
  675. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  676. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  677. { } /* end */
  678. };
  679. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  680. { 6, alc880_fivestack_ch6_init },
  681. { 8, alc880_fivestack_ch8_init },
  682. };
  683. /*
  684. * ALC880 6-stack model
  685. *
  686. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  687. * Side = 0x05 (0x0f)
  688. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  689. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  690. */
  691. static hda_nid_t alc880_6st_dac_nids[4] = {
  692. /* front, rear, clfe, rear_surr */
  693. 0x02, 0x03, 0x04, 0x05
  694. };
  695. static struct hda_input_mux alc880_6stack_capture_source = {
  696. .num_items = 4,
  697. .items = {
  698. { "Mic", 0x0 },
  699. { "Front Mic", 0x1 },
  700. { "Line", 0x2 },
  701. { "CD", 0x4 },
  702. },
  703. };
  704. /* fixed 8-channels */
  705. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  706. { 8, NULL },
  707. };
  708. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  709. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  710. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  711. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  712. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  713. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  714. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  715. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  716. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  717. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  719. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  720. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  722. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  724. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  727. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  728. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  729. {
  730. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  731. .name = "Channel Mode",
  732. .info = alc_ch_mode_info,
  733. .get = alc_ch_mode_get,
  734. .put = alc_ch_mode_put,
  735. },
  736. { } /* end */
  737. };
  738. /*
  739. * ALC880 W810 model
  740. *
  741. * W810 has rear IO for:
  742. * Front (DAC 02)
  743. * Surround (DAC 03)
  744. * Center/LFE (DAC 04)
  745. * Digital out (06)
  746. *
  747. * The system also has a pair of internal speakers, and a headphone jack.
  748. * These are both connected to Line2 on the codec, hence to DAC 02.
  749. *
  750. * There is a variable resistor to control the speaker or headphone
  751. * volume. This is a hardware-only device without a software API.
  752. *
  753. * Plugging headphones in will disable the internal speakers. This is
  754. * implemented in hardware, not via the driver using jack sense. In
  755. * a similar fashion, plugging into the rear socket marked "front" will
  756. * disable both the speakers and headphones.
  757. *
  758. * For input, there's a microphone jack, and an "audio in" jack.
  759. * These may not do anything useful with this driver yet, because I
  760. * haven't setup any initialization verbs for these yet...
  761. */
  762. static hda_nid_t alc880_w810_dac_nids[3] = {
  763. /* front, rear/surround, clfe */
  764. 0x02, 0x03, 0x04
  765. };
  766. /* fixed 6 channels */
  767. static struct hda_channel_mode alc880_w810_modes[1] = {
  768. { 6, NULL }
  769. };
  770. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  771. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  772. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  773. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  774. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  775. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  776. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  777. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  778. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  779. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  780. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  781. { } /* end */
  782. };
  783. /*
  784. * Z710V model
  785. *
  786. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  787. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  788. * Line = 0x1a
  789. */
  790. static hda_nid_t alc880_z71v_dac_nids[1] = {
  791. 0x02
  792. };
  793. #define ALC880_Z71V_HP_DAC 0x03
  794. /* fixed 2 channels */
  795. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  796. { 2, NULL }
  797. };
  798. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  799. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  800. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  801. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  802. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  803. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  804. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  805. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  806. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  807. { } /* end */
  808. };
  809. /* FIXME! */
  810. /*
  811. * ALC880 F1734 model
  812. *
  813. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  814. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  815. */
  816. static hda_nid_t alc880_f1734_dac_nids[1] = {
  817. 0x03
  818. };
  819. #define ALC880_F1734_HP_DAC 0x02
  820. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  821. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  822. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  823. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  824. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  825. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  826. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  827. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  828. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  829. { } /* end */
  830. };
  831. /* FIXME! */
  832. /*
  833. * ALC880 ASUS model
  834. *
  835. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  836. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  837. * Mic = 0x18, Line = 0x1a
  838. */
  839. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  840. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  841. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  842. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  843. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  844. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  845. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  846. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  847. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  848. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  849. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  850. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  851. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  852. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  853. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  854. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  855. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  856. {
  857. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  858. .name = "Channel Mode",
  859. .info = alc_ch_mode_info,
  860. .get = alc_ch_mode_get,
  861. .put = alc_ch_mode_put,
  862. },
  863. { } /* end */
  864. };
  865. /* FIXME! */
  866. /*
  867. * ALC880 ASUS W1V model
  868. *
  869. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  870. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  871. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  872. */
  873. /* additional mixers to alc880_asus_mixer */
  874. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  875. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  876. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  877. { } /* end */
  878. };
  879. /* additional mixers to alc880_asus_mixer */
  880. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  881. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  882. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  883. { } /* end */
  884. };
  885. /* TCL S700 */
  886. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  887. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  888. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  889. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  890. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  891. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  892. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  893. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  894. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  895. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  896. {
  897. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  898. /* The multiple "Capture Source" controls confuse alsamixer
  899. * So call somewhat different..
  900. * FIXME: the controls appear in the "playback" view!
  901. */
  902. /* .name = "Capture Source", */
  903. .name = "Input Source",
  904. .count = 1,
  905. .info = alc_mux_enum_info,
  906. .get = alc_mux_enum_get,
  907. .put = alc_mux_enum_put,
  908. },
  909. { } /* end */
  910. };
  911. /*
  912. * build control elements
  913. */
  914. static int alc_build_controls(struct hda_codec *codec)
  915. {
  916. struct alc_spec *spec = codec->spec;
  917. int err;
  918. int i;
  919. for (i = 0; i < spec->num_mixers; i++) {
  920. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  921. if (err < 0)
  922. return err;
  923. }
  924. if (spec->multiout.dig_out_nid) {
  925. err = snd_hda_create_spdif_out_ctls(codec,
  926. spec->multiout.dig_out_nid);
  927. if (err < 0)
  928. return err;
  929. }
  930. if (spec->dig_in_nid) {
  931. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  932. if (err < 0)
  933. return err;
  934. }
  935. return 0;
  936. }
  937. /*
  938. * initialize the codec volumes, etc
  939. */
  940. /*
  941. * generic initialization of ADC, input mixers and output mixers
  942. */
  943. static struct hda_verb alc880_volume_init_verbs[] = {
  944. /*
  945. * Unmute ADC0-2 and set the default input to mic-in
  946. */
  947. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  948. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  949. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  950. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  951. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  952. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  953. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  954. * mixer widget
  955. * Note: PASD motherboards uses the Line In 2 as the input for front
  956. * panel mic (mic 2)
  957. */
  958. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  959. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  960. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  961. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  964. /*
  965. * Set up output mixers (0x0c - 0x0f)
  966. */
  967. /* set vol=0 to output mixers */
  968. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  969. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  970. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  971. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  972. /* set up input amps for analog loopback */
  973. /* Amp Indices: DAC = 0, mixer = 1 */
  974. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  975. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  976. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  977. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  978. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  979. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  980. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  981. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  982. { }
  983. };
  984. /*
  985. * 3-stack pin configuration:
  986. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  987. */
  988. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  989. /*
  990. * preset connection lists of input pins
  991. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  992. */
  993. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  994. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  995. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  996. /*
  997. * Set pin mode and muting
  998. */
  999. /* set front pin widgets 0x14 for output */
  1000. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1001. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1002. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1003. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1004. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1005. /* Mic2 (as headphone out) for HP output */
  1006. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1007. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1008. /* Line In pin widget for input */
  1009. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1010. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1011. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1012. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1013. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1014. /* CD pin widget for input */
  1015. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1016. { }
  1017. };
  1018. /*
  1019. * 5-stack pin configuration:
  1020. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1021. * line-in/side = 0x1a, f-mic = 0x1b
  1022. */
  1023. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1024. /*
  1025. * preset connection lists of input pins
  1026. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1027. */
  1028. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1029. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1030. /*
  1031. * Set pin mode and muting
  1032. */
  1033. /* set pin widgets 0x14-0x17 for output */
  1034. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1035. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1036. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1037. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1038. /* unmute pins for output (no gain on this amp) */
  1039. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1040. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1041. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1042. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1043. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1044. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1045. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1046. /* Mic2 (as headphone out) for HP output */
  1047. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1048. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1049. /* Line In pin widget for input */
  1050. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1051. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1052. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1053. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1054. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1055. /* CD pin widget for input */
  1056. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1057. { }
  1058. };
  1059. /*
  1060. * W810 pin configuration:
  1061. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1062. */
  1063. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1064. /* hphone/speaker input selector: front DAC */
  1065. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1066. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1067. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1068. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1069. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1070. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1071. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1072. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1073. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1074. { }
  1075. };
  1076. /*
  1077. * Z71V pin configuration:
  1078. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1079. */
  1080. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1081. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1082. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1083. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1084. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1085. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1086. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1087. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1088. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1089. { }
  1090. };
  1091. /*
  1092. * 6-stack pin configuration:
  1093. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1094. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1095. */
  1096. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1097. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1098. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1099. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1100. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1101. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1102. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1103. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1104. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1105. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1106. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1107. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1108. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1109. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1110. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1111. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1112. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1113. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1114. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1115. { }
  1116. };
  1117. /* FIXME! */
  1118. /*
  1119. * F1734 pin configuration:
  1120. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1121. */
  1122. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1123. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1124. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1125. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1126. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1127. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1128. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1129. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1130. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1131. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1132. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1133. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1134. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1135. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1136. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1137. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1138. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1139. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1140. { }
  1141. };
  1142. /* FIXME! */
  1143. /*
  1144. * ASUS pin configuration:
  1145. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1146. */
  1147. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1148. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1149. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1150. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1151. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1152. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1153. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1154. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1155. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1156. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1157. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1158. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1159. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1160. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1161. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1162. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1163. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1164. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1165. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1167. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1168. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1169. { }
  1170. };
  1171. /* Enable GPIO mask and set output */
  1172. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1173. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1174. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1175. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1176. { }
  1177. };
  1178. /* Enable GPIO mask and set output */
  1179. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1180. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1181. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1182. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1183. { }
  1184. };
  1185. /* Clevo m520g init */
  1186. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1187. /* headphone output */
  1188. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1189. /* line-out */
  1190. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1191. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1192. /* Line-in */
  1193. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1195. /* CD */
  1196. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1197. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1198. /* Mic1 (rear panel) */
  1199. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1200. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1201. /* Mic2 (front panel) */
  1202. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1203. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1204. /* headphone */
  1205. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1206. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1207. /* change to EAPD mode */
  1208. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1209. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1210. { }
  1211. };
  1212. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1213. /* change to EAPD mode */
  1214. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1215. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1216. /* Headphone output */
  1217. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1218. /* Front output*/
  1219. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1221. /* Line In pin widget for input */
  1222. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1223. /* CD pin widget for input */
  1224. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1226. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1227. /* change to EAPD mode */
  1228. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1229. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1230. { }
  1231. };
  1232. /*
  1233. * LG m1 express dual
  1234. *
  1235. * Pin assignment:
  1236. * Rear Line-In/Out (blue): 0x14
  1237. * Build-in Mic-In: 0x15
  1238. * Speaker-out: 0x17
  1239. * HP-Out (green): 0x1b
  1240. * Mic-In/Out (red): 0x19
  1241. * SPDIF-Out: 0x1e
  1242. */
  1243. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1244. static hda_nid_t alc880_lg_dac_nids[3] = {
  1245. 0x05, 0x02, 0x03
  1246. };
  1247. /* seems analog CD is not working */
  1248. static struct hda_input_mux alc880_lg_capture_source = {
  1249. .num_items = 3,
  1250. .items = {
  1251. { "Mic", 0x1 },
  1252. { "Line", 0x5 },
  1253. { "Internal Mic", 0x6 },
  1254. },
  1255. };
  1256. /* 2,4,6 channel modes */
  1257. static struct hda_verb alc880_lg_ch2_init[] = {
  1258. /* set line-in and mic-in to input */
  1259. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1260. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1261. { }
  1262. };
  1263. static struct hda_verb alc880_lg_ch4_init[] = {
  1264. /* set line-in to out and mic-in to input */
  1265. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1266. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1267. { }
  1268. };
  1269. static struct hda_verb alc880_lg_ch6_init[] = {
  1270. /* set line-in and mic-in to output */
  1271. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1272. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1273. { }
  1274. };
  1275. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1276. { 2, alc880_lg_ch2_init },
  1277. { 4, alc880_lg_ch4_init },
  1278. { 6, alc880_lg_ch6_init },
  1279. };
  1280. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1281. /* FIXME: it's not really "master" but front channels */
  1282. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1283. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1284. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1285. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1286. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1287. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1288. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1289. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1290. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1291. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1292. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1293. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1294. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1295. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1296. {
  1297. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1298. .name = "Channel Mode",
  1299. .info = alc_ch_mode_info,
  1300. .get = alc_ch_mode_get,
  1301. .put = alc_ch_mode_put,
  1302. },
  1303. { } /* end */
  1304. };
  1305. static struct hda_verb alc880_lg_init_verbs[] = {
  1306. /* set capture source to mic-in */
  1307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1308. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1309. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1310. /* mute all amp mixer inputs */
  1311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1314. /* line-in to input */
  1315. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1316. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. /* built-in mic */
  1318. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. /* speaker-out */
  1321. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1322. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1323. /* mic-in to input */
  1324. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1327. /* HP-out */
  1328. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1329. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1330. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1331. /* jack sense */
  1332. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1333. { }
  1334. };
  1335. /* toggle speaker-output according to the hp-jack state */
  1336. static void alc880_lg_automute(struct hda_codec *codec)
  1337. {
  1338. unsigned int present;
  1339. present = snd_hda_codec_read(codec, 0x1b, 0,
  1340. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1341. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1342. 0x80, present ? 0x80 : 0);
  1343. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1344. 0x80, present ? 0x80 : 0);
  1345. }
  1346. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1347. {
  1348. /* Looks like the unsol event is incompatible with the standard
  1349. * definition. 4bit tag is placed at 28 bit!
  1350. */
  1351. if ((res >> 28) == 0x01)
  1352. alc880_lg_automute(codec);
  1353. }
  1354. /*
  1355. * LG LW20
  1356. *
  1357. * Pin assignment:
  1358. * Speaker-out: 0x14
  1359. * Mic-In: 0x18
  1360. * Built-in Mic-In: 0x19 (?)
  1361. * HP-Out: 0x1b
  1362. * SPDIF-Out: 0x1e
  1363. */
  1364. /* seems analog CD is not working */
  1365. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1366. .num_items = 2,
  1367. .items = {
  1368. { "Mic", 0x0 },
  1369. { "Internal Mic", 0x1 },
  1370. },
  1371. };
  1372. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1373. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1374. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1375. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1376. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1377. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1378. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1379. { } /* end */
  1380. };
  1381. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1382. /* set capture source to mic-in */
  1383. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1384. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1385. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1386. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1387. /* speaker-out */
  1388. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1389. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1390. /* HP-out */
  1391. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1392. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1393. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1394. /* mic-in to input */
  1395. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1396. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1397. /* built-in mic */
  1398. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1399. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1400. /* jack sense */
  1401. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1402. { }
  1403. };
  1404. /* toggle speaker-output according to the hp-jack state */
  1405. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1406. {
  1407. unsigned int present;
  1408. present = snd_hda_codec_read(codec, 0x1b, 0,
  1409. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1410. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1411. 0x80, present ? 0x80 : 0);
  1412. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1413. 0x80, present ? 0x80 : 0);
  1414. }
  1415. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1416. {
  1417. /* Looks like the unsol event is incompatible with the standard
  1418. * definition. 4bit tag is placed at 28 bit!
  1419. */
  1420. if ((res >> 28) == 0x01)
  1421. alc880_lg_lw_automute(codec);
  1422. }
  1423. /*
  1424. * Common callbacks
  1425. */
  1426. static int alc_init(struct hda_codec *codec)
  1427. {
  1428. struct alc_spec *spec = codec->spec;
  1429. unsigned int i;
  1430. for (i = 0; i < spec->num_init_verbs; i++)
  1431. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1432. if (spec->init_hook)
  1433. spec->init_hook(codec);
  1434. return 0;
  1435. }
  1436. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1437. {
  1438. struct alc_spec *spec = codec->spec;
  1439. if (spec->unsol_event)
  1440. spec->unsol_event(codec, res);
  1441. }
  1442. #ifdef CONFIG_PM
  1443. /*
  1444. * resume
  1445. */
  1446. static int alc_resume(struct hda_codec *codec)
  1447. {
  1448. struct alc_spec *spec = codec->spec;
  1449. int i;
  1450. alc_init(codec);
  1451. for (i = 0; i < spec->num_mixers; i++)
  1452. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1453. if (spec->multiout.dig_out_nid)
  1454. snd_hda_resume_spdif_out(codec);
  1455. if (spec->dig_in_nid)
  1456. snd_hda_resume_spdif_in(codec);
  1457. return 0;
  1458. }
  1459. #endif
  1460. /*
  1461. * Analog playback callbacks
  1462. */
  1463. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1464. struct hda_codec *codec,
  1465. struct snd_pcm_substream *substream)
  1466. {
  1467. struct alc_spec *spec = codec->spec;
  1468. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1469. }
  1470. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1471. struct hda_codec *codec,
  1472. unsigned int stream_tag,
  1473. unsigned int format,
  1474. struct snd_pcm_substream *substream)
  1475. {
  1476. struct alc_spec *spec = codec->spec;
  1477. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1478. stream_tag, format, substream);
  1479. }
  1480. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1481. struct hda_codec *codec,
  1482. struct snd_pcm_substream *substream)
  1483. {
  1484. struct alc_spec *spec = codec->spec;
  1485. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1486. }
  1487. /*
  1488. * Digital out
  1489. */
  1490. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1491. struct hda_codec *codec,
  1492. struct snd_pcm_substream *substream)
  1493. {
  1494. struct alc_spec *spec = codec->spec;
  1495. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1496. }
  1497. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1498. struct hda_codec *codec,
  1499. struct snd_pcm_substream *substream)
  1500. {
  1501. struct alc_spec *spec = codec->spec;
  1502. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1503. }
  1504. /*
  1505. * Analog capture
  1506. */
  1507. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1508. struct hda_codec *codec,
  1509. unsigned int stream_tag,
  1510. unsigned int format,
  1511. struct snd_pcm_substream *substream)
  1512. {
  1513. struct alc_spec *spec = codec->spec;
  1514. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1515. stream_tag, 0, format);
  1516. return 0;
  1517. }
  1518. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1519. struct hda_codec *codec,
  1520. struct snd_pcm_substream *substream)
  1521. {
  1522. struct alc_spec *spec = codec->spec;
  1523. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1524. 0, 0, 0);
  1525. return 0;
  1526. }
  1527. /*
  1528. */
  1529. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1530. .substreams = 1,
  1531. .channels_min = 2,
  1532. .channels_max = 8,
  1533. /* NID is set in alc_build_pcms */
  1534. .ops = {
  1535. .open = alc880_playback_pcm_open,
  1536. .prepare = alc880_playback_pcm_prepare,
  1537. .cleanup = alc880_playback_pcm_cleanup
  1538. },
  1539. };
  1540. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1541. .substreams = 2,
  1542. .channels_min = 2,
  1543. .channels_max = 2,
  1544. /* NID is set in alc_build_pcms */
  1545. .ops = {
  1546. .prepare = alc880_capture_pcm_prepare,
  1547. .cleanup = alc880_capture_pcm_cleanup
  1548. },
  1549. };
  1550. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1551. .substreams = 1,
  1552. .channels_min = 2,
  1553. .channels_max = 2,
  1554. /* NID is set in alc_build_pcms */
  1555. .ops = {
  1556. .open = alc880_dig_playback_pcm_open,
  1557. .close = alc880_dig_playback_pcm_close
  1558. },
  1559. };
  1560. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1561. .substreams = 1,
  1562. .channels_min = 2,
  1563. .channels_max = 2,
  1564. /* NID is set in alc_build_pcms */
  1565. };
  1566. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1567. static struct hda_pcm_stream alc_pcm_null_playback = {
  1568. .substreams = 0,
  1569. .channels_min = 0,
  1570. .channels_max = 0,
  1571. };
  1572. static int alc_build_pcms(struct hda_codec *codec)
  1573. {
  1574. struct alc_spec *spec = codec->spec;
  1575. struct hda_pcm *info = spec->pcm_rec;
  1576. int i;
  1577. codec->num_pcms = 1;
  1578. codec->pcm_info = info;
  1579. info->name = spec->stream_name_analog;
  1580. if (spec->stream_analog_playback) {
  1581. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1582. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1583. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1584. }
  1585. if (spec->stream_analog_capture) {
  1586. snd_assert(spec->adc_nids, return -EINVAL);
  1587. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1588. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1589. }
  1590. if (spec->channel_mode) {
  1591. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1592. for (i = 0; i < spec->num_channel_mode; i++) {
  1593. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1594. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1595. }
  1596. }
  1597. }
  1598. /* SPDIF for stream index #1 */
  1599. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1600. codec->num_pcms = 2;
  1601. info = spec->pcm_rec + 1;
  1602. info->name = spec->stream_name_digital;
  1603. if (spec->multiout.dig_out_nid &&
  1604. spec->stream_digital_playback) {
  1605. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1606. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1607. }
  1608. if (spec->dig_in_nid &&
  1609. spec->stream_digital_capture) {
  1610. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1611. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1612. }
  1613. }
  1614. /* If the use of more than one ADC is requested for the current
  1615. * model, configure a second analog capture-only PCM.
  1616. */
  1617. /* Additional Analaog capture for index #2 */
  1618. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1619. spec->adc_nids) {
  1620. codec->num_pcms = 3;
  1621. info = spec->pcm_rec + 2;
  1622. info->name = spec->stream_name_analog;
  1623. /* No playback stream for second PCM */
  1624. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1625. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1626. if (spec->stream_analog_capture) {
  1627. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1628. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1629. }
  1630. }
  1631. return 0;
  1632. }
  1633. static void alc_free(struct hda_codec *codec)
  1634. {
  1635. struct alc_spec *spec = codec->spec;
  1636. unsigned int i;
  1637. if (! spec)
  1638. return;
  1639. if (spec->kctl_alloc) {
  1640. for (i = 0; i < spec->num_kctl_used; i++)
  1641. kfree(spec->kctl_alloc[i].name);
  1642. kfree(spec->kctl_alloc);
  1643. }
  1644. kfree(spec);
  1645. }
  1646. /*
  1647. */
  1648. static struct hda_codec_ops alc_patch_ops = {
  1649. .build_controls = alc_build_controls,
  1650. .build_pcms = alc_build_pcms,
  1651. .init = alc_init,
  1652. .free = alc_free,
  1653. .unsol_event = alc_unsol_event,
  1654. #ifdef CONFIG_PM
  1655. .resume = alc_resume,
  1656. #endif
  1657. };
  1658. /*
  1659. * Test configuration for debugging
  1660. *
  1661. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1662. * enum controls.
  1663. */
  1664. #ifdef CONFIG_SND_DEBUG
  1665. static hda_nid_t alc880_test_dac_nids[4] = {
  1666. 0x02, 0x03, 0x04, 0x05
  1667. };
  1668. static struct hda_input_mux alc880_test_capture_source = {
  1669. .num_items = 7,
  1670. .items = {
  1671. { "In-1", 0x0 },
  1672. { "In-2", 0x1 },
  1673. { "In-3", 0x2 },
  1674. { "In-4", 0x3 },
  1675. { "CD", 0x4 },
  1676. { "Front", 0x5 },
  1677. { "Surround", 0x6 },
  1678. },
  1679. };
  1680. static struct hda_channel_mode alc880_test_modes[4] = {
  1681. { 2, NULL },
  1682. { 4, NULL },
  1683. { 6, NULL },
  1684. { 8, NULL },
  1685. };
  1686. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1687. struct snd_ctl_elem_info *uinfo)
  1688. {
  1689. static char *texts[] = {
  1690. "N/A", "Line Out", "HP Out",
  1691. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1692. };
  1693. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1694. uinfo->count = 1;
  1695. uinfo->value.enumerated.items = 8;
  1696. if (uinfo->value.enumerated.item >= 8)
  1697. uinfo->value.enumerated.item = 7;
  1698. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1699. return 0;
  1700. }
  1701. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1702. struct snd_ctl_elem_value *ucontrol)
  1703. {
  1704. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1705. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1706. unsigned int pin_ctl, item = 0;
  1707. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1708. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1709. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1710. if (pin_ctl & AC_PINCTL_HP_EN)
  1711. item = 2;
  1712. else
  1713. item = 1;
  1714. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1715. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1716. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1717. case AC_PINCTL_VREF_50: item = 4; break;
  1718. case AC_PINCTL_VREF_GRD: item = 5; break;
  1719. case AC_PINCTL_VREF_80: item = 6; break;
  1720. case AC_PINCTL_VREF_100: item = 7; break;
  1721. }
  1722. }
  1723. ucontrol->value.enumerated.item[0] = item;
  1724. return 0;
  1725. }
  1726. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1727. struct snd_ctl_elem_value *ucontrol)
  1728. {
  1729. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1730. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1731. static unsigned int ctls[] = {
  1732. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1733. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1734. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1735. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1736. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1737. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1738. };
  1739. unsigned int old_ctl, new_ctl;
  1740. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1741. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1742. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1743. if (old_ctl != new_ctl) {
  1744. snd_hda_codec_write(codec, nid, 0,
  1745. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1746. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1747. (ucontrol->value.enumerated.item[0] >= 3 ?
  1748. 0xb080 : 0xb000));
  1749. return 1;
  1750. }
  1751. return 0;
  1752. }
  1753. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1754. struct snd_ctl_elem_info *uinfo)
  1755. {
  1756. static char *texts[] = {
  1757. "Front", "Surround", "CLFE", "Side"
  1758. };
  1759. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1760. uinfo->count = 1;
  1761. uinfo->value.enumerated.items = 4;
  1762. if (uinfo->value.enumerated.item >= 4)
  1763. uinfo->value.enumerated.item = 3;
  1764. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1765. return 0;
  1766. }
  1767. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1768. struct snd_ctl_elem_value *ucontrol)
  1769. {
  1770. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1771. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1772. unsigned int sel;
  1773. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1774. ucontrol->value.enumerated.item[0] = sel & 3;
  1775. return 0;
  1776. }
  1777. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1778. struct snd_ctl_elem_value *ucontrol)
  1779. {
  1780. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1781. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1782. unsigned int sel;
  1783. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1784. if (ucontrol->value.enumerated.item[0] != sel) {
  1785. sel = ucontrol->value.enumerated.item[0] & 3;
  1786. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1787. return 1;
  1788. }
  1789. return 0;
  1790. }
  1791. #define PIN_CTL_TEST(xname,nid) { \
  1792. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1793. .name = xname, \
  1794. .info = alc_test_pin_ctl_info, \
  1795. .get = alc_test_pin_ctl_get, \
  1796. .put = alc_test_pin_ctl_put, \
  1797. .private_value = nid \
  1798. }
  1799. #define PIN_SRC_TEST(xname,nid) { \
  1800. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1801. .name = xname, \
  1802. .info = alc_test_pin_src_info, \
  1803. .get = alc_test_pin_src_get, \
  1804. .put = alc_test_pin_src_put, \
  1805. .private_value = nid \
  1806. }
  1807. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1808. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1809. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1810. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1811. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1812. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1813. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1814. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1815. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1816. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1817. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1818. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1819. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1820. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1821. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1822. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1823. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1824. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1825. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1826. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1827. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1828. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1829. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1830. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1831. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1832. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1833. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1834. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1835. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1836. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1837. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1838. {
  1839. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1840. .name = "Channel Mode",
  1841. .info = alc_ch_mode_info,
  1842. .get = alc_ch_mode_get,
  1843. .put = alc_ch_mode_put,
  1844. },
  1845. { } /* end */
  1846. };
  1847. static struct hda_verb alc880_test_init_verbs[] = {
  1848. /* Unmute inputs of 0x0c - 0x0f */
  1849. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1850. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1851. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1852. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1853. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1854. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1855. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1856. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1857. /* Vol output for 0x0c-0x0f */
  1858. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1859. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1860. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1861. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1862. /* Set output pins 0x14-0x17 */
  1863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1864. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1866. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1867. /* Unmute output pins 0x14-0x17 */
  1868. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1869. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1870. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1871. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1872. /* Set input pins 0x18-0x1c */
  1873. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1874. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1875. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1876. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1877. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1878. /* Mute input pins 0x18-0x1b */
  1879. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1880. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1881. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1882. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1883. /* ADC set up */
  1884. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1885. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1886. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1887. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1888. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1889. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1890. /* Analog input/passthru */
  1891. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1892. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1893. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1894. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1895. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1896. { }
  1897. };
  1898. #endif
  1899. /*
  1900. */
  1901. static struct hda_board_config alc880_cfg_tbl[] = {
  1902. /* Back 3 jack, front 2 jack */
  1903. { .modelname = "3stack", .config = ALC880_3ST },
  1904. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1905. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1906. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1907. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1908. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1909. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1910. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1911. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1912. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1913. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1914. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1915. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1916. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1917. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1918. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1919. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1920. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1921. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1922. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
  1923. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
  1924. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1925. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
  1926. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1927. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1928. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1929. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1930. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1931. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1932. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1933. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1934. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1935. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1936. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1937. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1938. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1939. /* TCL S700 */
  1940. { .modelname = "tcl", .config = ALC880_TCL_S700 },
  1941. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1942. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1943. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1944. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1945. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1946. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1947. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1948. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1949. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1950. /* Clevo laptops */
  1951. { .modelname = "clevo", .config = ALC880_CLEVO },
  1952. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
  1953. .config = ALC880_CLEVO }, /* Clevo m520G NB */
  1954. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
  1955. .config = ALC880_CLEVO }, /* Clevo m665n */
  1956. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1957. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1958. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1959. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1960. /* Back 5 jack, front 2 jack */
  1961. { .modelname = "5stack", .config = ALC880_5ST },
  1962. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1963. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1964. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1965. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1966. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1967. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1968. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1969. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1970. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1971. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1972. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1973. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1974. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1975. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1976. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1977. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1978. { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
  1979. .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
  1980. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1981. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1982. /* note subvendor = 0 below */
  1983. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1984. { .modelname = "w810", .config = ALC880_W810 },
  1985. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1986. { .modelname = "z71v", .config = ALC880_Z71V },
  1987. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1988. { .modelname = "6stack", .config = ALC880_6ST },
  1989. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1990. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1991. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1992. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1993. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1994. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1995. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1996. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1997. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1998. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  1999. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  2000. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  2001. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  2002. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  2003. { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
  2004. { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
  2005. { .modelname = "asus", .config = ALC880_ASUS },
  2006. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  2007. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  2008. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  2009. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  2010. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  2011. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  2012. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
  2013. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  2014. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  2015. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  2016. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  2017. { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
  2018. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  2019. { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
  2020. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
  2021. { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
  2022. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  2023. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  2024. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  2025. { .modelname = "F1734", .config = ALC880_F1734 },
  2026. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  2027. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  2028. { .modelname = "lg", .config = ALC880_LG },
  2029. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  2030. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
  2031. { .modelname = "lg-lw", .config = ALC880_LG_LW },
  2032. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
  2033. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
  2034. #ifdef CONFIG_SND_DEBUG
  2035. { .modelname = "test", .config = ALC880_TEST },
  2036. #endif
  2037. { .modelname = "auto", .config = ALC880_AUTO },
  2038. {}
  2039. };
  2040. /*
  2041. * ALC880 codec presets
  2042. */
  2043. static struct alc_config_preset alc880_presets[] = {
  2044. [ALC880_3ST] = {
  2045. .mixers = { alc880_three_stack_mixer },
  2046. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2047. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2048. .dac_nids = alc880_dac_nids,
  2049. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2050. .channel_mode = alc880_threestack_modes,
  2051. .need_dac_fix = 1,
  2052. .input_mux = &alc880_capture_source,
  2053. },
  2054. [ALC880_3ST_DIG] = {
  2055. .mixers = { alc880_three_stack_mixer },
  2056. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2057. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2058. .dac_nids = alc880_dac_nids,
  2059. .dig_out_nid = ALC880_DIGOUT_NID,
  2060. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2061. .channel_mode = alc880_threestack_modes,
  2062. .need_dac_fix = 1,
  2063. .input_mux = &alc880_capture_source,
  2064. },
  2065. [ALC880_TCL_S700] = {
  2066. .mixers = { alc880_tcl_s700_mixer },
  2067. .init_verbs = { alc880_volume_init_verbs,
  2068. alc880_pin_tcl_S700_init_verbs,
  2069. alc880_gpio2_init_verbs },
  2070. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2071. .dac_nids = alc880_dac_nids,
  2072. .hp_nid = 0x03,
  2073. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2074. .channel_mode = alc880_2_jack_modes,
  2075. .input_mux = &alc880_capture_source,
  2076. },
  2077. [ALC880_5ST] = {
  2078. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2079. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2080. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2081. .dac_nids = alc880_dac_nids,
  2082. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2083. .channel_mode = alc880_fivestack_modes,
  2084. .input_mux = &alc880_capture_source,
  2085. },
  2086. [ALC880_5ST_DIG] = {
  2087. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2088. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2089. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2090. .dac_nids = alc880_dac_nids,
  2091. .dig_out_nid = ALC880_DIGOUT_NID,
  2092. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2093. .channel_mode = alc880_fivestack_modes,
  2094. .input_mux = &alc880_capture_source,
  2095. },
  2096. [ALC880_6ST] = {
  2097. .mixers = { alc880_six_stack_mixer },
  2098. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2099. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2100. .dac_nids = alc880_6st_dac_nids,
  2101. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2102. .channel_mode = alc880_sixstack_modes,
  2103. .input_mux = &alc880_6stack_capture_source,
  2104. },
  2105. [ALC880_6ST_DIG] = {
  2106. .mixers = { alc880_six_stack_mixer },
  2107. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2108. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2109. .dac_nids = alc880_6st_dac_nids,
  2110. .dig_out_nid = ALC880_DIGOUT_NID,
  2111. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2112. .channel_mode = alc880_sixstack_modes,
  2113. .input_mux = &alc880_6stack_capture_source,
  2114. },
  2115. [ALC880_W810] = {
  2116. .mixers = { alc880_w810_base_mixer },
  2117. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2118. alc880_gpio2_init_verbs },
  2119. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2120. .dac_nids = alc880_w810_dac_nids,
  2121. .dig_out_nid = ALC880_DIGOUT_NID,
  2122. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2123. .channel_mode = alc880_w810_modes,
  2124. .input_mux = &alc880_capture_source,
  2125. },
  2126. [ALC880_Z71V] = {
  2127. .mixers = { alc880_z71v_mixer },
  2128. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2129. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2130. .dac_nids = alc880_z71v_dac_nids,
  2131. .dig_out_nid = ALC880_DIGOUT_NID,
  2132. .hp_nid = 0x03,
  2133. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2134. .channel_mode = alc880_2_jack_modes,
  2135. .input_mux = &alc880_capture_source,
  2136. },
  2137. [ALC880_F1734] = {
  2138. .mixers = { alc880_f1734_mixer },
  2139. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2140. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2141. .dac_nids = alc880_f1734_dac_nids,
  2142. .hp_nid = 0x02,
  2143. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2144. .channel_mode = alc880_2_jack_modes,
  2145. .input_mux = &alc880_capture_source,
  2146. },
  2147. [ALC880_ASUS] = {
  2148. .mixers = { alc880_asus_mixer },
  2149. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2150. alc880_gpio1_init_verbs },
  2151. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2152. .dac_nids = alc880_asus_dac_nids,
  2153. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2154. .channel_mode = alc880_asus_modes,
  2155. .need_dac_fix = 1,
  2156. .input_mux = &alc880_capture_source,
  2157. },
  2158. [ALC880_ASUS_DIG] = {
  2159. .mixers = { alc880_asus_mixer },
  2160. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2161. alc880_gpio1_init_verbs },
  2162. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2163. .dac_nids = alc880_asus_dac_nids,
  2164. .dig_out_nid = ALC880_DIGOUT_NID,
  2165. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2166. .channel_mode = alc880_asus_modes,
  2167. .need_dac_fix = 1,
  2168. .input_mux = &alc880_capture_source,
  2169. },
  2170. [ALC880_ASUS_DIG2] = {
  2171. .mixers = { alc880_asus_mixer },
  2172. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2173. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2174. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2175. .dac_nids = alc880_asus_dac_nids,
  2176. .dig_out_nid = ALC880_DIGOUT_NID,
  2177. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2178. .channel_mode = alc880_asus_modes,
  2179. .need_dac_fix = 1,
  2180. .input_mux = &alc880_capture_source,
  2181. },
  2182. [ALC880_ASUS_W1V] = {
  2183. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2184. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2185. alc880_gpio1_init_verbs },
  2186. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2187. .dac_nids = alc880_asus_dac_nids,
  2188. .dig_out_nid = ALC880_DIGOUT_NID,
  2189. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2190. .channel_mode = alc880_asus_modes,
  2191. .need_dac_fix = 1,
  2192. .input_mux = &alc880_capture_source,
  2193. },
  2194. [ALC880_UNIWILL_DIG] = {
  2195. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2196. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2197. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2198. .dac_nids = alc880_asus_dac_nids,
  2199. .dig_out_nid = ALC880_DIGOUT_NID,
  2200. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2201. .channel_mode = alc880_asus_modes,
  2202. .need_dac_fix = 1,
  2203. .input_mux = &alc880_capture_source,
  2204. },
  2205. [ALC880_CLEVO] = {
  2206. .mixers = { alc880_three_stack_mixer },
  2207. .init_verbs = { alc880_volume_init_verbs,
  2208. alc880_pin_clevo_init_verbs },
  2209. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2210. .dac_nids = alc880_dac_nids,
  2211. .hp_nid = 0x03,
  2212. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2213. .channel_mode = alc880_threestack_modes,
  2214. .need_dac_fix = 1,
  2215. .input_mux = &alc880_capture_source,
  2216. },
  2217. [ALC880_LG] = {
  2218. .mixers = { alc880_lg_mixer },
  2219. .init_verbs = { alc880_volume_init_verbs,
  2220. alc880_lg_init_verbs },
  2221. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2222. .dac_nids = alc880_lg_dac_nids,
  2223. .dig_out_nid = ALC880_DIGOUT_NID,
  2224. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2225. .channel_mode = alc880_lg_ch_modes,
  2226. .need_dac_fix = 1,
  2227. .input_mux = &alc880_lg_capture_source,
  2228. .unsol_event = alc880_lg_unsol_event,
  2229. .init_hook = alc880_lg_automute,
  2230. },
  2231. [ALC880_LG_LW] = {
  2232. .mixers = { alc880_lg_lw_mixer },
  2233. .init_verbs = { alc880_volume_init_verbs,
  2234. alc880_lg_lw_init_verbs },
  2235. .num_dacs = 1,
  2236. .dac_nids = alc880_dac_nids,
  2237. .dig_out_nid = ALC880_DIGOUT_NID,
  2238. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2239. .channel_mode = alc880_2_jack_modes,
  2240. .input_mux = &alc880_lg_lw_capture_source,
  2241. .unsol_event = alc880_lg_lw_unsol_event,
  2242. .init_hook = alc880_lg_lw_automute,
  2243. },
  2244. #ifdef CONFIG_SND_DEBUG
  2245. [ALC880_TEST] = {
  2246. .mixers = { alc880_test_mixer },
  2247. .init_verbs = { alc880_test_init_verbs },
  2248. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2249. .dac_nids = alc880_test_dac_nids,
  2250. .dig_out_nid = ALC880_DIGOUT_NID,
  2251. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2252. .channel_mode = alc880_test_modes,
  2253. .input_mux = &alc880_test_capture_source,
  2254. },
  2255. #endif
  2256. };
  2257. /*
  2258. * Automatic parse of I/O pins from the BIOS configuration
  2259. */
  2260. #define NUM_CONTROL_ALLOC 32
  2261. #define NUM_VERB_ALLOC 32
  2262. enum {
  2263. ALC_CTL_WIDGET_VOL,
  2264. ALC_CTL_WIDGET_MUTE,
  2265. ALC_CTL_BIND_MUTE,
  2266. };
  2267. static struct snd_kcontrol_new alc880_control_templates[] = {
  2268. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2269. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2270. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2271. };
  2272. /* add dynamic controls */
  2273. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2274. {
  2275. struct snd_kcontrol_new *knew;
  2276. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2277. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2278. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2279. if (! knew)
  2280. return -ENOMEM;
  2281. if (spec->kctl_alloc) {
  2282. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2283. kfree(spec->kctl_alloc);
  2284. }
  2285. spec->kctl_alloc = knew;
  2286. spec->num_kctl_alloc = num;
  2287. }
  2288. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2289. *knew = alc880_control_templates[type];
  2290. knew->name = kstrdup(name, GFP_KERNEL);
  2291. if (! knew->name)
  2292. return -ENOMEM;
  2293. knew->private_value = val;
  2294. spec->num_kctl_used++;
  2295. return 0;
  2296. }
  2297. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2298. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2299. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2300. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2301. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2302. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2303. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2304. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2305. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2306. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2307. #define ALC880_PIN_CD_NID 0x1c
  2308. /* fill in the dac_nids table from the parsed pin configuration */
  2309. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2310. {
  2311. hda_nid_t nid;
  2312. int assigned[4];
  2313. int i, j;
  2314. memset(assigned, 0, sizeof(assigned));
  2315. spec->multiout.dac_nids = spec->private_dac_nids;
  2316. /* check the pins hardwired to audio widget */
  2317. for (i = 0; i < cfg->line_outs; i++) {
  2318. nid = cfg->line_out_pins[i];
  2319. if (alc880_is_fixed_pin(nid)) {
  2320. int idx = alc880_fixed_pin_idx(nid);
  2321. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2322. assigned[idx] = 1;
  2323. }
  2324. }
  2325. /* left pins can be connect to any audio widget */
  2326. for (i = 0; i < cfg->line_outs; i++) {
  2327. nid = cfg->line_out_pins[i];
  2328. if (alc880_is_fixed_pin(nid))
  2329. continue;
  2330. /* search for an empty channel */
  2331. for (j = 0; j < cfg->line_outs; j++) {
  2332. if (! assigned[j]) {
  2333. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2334. assigned[j] = 1;
  2335. break;
  2336. }
  2337. }
  2338. }
  2339. spec->multiout.num_dacs = cfg->line_outs;
  2340. return 0;
  2341. }
  2342. /* add playback controls from the parsed DAC table */
  2343. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2344. const struct auto_pin_cfg *cfg)
  2345. {
  2346. char name[32];
  2347. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2348. hda_nid_t nid;
  2349. int i, err;
  2350. for (i = 0; i < cfg->line_outs; i++) {
  2351. if (! spec->multiout.dac_nids[i])
  2352. continue;
  2353. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2354. if (i == 2) {
  2355. /* Center/LFE */
  2356. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2357. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2358. return err;
  2359. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2360. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2361. return err;
  2362. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2363. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2364. return err;
  2365. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2366. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2367. return err;
  2368. } else {
  2369. sprintf(name, "%s Playback Volume", chname[i]);
  2370. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2371. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2372. return err;
  2373. sprintf(name, "%s Playback Switch", chname[i]);
  2374. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2375. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2376. return err;
  2377. }
  2378. }
  2379. return 0;
  2380. }
  2381. /* add playback controls for speaker and HP outputs */
  2382. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2383. const char *pfx)
  2384. {
  2385. hda_nid_t nid;
  2386. int err;
  2387. char name[32];
  2388. if (! pin)
  2389. return 0;
  2390. if (alc880_is_fixed_pin(pin)) {
  2391. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2392. /* specify the DAC as the extra output */
  2393. if (! spec->multiout.hp_nid)
  2394. spec->multiout.hp_nid = nid;
  2395. else
  2396. spec->multiout.extra_out_nid[0] = nid;
  2397. /* control HP volume/switch on the output mixer amp */
  2398. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2399. sprintf(name, "%s Playback Volume", pfx);
  2400. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2401. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2402. return err;
  2403. sprintf(name, "%s Playback Switch", pfx);
  2404. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2405. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2406. return err;
  2407. } else if (alc880_is_multi_pin(pin)) {
  2408. /* set manual connection */
  2409. /* we have only a switch on HP-out PIN */
  2410. sprintf(name, "%s Playback Switch", pfx);
  2411. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2412. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2413. return err;
  2414. }
  2415. return 0;
  2416. }
  2417. /* create input playback/capture controls for the given pin */
  2418. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2419. int idx, hda_nid_t mix_nid)
  2420. {
  2421. char name[32];
  2422. int err;
  2423. sprintf(name, "%s Playback Volume", ctlname);
  2424. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2425. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2426. return err;
  2427. sprintf(name, "%s Playback Switch", ctlname);
  2428. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2429. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2430. return err;
  2431. return 0;
  2432. }
  2433. /* create playback/capture controls for input pins */
  2434. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2435. const struct auto_pin_cfg *cfg)
  2436. {
  2437. struct hda_input_mux *imux = &spec->private_imux;
  2438. int i, err, idx;
  2439. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2440. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2441. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2442. err = new_analog_input(spec, cfg->input_pins[i],
  2443. auto_pin_cfg_labels[i],
  2444. idx, 0x0b);
  2445. if (err < 0)
  2446. return err;
  2447. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2448. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2449. imux->num_items++;
  2450. }
  2451. }
  2452. return 0;
  2453. }
  2454. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2455. hda_nid_t nid, int pin_type,
  2456. int dac_idx)
  2457. {
  2458. /* set as output */
  2459. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2460. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2461. /* need the manual connection? */
  2462. if (alc880_is_multi_pin(nid)) {
  2463. struct alc_spec *spec = codec->spec;
  2464. int idx = alc880_multi_pin_idx(nid);
  2465. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2466. AC_VERB_SET_CONNECT_SEL,
  2467. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2468. }
  2469. }
  2470. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2471. {
  2472. struct alc_spec *spec = codec->spec;
  2473. int i;
  2474. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2475. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2476. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2477. }
  2478. }
  2479. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2480. {
  2481. struct alc_spec *spec = codec->spec;
  2482. hda_nid_t pin;
  2483. pin = spec->autocfg.speaker_pins[0];
  2484. if (pin) /* connect to front */
  2485. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2486. pin = spec->autocfg.hp_pins[0];
  2487. if (pin) /* connect to front */
  2488. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2489. }
  2490. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2491. {
  2492. struct alc_spec *spec = codec->spec;
  2493. int i;
  2494. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2495. hda_nid_t nid = spec->autocfg.input_pins[i];
  2496. if (alc880_is_input_pin(nid)) {
  2497. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2498. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2499. if (nid != ALC880_PIN_CD_NID)
  2500. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2501. AMP_OUT_MUTE);
  2502. }
  2503. }
  2504. }
  2505. /* parse the BIOS configuration and set up the alc_spec */
  2506. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2507. static int alc880_parse_auto_config(struct hda_codec *codec)
  2508. {
  2509. struct alc_spec *spec = codec->spec;
  2510. int err;
  2511. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2512. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2513. alc880_ignore)) < 0)
  2514. return err;
  2515. if (! spec->autocfg.line_outs)
  2516. return 0; /* can't find valid BIOS pin config */
  2517. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2518. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2519. (err = alc880_auto_create_extra_out(spec,
  2520. spec->autocfg.speaker_pins[0],
  2521. "Speaker")) < 0 ||
  2522. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2523. "Headphone")) < 0 ||
  2524. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2525. return err;
  2526. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2527. if (spec->autocfg.dig_out_pin)
  2528. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2529. if (spec->autocfg.dig_in_pin)
  2530. spec->dig_in_nid = ALC880_DIGIN_NID;
  2531. if (spec->kctl_alloc)
  2532. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2533. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2534. spec->num_mux_defs = 1;
  2535. spec->input_mux = &spec->private_imux;
  2536. return 1;
  2537. }
  2538. /* additional initialization for auto-configuration model */
  2539. static void alc880_auto_init(struct hda_codec *codec)
  2540. {
  2541. alc880_auto_init_multi_out(codec);
  2542. alc880_auto_init_extra_out(codec);
  2543. alc880_auto_init_analog_input(codec);
  2544. }
  2545. /*
  2546. * OK, here we have finally the patch for ALC880
  2547. */
  2548. static int patch_alc880(struct hda_codec *codec)
  2549. {
  2550. struct alc_spec *spec;
  2551. int board_config;
  2552. int err;
  2553. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2554. if (spec == NULL)
  2555. return -ENOMEM;
  2556. codec->spec = spec;
  2557. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2558. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2559. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2560. "trying auto-probe from BIOS...\n");
  2561. board_config = ALC880_AUTO;
  2562. }
  2563. if (board_config == ALC880_AUTO) {
  2564. /* automatic parse from the BIOS config */
  2565. err = alc880_parse_auto_config(codec);
  2566. if (err < 0) {
  2567. alc_free(codec);
  2568. return err;
  2569. } else if (! err) {
  2570. printk(KERN_INFO
  2571. "hda_codec: Cannot set up configuration "
  2572. "from BIOS. Using 3-stack mode...\n");
  2573. board_config = ALC880_3ST;
  2574. }
  2575. }
  2576. if (board_config != ALC880_AUTO)
  2577. setup_preset(spec, &alc880_presets[board_config]);
  2578. spec->stream_name_analog = "ALC880 Analog";
  2579. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2580. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2581. spec->stream_name_digital = "ALC880 Digital";
  2582. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2583. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2584. if (! spec->adc_nids && spec->input_mux) {
  2585. /* check whether NID 0x07 is valid */
  2586. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2587. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2588. if (wcap != AC_WID_AUD_IN) {
  2589. spec->adc_nids = alc880_adc_nids_alt;
  2590. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2591. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2592. spec->num_mixers++;
  2593. } else {
  2594. spec->adc_nids = alc880_adc_nids;
  2595. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2596. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2597. spec->num_mixers++;
  2598. }
  2599. }
  2600. codec->patch_ops = alc_patch_ops;
  2601. if (board_config == ALC880_AUTO)
  2602. spec->init_hook = alc880_auto_init;
  2603. return 0;
  2604. }
  2605. /*
  2606. * ALC260 support
  2607. */
  2608. static hda_nid_t alc260_dac_nids[1] = {
  2609. /* front */
  2610. 0x02,
  2611. };
  2612. static hda_nid_t alc260_adc_nids[1] = {
  2613. /* ADC0 */
  2614. 0x04,
  2615. };
  2616. static hda_nid_t alc260_adc_nids_alt[1] = {
  2617. /* ADC1 */
  2618. 0x05,
  2619. };
  2620. static hda_nid_t alc260_hp_adc_nids[2] = {
  2621. /* ADC1, 0 */
  2622. 0x05, 0x04
  2623. };
  2624. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2625. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2626. */
  2627. static hda_nid_t alc260_dual_adc_nids[2] = {
  2628. /* ADC0, ADC1 */
  2629. 0x04, 0x05
  2630. };
  2631. #define ALC260_DIGOUT_NID 0x03
  2632. #define ALC260_DIGIN_NID 0x06
  2633. static struct hda_input_mux alc260_capture_source = {
  2634. .num_items = 4,
  2635. .items = {
  2636. { "Mic", 0x0 },
  2637. { "Front Mic", 0x1 },
  2638. { "Line", 0x2 },
  2639. { "CD", 0x4 },
  2640. },
  2641. };
  2642. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2643. * headphone jack and the internal CD lines since these are the only pins at
  2644. * which audio can appear. For flexibility, also allow the option of
  2645. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2646. * connection to the mixer output).
  2647. */
  2648. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2649. {
  2650. .num_items = 3,
  2651. .items = {
  2652. { "Mic/Line", 0x0 },
  2653. { "CD", 0x4 },
  2654. { "Headphone", 0x2 },
  2655. },
  2656. },
  2657. {
  2658. .num_items = 4,
  2659. .items = {
  2660. { "Mic/Line", 0x0 },
  2661. { "CD", 0x4 },
  2662. { "Headphone", 0x2 },
  2663. { "Mixer", 0x5 },
  2664. },
  2665. },
  2666. };
  2667. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2668. * the Fujitsu S702x, but jacks are marked differently.
  2669. */
  2670. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2671. {
  2672. .num_items = 4,
  2673. .items = {
  2674. { "Mic", 0x0 },
  2675. { "Line", 0x2 },
  2676. { "CD", 0x4 },
  2677. { "Headphone", 0x5 },
  2678. },
  2679. },
  2680. {
  2681. .num_items = 5,
  2682. .items = {
  2683. { "Mic", 0x0 },
  2684. { "Line", 0x2 },
  2685. { "CD", 0x4 },
  2686. { "Headphone", 0x6 },
  2687. { "Mixer", 0x5 },
  2688. },
  2689. },
  2690. };
  2691. /*
  2692. * This is just place-holder, so there's something for alc_build_pcms to look
  2693. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2694. * element which allows changing the channel mode, so the verb list is
  2695. * never used.
  2696. */
  2697. static struct hda_channel_mode alc260_modes[1] = {
  2698. { 2, NULL },
  2699. };
  2700. /* Mixer combinations
  2701. *
  2702. * basic: base_output + input + pc_beep + capture
  2703. * HP: base_output + input + capture_alt
  2704. * HP_3013: hp_3013 + input + capture
  2705. * fujitsu: fujitsu + capture
  2706. * acer: acer + capture
  2707. */
  2708. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2709. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2710. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2711. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2712. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2713. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2714. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2715. { } /* end */
  2716. };
  2717. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2718. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2719. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2720. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2721. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2722. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2723. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2724. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2725. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2726. { } /* end */
  2727. };
  2728. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2729. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2730. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2731. { } /* end */
  2732. };
  2733. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2734. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2735. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2736. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2737. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2738. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2739. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2740. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2741. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2742. { } /* end */
  2743. };
  2744. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2745. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2746. */
  2747. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2748. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2749. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2750. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2751. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2752. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2753. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2754. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2755. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2756. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2757. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2758. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2759. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2760. { } /* end */
  2761. };
  2762. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2763. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2764. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2765. * datasheet doesn't mention this restriction. At this stage it's not clear
  2766. * whether this behaviour is intentional or is a hardware bug in chip
  2767. * revisions available in early 2006. Therefore for now allow the
  2768. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2769. * that the lack of mic bias for this NID is intentional we could change the
  2770. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2771. *
  2772. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2773. * don't appear to make the mic bias available from the "line" jack, even
  2774. * though the NID used for this jack (0x14) can supply it. The theory is
  2775. * that perhaps Acer have included blocking capacitors between the ALC260
  2776. * and the output jack. If this turns out to be the case for all such
  2777. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2778. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2779. */
  2780. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2781. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2782. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2783. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2784. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2785. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2786. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2787. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2788. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2789. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2790. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2791. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2792. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2793. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2794. { } /* end */
  2795. };
  2796. /* capture mixer elements */
  2797. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2798. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2799. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2800. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2801. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2802. {
  2803. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2804. /* The multiple "Capture Source" controls confuse alsamixer
  2805. * So call somewhat different..
  2806. * FIXME: the controls appear in the "playback" view!
  2807. */
  2808. /* .name = "Capture Source", */
  2809. .name = "Input Source",
  2810. .count = 2,
  2811. .info = alc_mux_enum_info,
  2812. .get = alc_mux_enum_get,
  2813. .put = alc_mux_enum_put,
  2814. },
  2815. { } /* end */
  2816. };
  2817. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2818. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2819. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2820. {
  2821. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2822. /* The multiple "Capture Source" controls confuse alsamixer
  2823. * So call somewhat different..
  2824. * FIXME: the controls appear in the "playback" view!
  2825. */
  2826. /* .name = "Capture Source", */
  2827. .name = "Input Source",
  2828. .count = 1,
  2829. .info = alc_mux_enum_info,
  2830. .get = alc_mux_enum_get,
  2831. .put = alc_mux_enum_put,
  2832. },
  2833. { } /* end */
  2834. };
  2835. /*
  2836. * initialization verbs
  2837. */
  2838. static struct hda_verb alc260_init_verbs[] = {
  2839. /* Line In pin widget for input */
  2840. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2841. /* CD pin widget for input */
  2842. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2843. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2844. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2845. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2846. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2847. /* LINE-2 is used for line-out in rear */
  2848. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2849. /* select line-out */
  2850. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2851. /* LINE-OUT pin */
  2852. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2853. /* enable HP */
  2854. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2855. /* enable Mono */
  2856. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2857. /* mute capture amp left and right */
  2858. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2859. /* set connection select to line in (default select for this ADC) */
  2860. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2861. /* mute capture amp left and right */
  2862. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2863. /* set connection select to line in (default select for this ADC) */
  2864. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2865. /* set vol=0 Line-Out mixer amp left and right */
  2866. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2867. /* unmute pin widget amp left and right (no gain on this amp) */
  2868. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2869. /* set vol=0 HP mixer amp left and right */
  2870. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2871. /* unmute pin widget amp left and right (no gain on this amp) */
  2872. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2873. /* set vol=0 Mono mixer amp left and right */
  2874. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2875. /* unmute pin widget amp left and right (no gain on this amp) */
  2876. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2877. /* unmute LINE-2 out pin */
  2878. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2879. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2880. /* mute CD */
  2881. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2882. /* mute Line In */
  2883. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2884. /* mute Mic */
  2885. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2886. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2887. /* mute Front out path */
  2888. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2889. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2890. /* mute Headphone out path */
  2891. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2892. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2893. /* mute Mono out path */
  2894. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2895. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2896. { }
  2897. };
  2898. #if 0 /* should be identical with alc260_init_verbs? */
  2899. static struct hda_verb alc260_hp_init_verbs[] = {
  2900. /* Headphone and output */
  2901. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2902. /* mono output */
  2903. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2904. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2905. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2906. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2907. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2908. /* Line In pin widget for input */
  2909. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2910. /* Line-2 pin widget for output */
  2911. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2912. /* CD pin widget for input */
  2913. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2914. /* unmute amp left and right */
  2915. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2916. /* set connection select to line in (default select for this ADC) */
  2917. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2918. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2920. /* mute pin widget amp left and right (no gain on this amp) */
  2921. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2922. /* unmute HP mixer amp left and right (volume = 0) */
  2923. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2924. /* mute pin widget amp left and right (no gain on this amp) */
  2925. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2926. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2927. /* unmute CD */
  2928. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2929. /* unmute Line In */
  2930. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2931. /* unmute Mic */
  2932. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2933. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2934. /* Unmute Front out path */
  2935. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2936. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2937. /* Unmute Headphone out path */
  2938. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2939. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2940. /* Unmute Mono out path */
  2941. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2942. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2943. { }
  2944. };
  2945. #endif
  2946. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2947. /* Line out and output */
  2948. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2949. /* mono output */
  2950. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2951. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2952. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2953. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2954. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2955. /* Line In pin widget for input */
  2956. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2957. /* Headphone pin widget for output */
  2958. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2959. /* CD pin widget for input */
  2960. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2961. /* unmute amp left and right */
  2962. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2963. /* set connection select to line in (default select for this ADC) */
  2964. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2965. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2966. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2967. /* mute pin widget amp left and right (no gain on this amp) */
  2968. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2969. /* unmute HP mixer amp left and right (volume = 0) */
  2970. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2971. /* mute pin widget amp left and right (no gain on this amp) */
  2972. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2973. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2974. /* unmute CD */
  2975. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2976. /* unmute Line In */
  2977. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2978. /* unmute Mic */
  2979. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2980. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2981. /* Unmute Front out path */
  2982. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2983. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2984. /* Unmute Headphone out path */
  2985. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2986. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2987. /* Unmute Mono out path */
  2988. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2989. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2990. { }
  2991. };
  2992. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2993. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  2994. * audio = 0x16, internal speaker = 0x10.
  2995. */
  2996. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2997. /* Disable all GPIOs */
  2998. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2999. /* Internal speaker is connected to headphone pin */
  3000. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3001. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3002. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3003. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3004. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3005. /* Ensure all other unused pins are disabled and muted. */
  3006. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3007. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3008. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3009. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3010. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3011. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3012. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3013. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3014. /* Disable digital (SPDIF) pins */
  3015. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3016. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3017. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3018. * when acting as an output.
  3019. */
  3020. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3021. /* Start with output sum widgets muted and their output gains at min */
  3022. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3023. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3024. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3025. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3026. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3027. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3028. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3029. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3030. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3031. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3032. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3033. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3034. * If the pin mode is changed by the user the pin mode control will
  3035. * take care of enabling the pin's input/output buffers as needed.
  3036. * Therefore there's no need to enable the input buffer at this
  3037. * stage.
  3038. */
  3039. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3040. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3041. * mixer ctrl)
  3042. */
  3043. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3044. /* Mute capture amp left and right */
  3045. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3046. /* Set ADC connection select to match default mixer setting - line
  3047. * in (on mic1 pin)
  3048. */
  3049. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3050. /* Do the same for the second ADC: mute capture input amp and
  3051. * set ADC connection to line in (on mic1 pin)
  3052. */
  3053. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3054. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3055. /* Mute all inputs to mixer widget (even unconnected ones) */
  3056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3064. { }
  3065. };
  3066. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3067. * similar laptops (adapted from Fujitsu init verbs).
  3068. */
  3069. static struct hda_verb alc260_acer_init_verbs[] = {
  3070. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3071. * the headphone jack. Turn this on and rely on the standard mute
  3072. * methods whenever the user wants to turn these outputs off.
  3073. */
  3074. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3075. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3076. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3077. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3078. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3079. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3080. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3081. /* Line In jack is connected to Line1 pin */
  3082. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3083. /* Ensure all other unused pins are disabled and muted. */
  3084. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3085. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3086. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3087. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3088. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3089. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3090. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3091. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3092. /* Disable digital (SPDIF) pins */
  3093. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3094. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3095. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3096. * bus when acting as outputs.
  3097. */
  3098. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3099. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3100. /* Start with output sum widgets muted and their output gains at min */
  3101. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3102. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3103. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3104. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3105. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3106. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3107. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3108. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3109. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3110. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3111. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3112. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3113. * inputs. If the pin mode is changed by the user the pin mode control
  3114. * will take care of enabling the pin's input/output buffers as needed.
  3115. * Therefore there's no need to enable the input buffer at this
  3116. * stage.
  3117. */
  3118. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3119. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3120. /* Mute capture amp left and right */
  3121. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3122. /* Set ADC connection select to match default mixer setting - mic
  3123. * (on mic1 pin)
  3124. */
  3125. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3126. /* Do similar with the second ADC: mute capture input amp and
  3127. * set ADC connection to mic to match ALSA's default state.
  3128. */
  3129. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3130. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3131. /* Mute all inputs to mixer widget (even unconnected ones) */
  3132. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3134. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3135. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3136. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3137. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3138. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3139. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3140. { }
  3141. };
  3142. /* Test configuration for debugging, modelled after the ALC880 test
  3143. * configuration.
  3144. */
  3145. #ifdef CONFIG_SND_DEBUG
  3146. static hda_nid_t alc260_test_dac_nids[1] = {
  3147. 0x02,
  3148. };
  3149. static hda_nid_t alc260_test_adc_nids[2] = {
  3150. 0x04, 0x05,
  3151. };
  3152. /* For testing the ALC260, each input MUX needs its own definition since
  3153. * the signal assignments are different. This assumes that the first ADC
  3154. * is NID 0x04.
  3155. */
  3156. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3157. {
  3158. .num_items = 7,
  3159. .items = {
  3160. { "MIC1 pin", 0x0 },
  3161. { "MIC2 pin", 0x1 },
  3162. { "LINE1 pin", 0x2 },
  3163. { "LINE2 pin", 0x3 },
  3164. { "CD pin", 0x4 },
  3165. { "LINE-OUT pin", 0x5 },
  3166. { "HP-OUT pin", 0x6 },
  3167. },
  3168. },
  3169. {
  3170. .num_items = 8,
  3171. .items = {
  3172. { "MIC1 pin", 0x0 },
  3173. { "MIC2 pin", 0x1 },
  3174. { "LINE1 pin", 0x2 },
  3175. { "LINE2 pin", 0x3 },
  3176. { "CD pin", 0x4 },
  3177. { "Mixer", 0x5 },
  3178. { "LINE-OUT pin", 0x6 },
  3179. { "HP-OUT pin", 0x7 },
  3180. },
  3181. },
  3182. };
  3183. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3184. /* Output driver widgets */
  3185. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3186. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3187. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3188. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3190. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3191. /* Modes for retasking pin widgets
  3192. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3193. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3194. * mention this restriction. At this stage it's not clear whether
  3195. * this behaviour is intentional or is a hardware bug in chip
  3196. * revisions available at least up until early 2006. Therefore for
  3197. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3198. * choices, but if it turns out that the lack of mic bias for these
  3199. * NIDs is intentional we could change their modes from
  3200. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3201. */
  3202. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3203. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3204. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3205. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3206. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3207. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3208. /* Loopback mixer controls */
  3209. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3210. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3211. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3212. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3213. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3214. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3215. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3216. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3217. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3218. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3219. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3220. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3222. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3224. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3225. /* Controls for GPIO pins, assuming they are configured as outputs */
  3226. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3227. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3228. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3229. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3230. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3231. * is ambigious as to which NID is which; testing on laptops which
  3232. * make this output available should provide clarification.
  3233. */
  3234. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3235. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3236. { } /* end */
  3237. };
  3238. static struct hda_verb alc260_test_init_verbs[] = {
  3239. /* Enable all GPIOs as outputs with an initial value of 0 */
  3240. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3241. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3242. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3243. /* Enable retasking pins as output, initially without power amp */
  3244. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3245. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3246. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3248. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3249. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3250. /* Disable digital (SPDIF) pins initially, but users can enable
  3251. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3252. * payload also sets the generation to 0, output to be in "consumer"
  3253. * PCM format, copyright asserted, no pre-emphasis and no validity
  3254. * control.
  3255. */
  3256. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3257. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3258. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3259. * OUT1 sum bus when acting as an output.
  3260. */
  3261. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3262. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3263. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3264. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3265. /* Start with output sum widgets muted and their output gains at min */
  3266. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3268. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3269. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3270. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3272. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3273. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3274. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3275. /* Unmute retasking pin widget output buffers since the default
  3276. * state appears to be output. As the pin mode is changed by the
  3277. * user the pin mode control will take care of enabling the pin's
  3278. * input/output buffers as needed.
  3279. */
  3280. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3281. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3282. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3284. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3285. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3286. /* Also unmute the mono-out pin widget */
  3287. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3288. /* Mute capture amp left and right */
  3289. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3290. /* Set ADC connection select to match default mixer setting (mic1
  3291. * pin)
  3292. */
  3293. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3294. /* Do the same for the second ADC: mute capture input amp and
  3295. * set ADC connection to mic1 pin
  3296. */
  3297. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3298. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3299. /* Mute all inputs to mixer widget (even unconnected ones) */
  3300. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3301. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3302. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3303. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3304. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3305. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3306. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3308. { }
  3309. };
  3310. #endif
  3311. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3312. .substreams = 1,
  3313. .channels_min = 2,
  3314. .channels_max = 2,
  3315. };
  3316. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3317. .substreams = 1,
  3318. .channels_min = 2,
  3319. .channels_max = 2,
  3320. };
  3321. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3322. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3323. /*
  3324. * for BIOS auto-configuration
  3325. */
  3326. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3327. const char *pfx)
  3328. {
  3329. hda_nid_t nid_vol;
  3330. unsigned long vol_val, sw_val;
  3331. char name[32];
  3332. int err;
  3333. if (nid >= 0x0f && nid < 0x11) {
  3334. nid_vol = nid - 0x7;
  3335. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3336. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3337. } else if (nid == 0x11) {
  3338. nid_vol = nid - 0x7;
  3339. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3340. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3341. } else if (nid >= 0x12 && nid <= 0x15) {
  3342. nid_vol = 0x08;
  3343. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3344. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3345. } else
  3346. return 0; /* N/A */
  3347. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3348. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3349. return err;
  3350. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3351. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3352. return err;
  3353. return 1;
  3354. }
  3355. /* add playback controls from the parsed DAC table */
  3356. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3357. const struct auto_pin_cfg *cfg)
  3358. {
  3359. hda_nid_t nid;
  3360. int err;
  3361. spec->multiout.num_dacs = 1;
  3362. spec->multiout.dac_nids = spec->private_dac_nids;
  3363. spec->multiout.dac_nids[0] = 0x02;
  3364. nid = cfg->line_out_pins[0];
  3365. if (nid) {
  3366. err = alc260_add_playback_controls(spec, nid, "Front");
  3367. if (err < 0)
  3368. return err;
  3369. }
  3370. nid = cfg->speaker_pins[0];
  3371. if (nid) {
  3372. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3373. if (err < 0)
  3374. return err;
  3375. }
  3376. nid = cfg->hp_pins[0];
  3377. if (nid) {
  3378. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3379. if (err < 0)
  3380. return err;
  3381. }
  3382. return 0;
  3383. }
  3384. /* create playback/capture controls for input pins */
  3385. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3386. const struct auto_pin_cfg *cfg)
  3387. {
  3388. struct hda_input_mux *imux = &spec->private_imux;
  3389. int i, err, idx;
  3390. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3391. if (cfg->input_pins[i] >= 0x12) {
  3392. idx = cfg->input_pins[i] - 0x12;
  3393. err = new_analog_input(spec, cfg->input_pins[i],
  3394. auto_pin_cfg_labels[i], idx, 0x07);
  3395. if (err < 0)
  3396. return err;
  3397. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3398. imux->items[imux->num_items].index = idx;
  3399. imux->num_items++;
  3400. }
  3401. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3402. idx = cfg->input_pins[i] - 0x09;
  3403. err = new_analog_input(spec, cfg->input_pins[i],
  3404. auto_pin_cfg_labels[i], idx, 0x07);
  3405. if (err < 0)
  3406. return err;
  3407. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3408. imux->items[imux->num_items].index = idx;
  3409. imux->num_items++;
  3410. }
  3411. }
  3412. return 0;
  3413. }
  3414. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3415. hda_nid_t nid, int pin_type,
  3416. int sel_idx)
  3417. {
  3418. /* set as output */
  3419. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3420. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3421. /* need the manual connection? */
  3422. if (nid >= 0x12) {
  3423. int idx = nid - 0x12;
  3424. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3425. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3426. }
  3427. }
  3428. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3429. {
  3430. struct alc_spec *spec = codec->spec;
  3431. hda_nid_t nid;
  3432. nid = spec->autocfg.line_out_pins[0];
  3433. if (nid)
  3434. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3435. nid = spec->autocfg.speaker_pins[0];
  3436. if (nid)
  3437. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3438. nid = spec->autocfg.hp_pins[0];
  3439. if (nid)
  3440. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3441. }
  3442. #define ALC260_PIN_CD_NID 0x16
  3443. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3444. {
  3445. struct alc_spec *spec = codec->spec;
  3446. int i;
  3447. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3448. hda_nid_t nid = spec->autocfg.input_pins[i];
  3449. if (nid >= 0x12) {
  3450. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3451. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3452. if (nid != ALC260_PIN_CD_NID)
  3453. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3454. AMP_OUT_MUTE);
  3455. }
  3456. }
  3457. }
  3458. /*
  3459. * generic initialization of ADC, input mixers and output mixers
  3460. */
  3461. static struct hda_verb alc260_volume_init_verbs[] = {
  3462. /*
  3463. * Unmute ADC0-1 and set the default input to mic-in
  3464. */
  3465. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3466. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3467. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3468. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3469. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3470. * mixer widget
  3471. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3472. * mic (mic 2)
  3473. */
  3474. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3475. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3476. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3480. /*
  3481. * Set up output mixers (0x08 - 0x0a)
  3482. */
  3483. /* set vol=0 to output mixers */
  3484. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3486. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3487. /* set up input amps for analog loopback */
  3488. /* Amp Indices: DAC = 0, mixer = 1 */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3491. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3493. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3494. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3495. { }
  3496. };
  3497. static int alc260_parse_auto_config(struct hda_codec *codec)
  3498. {
  3499. struct alc_spec *spec = codec->spec;
  3500. unsigned int wcap;
  3501. int err;
  3502. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3503. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3504. alc260_ignore)) < 0)
  3505. return err;
  3506. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3507. return err;
  3508. if (! spec->kctl_alloc)
  3509. return 0; /* can't find valid BIOS pin config */
  3510. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3511. return err;
  3512. spec->multiout.max_channels = 2;
  3513. if (spec->autocfg.dig_out_pin)
  3514. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3515. if (spec->kctl_alloc)
  3516. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3517. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3518. spec->num_mux_defs = 1;
  3519. spec->input_mux = &spec->private_imux;
  3520. /* check whether NID 0x04 is valid */
  3521. wcap = get_wcaps(codec, 0x04);
  3522. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3523. if (wcap != AC_WID_AUD_IN) {
  3524. spec->adc_nids = alc260_adc_nids_alt;
  3525. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3526. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3527. } else {
  3528. spec->adc_nids = alc260_adc_nids;
  3529. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3530. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3531. }
  3532. spec->num_mixers++;
  3533. return 1;
  3534. }
  3535. /* additional initialization for auto-configuration model */
  3536. static void alc260_auto_init(struct hda_codec *codec)
  3537. {
  3538. alc260_auto_init_multi_out(codec);
  3539. alc260_auto_init_analog_input(codec);
  3540. }
  3541. /*
  3542. * ALC260 configurations
  3543. */
  3544. static struct hda_board_config alc260_cfg_tbl[] = {
  3545. { .modelname = "basic", .config = ALC260_BASIC },
  3546. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3547. .config = ALC260_BASIC }, /* Sony VAIO */
  3548. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
  3549. .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
  3550. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
  3551. .config = ALC260_BASIC }, /* Sony VAIO */
  3552. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3553. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3554. { .modelname = "hp", .config = ALC260_HP },
  3555. { .modelname = "hp-3013", .config = ALC260_HP_3013 },
  3556. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
  3557. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3558. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
  3559. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3560. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3561. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3562. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3563. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3564. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3565. { .modelname = "acer", .config = ALC260_ACER },
  3566. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3567. #ifdef CONFIG_SND_DEBUG
  3568. { .modelname = "test", .config = ALC260_TEST },
  3569. #endif
  3570. { .modelname = "auto", .config = ALC260_AUTO },
  3571. {}
  3572. };
  3573. static struct alc_config_preset alc260_presets[] = {
  3574. [ALC260_BASIC] = {
  3575. .mixers = { alc260_base_output_mixer,
  3576. alc260_input_mixer,
  3577. alc260_pc_beep_mixer,
  3578. alc260_capture_mixer },
  3579. .init_verbs = { alc260_init_verbs },
  3580. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3581. .dac_nids = alc260_dac_nids,
  3582. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3583. .adc_nids = alc260_adc_nids,
  3584. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3585. .channel_mode = alc260_modes,
  3586. .input_mux = &alc260_capture_source,
  3587. },
  3588. [ALC260_HP] = {
  3589. .mixers = { alc260_base_output_mixer,
  3590. alc260_input_mixer,
  3591. alc260_capture_alt_mixer },
  3592. .init_verbs = { alc260_init_verbs },
  3593. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3594. .dac_nids = alc260_dac_nids,
  3595. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3596. .adc_nids = alc260_hp_adc_nids,
  3597. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3598. .channel_mode = alc260_modes,
  3599. .input_mux = &alc260_capture_source,
  3600. },
  3601. [ALC260_HP_3013] = {
  3602. .mixers = { alc260_hp_3013_mixer,
  3603. alc260_input_mixer,
  3604. alc260_capture_alt_mixer },
  3605. .init_verbs = { alc260_hp_3013_init_verbs },
  3606. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3607. .dac_nids = alc260_dac_nids,
  3608. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3609. .adc_nids = alc260_hp_adc_nids,
  3610. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3611. .channel_mode = alc260_modes,
  3612. .input_mux = &alc260_capture_source,
  3613. },
  3614. [ALC260_FUJITSU_S702X] = {
  3615. .mixers = { alc260_fujitsu_mixer,
  3616. alc260_capture_mixer },
  3617. .init_verbs = { alc260_fujitsu_init_verbs },
  3618. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3619. .dac_nids = alc260_dac_nids,
  3620. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3621. .adc_nids = alc260_dual_adc_nids,
  3622. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3623. .channel_mode = alc260_modes,
  3624. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3625. .input_mux = alc260_fujitsu_capture_sources,
  3626. },
  3627. [ALC260_ACER] = {
  3628. .mixers = { alc260_acer_mixer,
  3629. alc260_capture_mixer },
  3630. .init_verbs = { alc260_acer_init_verbs },
  3631. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3632. .dac_nids = alc260_dac_nids,
  3633. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3634. .adc_nids = alc260_dual_adc_nids,
  3635. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3636. .channel_mode = alc260_modes,
  3637. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3638. .input_mux = alc260_acer_capture_sources,
  3639. },
  3640. #ifdef CONFIG_SND_DEBUG
  3641. [ALC260_TEST] = {
  3642. .mixers = { alc260_test_mixer,
  3643. alc260_capture_mixer },
  3644. .init_verbs = { alc260_test_init_verbs },
  3645. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3646. .dac_nids = alc260_test_dac_nids,
  3647. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3648. .adc_nids = alc260_test_adc_nids,
  3649. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3650. .channel_mode = alc260_modes,
  3651. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3652. .input_mux = alc260_test_capture_sources,
  3653. },
  3654. #endif
  3655. };
  3656. static int patch_alc260(struct hda_codec *codec)
  3657. {
  3658. struct alc_spec *spec;
  3659. int err, board_config;
  3660. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3661. if (spec == NULL)
  3662. return -ENOMEM;
  3663. codec->spec = spec;
  3664. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3665. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3666. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3667. "trying auto-probe from BIOS...\n");
  3668. board_config = ALC260_AUTO;
  3669. }
  3670. if (board_config == ALC260_AUTO) {
  3671. /* automatic parse from the BIOS config */
  3672. err = alc260_parse_auto_config(codec);
  3673. if (err < 0) {
  3674. alc_free(codec);
  3675. return err;
  3676. } else if (! err) {
  3677. printk(KERN_INFO
  3678. "hda_codec: Cannot set up configuration "
  3679. "from BIOS. Using base mode...\n");
  3680. board_config = ALC260_BASIC;
  3681. }
  3682. }
  3683. if (board_config != ALC260_AUTO)
  3684. setup_preset(spec, &alc260_presets[board_config]);
  3685. spec->stream_name_analog = "ALC260 Analog";
  3686. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3687. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3688. spec->stream_name_digital = "ALC260 Digital";
  3689. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3690. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3691. codec->patch_ops = alc_patch_ops;
  3692. if (board_config == ALC260_AUTO)
  3693. spec->init_hook = alc260_auto_init;
  3694. return 0;
  3695. }
  3696. /*
  3697. * ALC882 support
  3698. *
  3699. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3700. * configuration. Each pin widget can choose any input DACs and a mixer.
  3701. * Each ADC is connected from a mixer of all inputs. This makes possible
  3702. * 6-channel independent captures.
  3703. *
  3704. * In addition, an independent DAC for the multi-playback (not used in this
  3705. * driver yet).
  3706. */
  3707. #define ALC882_DIGOUT_NID 0x06
  3708. #define ALC882_DIGIN_NID 0x0a
  3709. static struct hda_channel_mode alc882_ch_modes[1] = {
  3710. { 8, NULL }
  3711. };
  3712. static hda_nid_t alc882_dac_nids[4] = {
  3713. /* front, rear, clfe, rear_surr */
  3714. 0x02, 0x03, 0x04, 0x05
  3715. };
  3716. /* identical with ALC880 */
  3717. #define alc882_adc_nids alc880_adc_nids
  3718. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3719. /* input MUX */
  3720. /* FIXME: should be a matrix-type input source selection */
  3721. static struct hda_input_mux alc882_capture_source = {
  3722. .num_items = 4,
  3723. .items = {
  3724. { "Mic", 0x0 },
  3725. { "Front Mic", 0x1 },
  3726. { "Line", 0x2 },
  3727. { "CD", 0x4 },
  3728. },
  3729. };
  3730. #define alc882_mux_enum_info alc_mux_enum_info
  3731. #define alc882_mux_enum_get alc_mux_enum_get
  3732. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3733. {
  3734. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3735. struct alc_spec *spec = codec->spec;
  3736. const struct hda_input_mux *imux = spec->input_mux;
  3737. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3738. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3739. hda_nid_t nid = capture_mixers[adc_idx];
  3740. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3741. unsigned int i, idx;
  3742. idx = ucontrol->value.enumerated.item[0];
  3743. if (idx >= imux->num_items)
  3744. idx = imux->num_items - 1;
  3745. if (*cur_val == idx && ! codec->in_resume)
  3746. return 0;
  3747. for (i = 0; i < imux->num_items; i++) {
  3748. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3749. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3750. v | (imux->items[i].index << 8));
  3751. }
  3752. *cur_val = idx;
  3753. return 1;
  3754. }
  3755. /*
  3756. * 6ch mode
  3757. */
  3758. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3759. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3760. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3761. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3762. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3763. { } /* end */
  3764. };
  3765. /*
  3766. * 8ch mode
  3767. */
  3768. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3769. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3770. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3771. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3772. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3773. { } /* end */
  3774. };
  3775. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3776. { 6, alc882_sixstack_ch6_init },
  3777. { 8, alc882_sixstack_ch8_init },
  3778. };
  3779. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3780. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3781. */
  3782. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3783. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3784. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3786. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3787. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3788. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3789. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3790. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3791. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3792. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3793. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3794. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3795. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3796. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3797. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3798. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3799. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3800. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3801. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3802. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3803. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3804. { } /* end */
  3805. };
  3806. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3807. {
  3808. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3809. .name = "Channel Mode",
  3810. .info = alc_ch_mode_info,
  3811. .get = alc_ch_mode_get,
  3812. .put = alc_ch_mode_put,
  3813. },
  3814. { } /* end */
  3815. };
  3816. static struct hda_verb alc882_init_verbs[] = {
  3817. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3821. /* Rear mixer */
  3822. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3823. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3824. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3825. /* CLFE mixer */
  3826. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3827. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3828. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3829. /* Side mixer */
  3830. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3831. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3832. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3833. /* Front Pin: output 0 (0x0c) */
  3834. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3835. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3836. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3837. /* Rear Pin: output 1 (0x0d) */
  3838. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3839. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3840. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3841. /* CLFE Pin: output 2 (0x0e) */
  3842. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3843. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3845. /* Side Pin: output 3 (0x0f) */
  3846. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3847. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3849. /* Mic (rear) pin: input vref at 80% */
  3850. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3851. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3852. /* Front Mic pin: input vref at 80% */
  3853. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3854. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3855. /* Line In pin: input */
  3856. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3857. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3858. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3859. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3860. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3861. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* CD pin widget for input */
  3863. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3864. /* FIXME: use matrix-type input source selection */
  3865. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3866. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3867. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3868. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3869. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3870. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3871. /* Input mixer2 */
  3872. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3873. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3874. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3875. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3876. /* Input mixer3 */
  3877. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3878. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3879. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3880. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3881. /* ADC1: mute amp left and right */
  3882. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3883. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3884. /* ADC2: mute amp left and right */
  3885. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3886. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3887. /* ADC3: mute amp left and right */
  3888. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3889. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3890. { }
  3891. };
  3892. static struct hda_verb alc882_eapd_verbs[] = {
  3893. /* change to EAPD mode */
  3894. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  3895. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  3896. { }
  3897. };
  3898. /*
  3899. * generic initialization of ADC, input mixers and output mixers
  3900. */
  3901. static struct hda_verb alc882_auto_init_verbs[] = {
  3902. /*
  3903. * Unmute ADC0-2 and set the default input to mic-in
  3904. */
  3905. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3906. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3907. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3908. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3909. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3910. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3911. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3912. * mixer widget
  3913. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3914. * mic (mic 2)
  3915. */
  3916. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3920. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3921. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3922. /*
  3923. * Set up output mixers (0x0c - 0x0f)
  3924. */
  3925. /* set vol=0 to output mixers */
  3926. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3927. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3928. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3929. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3930. /* set up input amps for analog loopback */
  3931. /* Amp Indices: DAC = 0, mixer = 1 */
  3932. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3933. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3934. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3935. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3936. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3938. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3939. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3940. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3941. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3942. /* FIXME: use matrix-type input source selection */
  3943. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3944. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3945. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3946. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3947. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3949. /* Input mixer2 */
  3950. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3951. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3954. /* Input mixer3 */
  3955. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3956. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3959. { }
  3960. };
  3961. /* capture mixer elements */
  3962. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3963. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3964. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3965. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3966. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3967. {
  3968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3969. /* The multiple "Capture Source" controls confuse alsamixer
  3970. * So call somewhat different..
  3971. * FIXME: the controls appear in the "playback" view!
  3972. */
  3973. /* .name = "Capture Source", */
  3974. .name = "Input Source",
  3975. .count = 2,
  3976. .info = alc882_mux_enum_info,
  3977. .get = alc882_mux_enum_get,
  3978. .put = alc882_mux_enum_put,
  3979. },
  3980. { } /* end */
  3981. };
  3982. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3983. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3984. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3985. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3986. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3987. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3988. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3989. {
  3990. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3991. /* The multiple "Capture Source" controls confuse alsamixer
  3992. * So call somewhat different..
  3993. * FIXME: the controls appear in the "playback" view!
  3994. */
  3995. /* .name = "Capture Source", */
  3996. .name = "Input Source",
  3997. .count = 3,
  3998. .info = alc882_mux_enum_info,
  3999. .get = alc882_mux_enum_get,
  4000. .put = alc882_mux_enum_put,
  4001. },
  4002. { } /* end */
  4003. };
  4004. /* pcm configuration: identiacal with ALC880 */
  4005. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4006. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4007. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4008. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4009. /*
  4010. * configuration and preset
  4011. */
  4012. static struct hda_board_config alc882_cfg_tbl[] = {
  4013. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  4014. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  4015. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4016. .config = ALC882_6ST_DIG }, /* MSI */
  4017. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4018. .config = ALC882_6ST_DIG }, /* Foxconn */
  4019. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4020. .config = ALC882_6ST_DIG }, /* ECS to Intel*/
  4021. { .modelname = "arima", .config = ALC882_ARIMA },
  4022. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4023. .config = ALC882_ARIMA }, /* Arima W820Di1 */
  4024. { .modelname = "auto", .config = ALC882_AUTO },
  4025. {}
  4026. };
  4027. static struct alc_config_preset alc882_presets[] = {
  4028. [ALC882_3ST_DIG] = {
  4029. .mixers = { alc882_base_mixer },
  4030. .init_verbs = { alc882_init_verbs },
  4031. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4032. .dac_nids = alc882_dac_nids,
  4033. .dig_out_nid = ALC882_DIGOUT_NID,
  4034. .dig_in_nid = ALC882_DIGIN_NID,
  4035. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4036. .channel_mode = alc882_ch_modes,
  4037. .need_dac_fix = 1,
  4038. .input_mux = &alc882_capture_source,
  4039. },
  4040. [ALC882_6ST_DIG] = {
  4041. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4042. .init_verbs = { alc882_init_verbs },
  4043. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4044. .dac_nids = alc882_dac_nids,
  4045. .dig_out_nid = ALC882_DIGOUT_NID,
  4046. .dig_in_nid = ALC882_DIGIN_NID,
  4047. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4048. .channel_mode = alc882_sixstack_modes,
  4049. .input_mux = &alc882_capture_source,
  4050. },
  4051. [ALC882_ARIMA] = {
  4052. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4053. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4054. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4055. .dac_nids = alc882_dac_nids,
  4056. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4057. .channel_mode = alc882_sixstack_modes,
  4058. .input_mux = &alc882_capture_source,
  4059. },
  4060. };
  4061. /*
  4062. * BIOS auto configuration
  4063. */
  4064. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4065. hda_nid_t nid, int pin_type,
  4066. int dac_idx)
  4067. {
  4068. /* set as output */
  4069. struct alc_spec *spec = codec->spec;
  4070. int idx;
  4071. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4072. idx = 4;
  4073. else
  4074. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4075. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4076. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4077. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4078. }
  4079. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4080. {
  4081. struct alc_spec *spec = codec->spec;
  4082. int i;
  4083. for (i = 0; i <= HDA_SIDE; i++) {
  4084. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4085. if (nid)
  4086. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4087. }
  4088. }
  4089. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4090. {
  4091. struct alc_spec *spec = codec->spec;
  4092. hda_nid_t pin;
  4093. pin = spec->autocfg.hp_pins[0];
  4094. if (pin) /* connect to front */
  4095. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4096. }
  4097. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4098. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4099. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4100. {
  4101. struct alc_spec *spec = codec->spec;
  4102. int i;
  4103. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4104. hda_nid_t nid = spec->autocfg.input_pins[i];
  4105. if (alc882_is_input_pin(nid)) {
  4106. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4107. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4108. if (nid != ALC882_PIN_CD_NID)
  4109. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4110. AMP_OUT_MUTE);
  4111. }
  4112. }
  4113. }
  4114. /* almost identical with ALC880 parser... */
  4115. static int alc882_parse_auto_config(struct hda_codec *codec)
  4116. {
  4117. struct alc_spec *spec = codec->spec;
  4118. int err = alc880_parse_auto_config(codec);
  4119. if (err < 0)
  4120. return err;
  4121. else if (err > 0)
  4122. /* hack - override the init verbs */
  4123. spec->init_verbs[0] = alc882_auto_init_verbs;
  4124. return err;
  4125. }
  4126. /* additional initialization for auto-configuration model */
  4127. static void alc882_auto_init(struct hda_codec *codec)
  4128. {
  4129. alc882_auto_init_multi_out(codec);
  4130. alc882_auto_init_hp_out(codec);
  4131. alc882_auto_init_analog_input(codec);
  4132. }
  4133. static int patch_alc882(struct hda_codec *codec)
  4134. {
  4135. struct alc_spec *spec;
  4136. int err, board_config;
  4137. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4138. if (spec == NULL)
  4139. return -ENOMEM;
  4140. codec->spec = spec;
  4141. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  4142. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4143. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4144. "trying auto-probe from BIOS...\n");
  4145. board_config = ALC882_AUTO;
  4146. }
  4147. if (board_config == ALC882_AUTO) {
  4148. /* automatic parse from the BIOS config */
  4149. err = alc882_parse_auto_config(codec);
  4150. if (err < 0) {
  4151. alc_free(codec);
  4152. return err;
  4153. } else if (! err) {
  4154. printk(KERN_INFO
  4155. "hda_codec: Cannot set up configuration "
  4156. "from BIOS. Using base mode...\n");
  4157. board_config = ALC882_3ST_DIG;
  4158. }
  4159. }
  4160. if (board_config != ALC882_AUTO)
  4161. setup_preset(spec, &alc882_presets[board_config]);
  4162. spec->stream_name_analog = "ALC882 Analog";
  4163. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4164. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4165. spec->stream_name_digital = "ALC882 Digital";
  4166. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4167. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4168. if (! spec->adc_nids && spec->input_mux) {
  4169. /* check whether NID 0x07 is valid */
  4170. unsigned int wcap = get_wcaps(codec, 0x07);
  4171. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4172. if (wcap != AC_WID_AUD_IN) {
  4173. spec->adc_nids = alc882_adc_nids_alt;
  4174. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4175. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4176. spec->num_mixers++;
  4177. } else {
  4178. spec->adc_nids = alc882_adc_nids;
  4179. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4180. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4181. spec->num_mixers++;
  4182. }
  4183. }
  4184. codec->patch_ops = alc_patch_ops;
  4185. if (board_config == ALC882_AUTO)
  4186. spec->init_hook = alc882_auto_init;
  4187. return 0;
  4188. }
  4189. /*
  4190. * ALC883 support
  4191. *
  4192. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4193. * configuration. Each pin widget can choose any input DACs and a mixer.
  4194. * Each ADC is connected from a mixer of all inputs. This makes possible
  4195. * 6-channel independent captures.
  4196. *
  4197. * In addition, an independent DAC for the multi-playback (not used in this
  4198. * driver yet).
  4199. */
  4200. #define ALC883_DIGOUT_NID 0x06
  4201. #define ALC883_DIGIN_NID 0x0a
  4202. static hda_nid_t alc883_dac_nids[4] = {
  4203. /* front, rear, clfe, rear_surr */
  4204. 0x02, 0x04, 0x03, 0x05
  4205. };
  4206. static hda_nid_t alc883_adc_nids[2] = {
  4207. /* ADC1-2 */
  4208. 0x08, 0x09,
  4209. };
  4210. /* input MUX */
  4211. /* FIXME: should be a matrix-type input source selection */
  4212. static struct hda_input_mux alc883_capture_source = {
  4213. .num_items = 4,
  4214. .items = {
  4215. { "Mic", 0x0 },
  4216. { "Front Mic", 0x1 },
  4217. { "Line", 0x2 },
  4218. { "CD", 0x4 },
  4219. },
  4220. };
  4221. #define alc883_mux_enum_info alc_mux_enum_info
  4222. #define alc883_mux_enum_get alc_mux_enum_get
  4223. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4224. struct snd_ctl_elem_value *ucontrol)
  4225. {
  4226. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4227. struct alc_spec *spec = codec->spec;
  4228. const struct hda_input_mux *imux = spec->input_mux;
  4229. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4230. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4231. hda_nid_t nid = capture_mixers[adc_idx];
  4232. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4233. unsigned int i, idx;
  4234. idx = ucontrol->value.enumerated.item[0];
  4235. if (idx >= imux->num_items)
  4236. idx = imux->num_items - 1;
  4237. if (*cur_val == idx && ! codec->in_resume)
  4238. return 0;
  4239. for (i = 0; i < imux->num_items; i++) {
  4240. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4241. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4242. v | (imux->items[i].index << 8));
  4243. }
  4244. *cur_val = idx;
  4245. return 1;
  4246. }
  4247. /*
  4248. * 2ch mode
  4249. */
  4250. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4251. { 2, NULL }
  4252. };
  4253. /*
  4254. * 2ch mode
  4255. */
  4256. static struct hda_verb alc883_3ST_ch2_init[] = {
  4257. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4258. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4259. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4260. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4261. { } /* end */
  4262. };
  4263. /*
  4264. * 6ch mode
  4265. */
  4266. static struct hda_verb alc883_3ST_ch6_init[] = {
  4267. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4268. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4269. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4270. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4271. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4272. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4273. { } /* end */
  4274. };
  4275. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4276. { 2, alc883_3ST_ch2_init },
  4277. { 6, alc883_3ST_ch6_init },
  4278. };
  4279. /*
  4280. * 6ch mode
  4281. */
  4282. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4283. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4284. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4285. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4286. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4287. { } /* end */
  4288. };
  4289. /*
  4290. * 8ch mode
  4291. */
  4292. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4293. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4294. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4295. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4296. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4297. { } /* end */
  4298. };
  4299. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4300. { 6, alc883_sixstack_ch6_init },
  4301. { 8, alc883_sixstack_ch8_init },
  4302. };
  4303. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4304. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4305. */
  4306. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4307. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4308. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4309. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4310. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4311. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4312. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4313. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4314. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4315. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4316. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4317. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4318. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4319. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4320. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4321. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4322. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4323. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4324. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4325. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4326. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4327. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4328. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4329. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4330. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4331. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4332. {
  4333. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4334. /* .name = "Capture Source", */
  4335. .name = "Input Source",
  4336. .count = 2,
  4337. .info = alc883_mux_enum_info,
  4338. .get = alc883_mux_enum_get,
  4339. .put = alc883_mux_enum_put,
  4340. },
  4341. { } /* end */
  4342. };
  4343. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4344. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4345. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4346. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4347. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4348. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4349. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4350. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4351. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4352. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4353. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4354. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4355. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4356. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4357. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4358. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4359. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4360. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4361. {
  4362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4363. /* .name = "Capture Source", */
  4364. .name = "Input Source",
  4365. .count = 2,
  4366. .info = alc883_mux_enum_info,
  4367. .get = alc883_mux_enum_get,
  4368. .put = alc883_mux_enum_put,
  4369. },
  4370. { } /* end */
  4371. };
  4372. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4374. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4375. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4376. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4378. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4379. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4380. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4381. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4382. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4383. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4385. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4386. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4387. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4391. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4392. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4393. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4394. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4395. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4396. {
  4397. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4398. /* .name = "Capture Source", */
  4399. .name = "Input Source",
  4400. .count = 2,
  4401. .info = alc883_mux_enum_info,
  4402. .get = alc883_mux_enum_get,
  4403. .put = alc883_mux_enum_put,
  4404. },
  4405. { } /* end */
  4406. };
  4407. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4408. {
  4409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4410. .name = "Channel Mode",
  4411. .info = alc_ch_mode_info,
  4412. .get = alc_ch_mode_get,
  4413. .put = alc_ch_mode_put,
  4414. },
  4415. { } /* end */
  4416. };
  4417. static struct hda_verb alc883_init_verbs[] = {
  4418. /* ADC1: mute amp left and right */
  4419. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4420. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4421. /* ADC2: mute amp left and right */
  4422. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4423. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4424. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4425. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4426. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4427. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4428. /* Rear mixer */
  4429. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4430. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4431. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4432. /* CLFE mixer */
  4433. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4434. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4435. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4436. /* Side mixer */
  4437. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4438. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4439. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4440. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4441. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4442. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4443. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4444. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4445. /* Front Pin: output 0 (0x0c) */
  4446. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4447. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4448. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4449. /* Rear Pin: output 1 (0x0d) */
  4450. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4451. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4452. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4453. /* CLFE Pin: output 2 (0x0e) */
  4454. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4455. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4456. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4457. /* Side Pin: output 3 (0x0f) */
  4458. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4459. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4460. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4461. /* Mic (rear) pin: input vref at 80% */
  4462. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4463. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4464. /* Front Mic pin: input vref at 80% */
  4465. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4466. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4467. /* Line In pin: input */
  4468. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4469. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4470. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4471. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4472. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4473. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4474. /* CD pin widget for input */
  4475. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4476. /* FIXME: use matrix-type input source selection */
  4477. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4478. /* Input mixer2 */
  4479. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4480. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4481. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4482. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4483. /* Input mixer3 */
  4484. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4485. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4486. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4487. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4488. { }
  4489. };
  4490. /*
  4491. * generic initialization of ADC, input mixers and output mixers
  4492. */
  4493. static struct hda_verb alc883_auto_init_verbs[] = {
  4494. /*
  4495. * Unmute ADC0-2 and set the default input to mic-in
  4496. */
  4497. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4498. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4499. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4500. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4501. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4502. * mixer widget
  4503. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4504. * mic (mic 2)
  4505. */
  4506. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4507. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4508. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4509. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4510. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4511. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4512. /*
  4513. * Set up output mixers (0x0c - 0x0f)
  4514. */
  4515. /* set vol=0 to output mixers */
  4516. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4517. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4518. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4519. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4520. /* set up input amps for analog loopback */
  4521. /* Amp Indices: DAC = 0, mixer = 1 */
  4522. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4523. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4524. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4525. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4526. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4527. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4528. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4529. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4530. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4531. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4532. /* FIXME: use matrix-type input source selection */
  4533. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4534. /* Input mixer1 */
  4535. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4536. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4537. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4538. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4539. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4540. /* Input mixer2 */
  4541. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4542. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4543. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4544. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4545. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4546. { }
  4547. };
  4548. /* capture mixer elements */
  4549. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4550. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4552. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4553. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4554. {
  4555. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4556. /* The multiple "Capture Source" controls confuse alsamixer
  4557. * So call somewhat different..
  4558. * FIXME: the controls appear in the "playback" view!
  4559. */
  4560. /* .name = "Capture Source", */
  4561. .name = "Input Source",
  4562. .count = 2,
  4563. .info = alc882_mux_enum_info,
  4564. .get = alc882_mux_enum_get,
  4565. .put = alc882_mux_enum_put,
  4566. },
  4567. { } /* end */
  4568. };
  4569. /* pcm configuration: identiacal with ALC880 */
  4570. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4571. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4572. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4573. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4574. /*
  4575. * configuration and preset
  4576. */
  4577. static struct hda_board_config alc883_cfg_tbl[] = {
  4578. { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
  4579. { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
  4580. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4581. .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
  4582. { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
  4583. { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
  4584. .config = ALC883_3ST_6ch },
  4585. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
  4586. .config = ALC883_3ST_6ch }, /* D102GGC */
  4587. { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
  4588. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4589. .config = ALC883_6ST_DIG }, /* MSI */
  4590. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4591. .config = ALC883_6ST_DIG }, /* Foxconn */
  4592. { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
  4593. { .modelname = "acer", .config = ALC883_ACER },
  4594. { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
  4595. .config = ALC883_ACER },
  4596. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
  4597. .config = ALC883_ACER },
  4598. { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
  4599. .config = ALC883_ACER },
  4600. { .modelname = "auto", .config = ALC883_AUTO },
  4601. {}
  4602. };
  4603. static struct alc_config_preset alc883_presets[] = {
  4604. [ALC883_3ST_2ch_DIG] = {
  4605. .mixers = { alc883_3ST_2ch_mixer },
  4606. .init_verbs = { alc883_init_verbs },
  4607. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4608. .dac_nids = alc883_dac_nids,
  4609. .dig_out_nid = ALC883_DIGOUT_NID,
  4610. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4611. .adc_nids = alc883_adc_nids,
  4612. .dig_in_nid = ALC883_DIGIN_NID,
  4613. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4614. .channel_mode = alc883_3ST_2ch_modes,
  4615. .input_mux = &alc883_capture_source,
  4616. },
  4617. [ALC883_3ST_6ch_DIG] = {
  4618. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4619. .init_verbs = { alc883_init_verbs },
  4620. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4621. .dac_nids = alc883_dac_nids,
  4622. .dig_out_nid = ALC883_DIGOUT_NID,
  4623. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4624. .adc_nids = alc883_adc_nids,
  4625. .dig_in_nid = ALC883_DIGIN_NID,
  4626. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4627. .channel_mode = alc883_3ST_6ch_modes,
  4628. .need_dac_fix = 1,
  4629. .input_mux = &alc883_capture_source,
  4630. },
  4631. [ALC883_3ST_6ch] = {
  4632. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4633. .init_verbs = { alc883_init_verbs },
  4634. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4635. .dac_nids = alc883_dac_nids,
  4636. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4637. .adc_nids = alc883_adc_nids,
  4638. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4639. .channel_mode = alc883_3ST_6ch_modes,
  4640. .need_dac_fix = 1,
  4641. .input_mux = &alc883_capture_source,
  4642. },
  4643. [ALC883_6ST_DIG] = {
  4644. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4645. .init_verbs = { alc883_init_verbs },
  4646. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4647. .dac_nids = alc883_dac_nids,
  4648. .dig_out_nid = ALC883_DIGOUT_NID,
  4649. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4650. .adc_nids = alc883_adc_nids,
  4651. .dig_in_nid = ALC883_DIGIN_NID,
  4652. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4653. .channel_mode = alc883_sixstack_modes,
  4654. .input_mux = &alc883_capture_source,
  4655. },
  4656. [ALC888_DEMO_BOARD] = {
  4657. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4658. .init_verbs = { alc883_init_verbs },
  4659. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4660. .dac_nids = alc883_dac_nids,
  4661. .dig_out_nid = ALC883_DIGOUT_NID,
  4662. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4663. .adc_nids = alc883_adc_nids,
  4664. .dig_in_nid = ALC883_DIGIN_NID,
  4665. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4666. .channel_mode = alc883_sixstack_modes,
  4667. .input_mux = &alc883_capture_source,
  4668. },
  4669. [ALC883_ACER] = {
  4670. .mixers = { alc883_base_mixer,
  4671. alc883_chmode_mixer },
  4672. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  4673. * and the headphone jack. Turn this on and rely on the
  4674. * standard mute methods whenever the user wants to turn
  4675. * these outputs off.
  4676. */
  4677. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  4678. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4679. .dac_nids = alc883_dac_nids,
  4680. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4681. .adc_nids = alc883_adc_nids,
  4682. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4683. .channel_mode = alc883_3ST_2ch_modes,
  4684. .input_mux = &alc883_capture_source,
  4685. },
  4686. };
  4687. /*
  4688. * BIOS auto configuration
  4689. */
  4690. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  4691. hda_nid_t nid, int pin_type,
  4692. int dac_idx)
  4693. {
  4694. /* set as output */
  4695. struct alc_spec *spec = codec->spec;
  4696. int idx;
  4697. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4698. idx = 4;
  4699. else
  4700. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4701. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4702. pin_type);
  4703. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4704. AMP_OUT_UNMUTE);
  4705. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4706. }
  4707. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  4708. {
  4709. struct alc_spec *spec = codec->spec;
  4710. int i;
  4711. for (i = 0; i <= HDA_SIDE; i++) {
  4712. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4713. if (nid)
  4714. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4715. }
  4716. }
  4717. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  4718. {
  4719. struct alc_spec *spec = codec->spec;
  4720. hda_nid_t pin;
  4721. pin = spec->autocfg.hp_pins[0];
  4722. if (pin) /* connect to front */
  4723. /* use dac 0 */
  4724. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4725. }
  4726. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  4727. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  4728. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  4729. {
  4730. struct alc_spec *spec = codec->spec;
  4731. int i;
  4732. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4733. hda_nid_t nid = spec->autocfg.input_pins[i];
  4734. if (alc883_is_input_pin(nid)) {
  4735. snd_hda_codec_write(codec, nid, 0,
  4736. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4737. (i <= AUTO_PIN_FRONT_MIC ?
  4738. PIN_VREF80 : PIN_IN));
  4739. if (nid != ALC883_PIN_CD_NID)
  4740. snd_hda_codec_write(codec, nid, 0,
  4741. AC_VERB_SET_AMP_GAIN_MUTE,
  4742. AMP_OUT_MUTE);
  4743. }
  4744. }
  4745. }
  4746. /* almost identical with ALC880 parser... */
  4747. static int alc883_parse_auto_config(struct hda_codec *codec)
  4748. {
  4749. struct alc_spec *spec = codec->spec;
  4750. int err = alc880_parse_auto_config(codec);
  4751. if (err < 0)
  4752. return err;
  4753. else if (err > 0)
  4754. /* hack - override the init verbs */
  4755. spec->init_verbs[0] = alc883_auto_init_verbs;
  4756. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  4757. spec->num_mixers++;
  4758. return err;
  4759. }
  4760. /* additional initialization for auto-configuration model */
  4761. static void alc883_auto_init(struct hda_codec *codec)
  4762. {
  4763. alc883_auto_init_multi_out(codec);
  4764. alc883_auto_init_hp_out(codec);
  4765. alc883_auto_init_analog_input(codec);
  4766. }
  4767. static int patch_alc883(struct hda_codec *codec)
  4768. {
  4769. struct alc_spec *spec;
  4770. int err, board_config;
  4771. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4772. if (spec == NULL)
  4773. return -ENOMEM;
  4774. codec->spec = spec;
  4775. board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
  4776. if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
  4777. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  4778. "trying auto-probe from BIOS...\n");
  4779. board_config = ALC883_AUTO;
  4780. }
  4781. if (board_config == ALC883_AUTO) {
  4782. /* automatic parse from the BIOS config */
  4783. err = alc883_parse_auto_config(codec);
  4784. if (err < 0) {
  4785. alc_free(codec);
  4786. return err;
  4787. } else if (! err) {
  4788. printk(KERN_INFO
  4789. "hda_codec: Cannot set up configuration "
  4790. "from BIOS. Using base mode...\n");
  4791. board_config = ALC883_3ST_2ch_DIG;
  4792. }
  4793. }
  4794. if (board_config != ALC883_AUTO)
  4795. setup_preset(spec, &alc883_presets[board_config]);
  4796. spec->stream_name_analog = "ALC883 Analog";
  4797. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  4798. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  4799. spec->stream_name_digital = "ALC883 Digital";
  4800. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  4801. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  4802. if (! spec->adc_nids && spec->input_mux) {
  4803. spec->adc_nids = alc883_adc_nids;
  4804. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  4805. }
  4806. codec->patch_ops = alc_patch_ops;
  4807. if (board_config == ALC883_AUTO)
  4808. spec->init_hook = alc883_auto_init;
  4809. return 0;
  4810. }
  4811. /*
  4812. * ALC262 support
  4813. */
  4814. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  4815. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  4816. #define alc262_dac_nids alc260_dac_nids
  4817. #define alc262_adc_nids alc882_adc_nids
  4818. #define alc262_adc_nids_alt alc882_adc_nids_alt
  4819. #define alc262_modes alc260_modes
  4820. #define alc262_capture_source alc882_capture_source
  4821. static struct snd_kcontrol_new alc262_base_mixer[] = {
  4822. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4823. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4824. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4825. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4826. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4827. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4828. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4829. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4830. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4831. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4832. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4833. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  4834. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  4835. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4836. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4837. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4838. { } /* end */
  4839. };
  4840. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  4841. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4842. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4843. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4844. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4845. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4846. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4847. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4848. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4849. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4850. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4851. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4852. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4853. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4854. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4855. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4856. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  4857. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  4858. { } /* end */
  4859. };
  4860. #define alc262_capture_mixer alc882_capture_mixer
  4861. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  4862. /*
  4863. * generic initialization of ADC, input mixers and output mixers
  4864. */
  4865. static struct hda_verb alc262_init_verbs[] = {
  4866. /*
  4867. * Unmute ADC0-2 and set the default input to mic-in
  4868. */
  4869. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4871. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4872. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4873. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4874. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4875. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4876. * mixer widget
  4877. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4878. * mic (mic 2)
  4879. */
  4880. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4881. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4882. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4883. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4884. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4885. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4886. /*
  4887. * Set up output mixers (0x0c - 0x0e)
  4888. */
  4889. /* set vol=0 to output mixers */
  4890. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4891. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4892. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4893. /* set up input amps for analog loopback */
  4894. /* Amp Indices: DAC = 0, mixer = 1 */
  4895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4896. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4897. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4898. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4899. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4900. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4901. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4902. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  4903. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4904. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  4905. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4906. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4907. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4908. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4909. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4910. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4911. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4912. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4913. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4914. /* FIXME: use matrix-type input source selection */
  4915. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4916. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4917. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4918. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4919. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4920. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4921. /* Input mixer2 */
  4922. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4923. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4924. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4925. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4926. /* Input mixer3 */
  4927. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4928. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4929. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4930. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4931. { }
  4932. };
  4933. /*
  4934. * fujitsu model
  4935. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  4936. */
  4937. #define ALC_HP_EVENT 0x37
  4938. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4939. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4940. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4941. {}
  4942. };
  4943. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4944. .num_items = 2,
  4945. .items = {
  4946. { "Mic", 0x0 },
  4947. { "CD", 0x4 },
  4948. },
  4949. };
  4950. static struct hda_input_mux alc262_HP_capture_source = {
  4951. .num_items = 5,
  4952. .items = {
  4953. { "Mic", 0x0 },
  4954. { "Front Mic", 0x3 },
  4955. { "Line", 0x2 },
  4956. { "CD", 0x4 },
  4957. { "AUX IN", 0x6 },
  4958. },
  4959. };
  4960. /* mute/unmute internal speaker according to the hp jack and mute state */
  4961. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  4962. {
  4963. struct alc_spec *spec = codec->spec;
  4964. unsigned int mute;
  4965. if (force || ! spec->sense_updated) {
  4966. unsigned int present;
  4967. /* need to execute and sync at first */
  4968. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  4969. present = snd_hda_codec_read(codec, 0x14, 0,
  4970. AC_VERB_GET_PIN_SENSE, 0);
  4971. spec->jack_present = (present & 0x80000000) != 0;
  4972. spec->sense_updated = 1;
  4973. }
  4974. if (spec->jack_present) {
  4975. /* mute internal speaker */
  4976. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4977. 0x80, 0x80);
  4978. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4979. 0x80, 0x80);
  4980. } else {
  4981. /* unmute internal speaker if necessary */
  4982. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  4983. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4984. 0x80, mute & 0x80);
  4985. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  4986. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4987. 0x80, mute & 0x80);
  4988. }
  4989. }
  4990. /* unsolicited event for HP jack sensing */
  4991. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  4992. unsigned int res)
  4993. {
  4994. if ((res >> 26) != ALC_HP_EVENT)
  4995. return;
  4996. alc262_fujitsu_automute(codec, 1);
  4997. }
  4998. /* bind volumes of both NID 0x0c and 0x0d */
  4999. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5000. struct snd_ctl_elem_value *ucontrol)
  5001. {
  5002. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5003. long *valp = ucontrol->value.integer.value;
  5004. int change;
  5005. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5006. 0x7f, valp[0] & 0x7f);
  5007. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5008. 0x7f, valp[1] & 0x7f);
  5009. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5010. 0x7f, valp[0] & 0x7f);
  5011. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5012. 0x7f, valp[1] & 0x7f);
  5013. return change;
  5014. }
  5015. /* bind hp and internal speaker mute (with plug check) */
  5016. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5017. struct snd_ctl_elem_value *ucontrol)
  5018. {
  5019. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5020. long *valp = ucontrol->value.integer.value;
  5021. int change;
  5022. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5023. 0x80, valp[0] ? 0 : 0x80);
  5024. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5025. 0x80, valp[1] ? 0 : 0x80);
  5026. if (change || codec->in_resume)
  5027. alc262_fujitsu_automute(codec, codec->in_resume);
  5028. return change;
  5029. }
  5030. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5031. {
  5032. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5033. .name = "Master Playback Volume",
  5034. .info = snd_hda_mixer_amp_volume_info,
  5035. .get = snd_hda_mixer_amp_volume_get,
  5036. .put = alc262_fujitsu_master_vol_put,
  5037. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5038. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5039. },
  5040. {
  5041. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5042. .name = "Master Playback Switch",
  5043. .info = snd_hda_mixer_amp_switch_info,
  5044. .get = snd_hda_mixer_amp_switch_get,
  5045. .put = alc262_fujitsu_master_sw_put,
  5046. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5047. },
  5048. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5049. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5050. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5051. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5052. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5053. { } /* end */
  5054. };
  5055. /* additional init verbs for Benq laptops */
  5056. static struct hda_verb alc262_EAPD_verbs[] = {
  5057. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5058. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5059. {}
  5060. };
  5061. /* add playback controls from the parsed DAC table */
  5062. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5063. {
  5064. hda_nid_t nid;
  5065. int err;
  5066. spec->multiout.num_dacs = 1; /* only use one dac */
  5067. spec->multiout.dac_nids = spec->private_dac_nids;
  5068. spec->multiout.dac_nids[0] = 2;
  5069. nid = cfg->line_out_pins[0];
  5070. if (nid) {
  5071. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5072. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5073. return err;
  5074. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5075. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5076. return err;
  5077. }
  5078. nid = cfg->speaker_pins[0];
  5079. if (nid) {
  5080. if (nid == 0x16) {
  5081. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5082. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5083. return err;
  5084. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5085. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5086. return err;
  5087. } else {
  5088. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5089. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5090. return err;
  5091. }
  5092. }
  5093. nid = cfg->hp_pins[0];
  5094. if (nid) {
  5095. /* spec->multiout.hp_nid = 2; */
  5096. if (nid == 0x16) {
  5097. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5098. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5099. return err;
  5100. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5101. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5102. return err;
  5103. } else {
  5104. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5105. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5106. return err;
  5107. }
  5108. }
  5109. return 0;
  5110. }
  5111. /* identical with ALC880 */
  5112. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5113. /*
  5114. * generic initialization of ADC, input mixers and output mixers
  5115. */
  5116. static struct hda_verb alc262_volume_init_verbs[] = {
  5117. /*
  5118. * Unmute ADC0-2 and set the default input to mic-in
  5119. */
  5120. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5121. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5122. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5123. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5124. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5125. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5126. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5127. * mixer widget
  5128. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5129. * mic (mic 2)
  5130. */
  5131. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5132. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5133. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5134. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5135. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5136. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5137. /*
  5138. * Set up output mixers (0x0c - 0x0f)
  5139. */
  5140. /* set vol=0 to output mixers */
  5141. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5142. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5143. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5144. /* set up input amps for analog loopback */
  5145. /* Amp Indices: DAC = 0, mixer = 1 */
  5146. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5147. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5148. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5149. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5150. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5151. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5152. /* FIXME: use matrix-type input source selection */
  5153. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5154. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5155. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5156. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5157. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5159. /* Input mixer2 */
  5160. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5161. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5162. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5163. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5164. /* Input mixer3 */
  5165. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5166. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5167. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5168. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5169. { }
  5170. };
  5171. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5172. /*
  5173. * Unmute ADC0-2 and set the default input to mic-in
  5174. */
  5175. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5176. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5177. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5178. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5179. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5180. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5181. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5182. * mixer widget
  5183. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5184. * mic (mic 2)
  5185. */
  5186. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5187. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5188. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5189. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5190. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5191. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5192. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5193. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5194. /*
  5195. * Set up output mixers (0x0c - 0x0e)
  5196. */
  5197. /* set vol=0 to output mixers */
  5198. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5199. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5200. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5201. /* set up input amps for analog loopback */
  5202. /* Amp Indices: DAC = 0, mixer = 1 */
  5203. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5204. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5205. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5206. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5207. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5208. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5209. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5210. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5211. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5212. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5213. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5214. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5215. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5216. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5217. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5218. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5219. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5220. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5221. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5222. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5223. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5224. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5225. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5226. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5227. /* FIXME: use matrix-type input source selection */
  5228. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5229. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5230. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5231. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5232. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5233. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5234. /* Input mixer2 */
  5235. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5236. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5237. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5238. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5239. /* Input mixer3 */
  5240. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5241. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5242. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5243. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5244. { }
  5245. };
  5246. /* pcm configuration: identiacal with ALC880 */
  5247. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5248. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5249. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5250. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5251. /*
  5252. * BIOS auto configuration
  5253. */
  5254. static int alc262_parse_auto_config(struct hda_codec *codec)
  5255. {
  5256. struct alc_spec *spec = codec->spec;
  5257. int err;
  5258. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5259. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5260. alc262_ignore)) < 0)
  5261. return err;
  5262. if (! spec->autocfg.line_outs)
  5263. return 0; /* can't find valid BIOS pin config */
  5264. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5265. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5266. return err;
  5267. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5268. if (spec->autocfg.dig_out_pin)
  5269. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5270. if (spec->autocfg.dig_in_pin)
  5271. spec->dig_in_nid = ALC262_DIGIN_NID;
  5272. if (spec->kctl_alloc)
  5273. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5274. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5275. spec->num_mux_defs = 1;
  5276. spec->input_mux = &spec->private_imux;
  5277. return 1;
  5278. }
  5279. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5280. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5281. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5282. /* init callback for auto-configuration model -- overriding the default init */
  5283. static void alc262_auto_init(struct hda_codec *codec)
  5284. {
  5285. alc262_auto_init_multi_out(codec);
  5286. alc262_auto_init_hp_out(codec);
  5287. alc262_auto_init_analog_input(codec);
  5288. }
  5289. /*
  5290. * configuration and preset
  5291. */
  5292. static struct hda_board_config alc262_cfg_tbl[] = {
  5293. { .modelname = "basic", .config = ALC262_BASIC },
  5294. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  5295. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
  5296. .config = ALC262_FUJITSU },
  5297. { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
  5298. { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
  5299. .config = ALC262_HP_BPC }, /* xw4400 */
  5300. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
  5301. .config = ALC262_HP_BPC }, /* xw6400 */
  5302. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
  5303. .config = ALC262_HP_BPC }, /* xw8400 */
  5304. { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
  5305. .config = ALC262_HP_BPC }, /* xw9400 */
  5306. { .modelname = "benq", .config = ALC262_BENQ_ED8 },
  5307. { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
  5308. .config = ALC262_BENQ_ED8 },
  5309. { .modelname = "auto", .config = ALC262_AUTO },
  5310. {}
  5311. };
  5312. static struct alc_config_preset alc262_presets[] = {
  5313. [ALC262_BASIC] = {
  5314. .mixers = { alc262_base_mixer },
  5315. .init_verbs = { alc262_init_verbs },
  5316. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5317. .dac_nids = alc262_dac_nids,
  5318. .hp_nid = 0x03,
  5319. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5320. .channel_mode = alc262_modes,
  5321. .input_mux = &alc262_capture_source,
  5322. },
  5323. [ALC262_FUJITSU] = {
  5324. .mixers = { alc262_fujitsu_mixer },
  5325. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5326. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5327. .dac_nids = alc262_dac_nids,
  5328. .hp_nid = 0x03,
  5329. .dig_out_nid = ALC262_DIGOUT_NID,
  5330. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5331. .channel_mode = alc262_modes,
  5332. .input_mux = &alc262_fujitsu_capture_source,
  5333. .unsol_event = alc262_fujitsu_unsol_event,
  5334. },
  5335. [ALC262_HP_BPC] = {
  5336. .mixers = { alc262_HP_BPC_mixer },
  5337. .init_verbs = { alc262_HP_BPC_init_verbs },
  5338. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5339. .dac_nids = alc262_dac_nids,
  5340. .hp_nid = 0x03,
  5341. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5342. .channel_mode = alc262_modes,
  5343. .input_mux = &alc262_HP_capture_source,
  5344. },
  5345. [ALC262_BENQ_ED8] = {
  5346. .mixers = { alc262_base_mixer },
  5347. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5348. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5349. .dac_nids = alc262_dac_nids,
  5350. .hp_nid = 0x03,
  5351. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5352. .channel_mode = alc262_modes,
  5353. .input_mux = &alc262_capture_source,
  5354. },
  5355. };
  5356. static int patch_alc262(struct hda_codec *codec)
  5357. {
  5358. struct alc_spec *spec;
  5359. int board_config;
  5360. int err;
  5361. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  5362. if (spec == NULL)
  5363. return -ENOMEM;
  5364. codec->spec = spec;
  5365. #if 0
  5366. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5367. {
  5368. int tmp;
  5369. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5370. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5371. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5372. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5373. }
  5374. #endif
  5375. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  5376. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  5377. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5378. "trying auto-probe from BIOS...\n");
  5379. board_config = ALC262_AUTO;
  5380. }
  5381. if (board_config == ALC262_AUTO) {
  5382. /* automatic parse from the BIOS config */
  5383. err = alc262_parse_auto_config(codec);
  5384. if (err < 0) {
  5385. alc_free(codec);
  5386. return err;
  5387. } else if (! err) {
  5388. printk(KERN_INFO
  5389. "hda_codec: Cannot set up configuration "
  5390. "from BIOS. Using base mode...\n");
  5391. board_config = ALC262_BASIC;
  5392. }
  5393. }
  5394. if (board_config != ALC262_AUTO)
  5395. setup_preset(spec, &alc262_presets[board_config]);
  5396. spec->stream_name_analog = "ALC262 Analog";
  5397. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5398. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5399. spec->stream_name_digital = "ALC262 Digital";
  5400. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  5401. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  5402. if (! spec->adc_nids && spec->input_mux) {
  5403. /* check whether NID 0x07 is valid */
  5404. unsigned int wcap = get_wcaps(codec, 0x07);
  5405. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  5406. if (wcap != AC_WID_AUD_IN) {
  5407. spec->adc_nids = alc262_adc_nids_alt;
  5408. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  5409. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  5410. spec->num_mixers++;
  5411. } else {
  5412. spec->adc_nids = alc262_adc_nids;
  5413. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  5414. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  5415. spec->num_mixers++;
  5416. }
  5417. }
  5418. codec->patch_ops = alc_patch_ops;
  5419. if (board_config == ALC262_AUTO)
  5420. spec->init_hook = alc262_auto_init;
  5421. return 0;
  5422. }
  5423. /*
  5424. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  5425. */
  5426. /*
  5427. * set the path ways for 2 channel output
  5428. * need to set the codec line out and mic 1 pin widgets to inputs
  5429. */
  5430. static struct hda_verb alc861_threestack_ch2_init[] = {
  5431. /* set pin widget 1Ah (line in) for input */
  5432. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5433. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  5434. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5435. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  5436. #if 0
  5437. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5438. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  5439. #endif
  5440. { } /* end */
  5441. };
  5442. /*
  5443. * 6ch mode
  5444. * need to set the codec line out and mic 1 pin widgets to outputs
  5445. */
  5446. static struct hda_verb alc861_threestack_ch6_init[] = {
  5447. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  5448. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5449. /* set pin widget 18h (mic1) for output (CLFE)*/
  5450. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5451. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5452. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5453. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  5454. #if 0
  5455. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5456. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  5457. #endif
  5458. { } /* end */
  5459. };
  5460. static struct hda_channel_mode alc861_threestack_modes[2] = {
  5461. { 2, alc861_threestack_ch2_init },
  5462. { 6, alc861_threestack_ch6_init },
  5463. };
  5464. /* Set mic1 as input and unmute the mixer */
  5465. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  5466. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5467. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5468. { } /* end */
  5469. };
  5470. /* Set mic1 as output and mute mixer */
  5471. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  5472. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5473. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5474. { } /* end */
  5475. };
  5476. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  5477. { 2, alc861_uniwill_m31_ch2_init },
  5478. { 4, alc861_uniwill_m31_ch4_init },
  5479. };
  5480. /* patch-ALC861 */
  5481. static struct snd_kcontrol_new alc861_base_mixer[] = {
  5482. /* output mixer control */
  5483. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5484. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5485. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5486. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5487. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  5488. /*Input mixer control */
  5489. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5490. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5491. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5492. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5493. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5494. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5495. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5496. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5497. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5498. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5499. /* Capture mixer control */
  5500. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5501. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5502. {
  5503. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5504. .name = "Capture Source",
  5505. .count = 1,
  5506. .info = alc_mux_enum_info,
  5507. .get = alc_mux_enum_get,
  5508. .put = alc_mux_enum_put,
  5509. },
  5510. { } /* end */
  5511. };
  5512. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  5513. /* output mixer control */
  5514. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5515. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5516. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5517. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5518. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5519. /* Input mixer control */
  5520. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5521. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5522. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5523. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5524. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5525. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5527. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5528. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5529. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5530. /* Capture mixer control */
  5531. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5532. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5533. {
  5534. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5535. .name = "Capture Source",
  5536. .count = 1,
  5537. .info = alc_mux_enum_info,
  5538. .get = alc_mux_enum_get,
  5539. .put = alc_mux_enum_put,
  5540. },
  5541. {
  5542. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5543. .name = "Channel Mode",
  5544. .info = alc_ch_mode_info,
  5545. .get = alc_ch_mode_get,
  5546. .put = alc_ch_mode_put,
  5547. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  5548. },
  5549. { } /* end */
  5550. };
  5551. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  5552. /* output mixer control */
  5553. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5554. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5555. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5556. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5557. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5558. /* Input mixer control */
  5559. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5560. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5561. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5562. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5563. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5564. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5565. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5566. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5567. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5568. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5569. /* Capture mixer control */
  5570. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5571. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5572. {
  5573. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5574. .name = "Capture Source",
  5575. .count = 1,
  5576. .info = alc_mux_enum_info,
  5577. .get = alc_mux_enum_get,
  5578. .put = alc_mux_enum_put,
  5579. },
  5580. {
  5581. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5582. .name = "Channel Mode",
  5583. .info = alc_ch_mode_info,
  5584. .get = alc_ch_mode_get,
  5585. .put = alc_ch_mode_put,
  5586. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  5587. },
  5588. { } /* end */
  5589. };
  5590. /*
  5591. * generic initialization of ADC, input mixers and output mixers
  5592. */
  5593. static struct hda_verb alc861_base_init_verbs[] = {
  5594. /*
  5595. * Unmute ADC0 and set the default input to mic-in
  5596. */
  5597. /* port-A for surround (rear panel) */
  5598. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5599. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5600. /* port-B for mic-in (rear panel) with vref */
  5601. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5602. /* port-C for line-in (rear panel) */
  5603. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5604. /* port-D for Front */
  5605. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5606. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5607. /* port-E for HP out (front panel) */
  5608. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5609. /* route front PCM to HP */
  5610. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5611. /* port-F for mic-in (front panel) with vref */
  5612. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5613. /* port-G for CLFE (rear panel) */
  5614. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5615. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5616. /* port-H for side (rear panel) */
  5617. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5618. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5619. /* CD-in */
  5620. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5621. /* route front mic to ADC1*/
  5622. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5623. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5624. /* Unmute DAC0~3 & spdif out*/
  5625. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5626. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5627. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5628. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5630. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5631. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5632. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5633. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5634. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5635. /* Unmute Stereo Mixer 15 */
  5636. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5637. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5638. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5639. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5640. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5641. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5642. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5643. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5644. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5645. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5646. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5647. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5648. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5649. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5650. { }
  5651. };
  5652. static struct hda_verb alc861_threestack_init_verbs[] = {
  5653. /*
  5654. * Unmute ADC0 and set the default input to mic-in
  5655. */
  5656. /* port-A for surround (rear panel) */
  5657. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5658. /* port-B for mic-in (rear panel) with vref */
  5659. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5660. /* port-C for line-in (rear panel) */
  5661. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5662. /* port-D for Front */
  5663. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5664. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5665. /* port-E for HP out (front panel) */
  5666. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5667. /* route front PCM to HP */
  5668. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5669. /* port-F for mic-in (front panel) with vref */
  5670. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5671. /* port-G for CLFE (rear panel) */
  5672. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5673. /* port-H for side (rear panel) */
  5674. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5675. /* CD-in */
  5676. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5677. /* route front mic to ADC1*/
  5678. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5679. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5680. /* Unmute DAC0~3 & spdif out*/
  5681. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5682. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5683. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5684. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5685. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5686. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5687. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5688. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5689. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5690. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5691. /* Unmute Stereo Mixer 15 */
  5692. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5693. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5694. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5695. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5696. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5697. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5698. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5699. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5700. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5701. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5702. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5703. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5704. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5705. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5706. { }
  5707. };
  5708. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  5709. /*
  5710. * Unmute ADC0 and set the default input to mic-in
  5711. */
  5712. /* port-A for surround (rear panel) */
  5713. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5714. /* port-B for mic-in (rear panel) with vref */
  5715. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5716. /* port-C for line-in (rear panel) */
  5717. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5718. /* port-D for Front */
  5719. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5720. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5721. /* port-E for HP out (front panel) */
  5722. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  5723. /* route front PCM to HP */
  5724. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5725. /* port-F for mic-in (front panel) with vref */
  5726. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5727. /* port-G for CLFE (rear panel) */
  5728. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5729. /* port-H for side (rear panel) */
  5730. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5731. /* CD-in */
  5732. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5733. /* route front mic to ADC1*/
  5734. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5735. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5736. /* Unmute DAC0~3 & spdif out*/
  5737. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5738. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5739. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5740. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5741. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5742. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5743. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5744. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5745. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5746. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5747. /* Unmute Stereo Mixer 15 */
  5748. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5749. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5750. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5751. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5752. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5753. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5754. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5755. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5756. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5757. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5758. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5759. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5760. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5761. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5762. { }
  5763. };
  5764. /*
  5765. * generic initialization of ADC, input mixers and output mixers
  5766. */
  5767. static struct hda_verb alc861_auto_init_verbs[] = {
  5768. /*
  5769. * Unmute ADC0 and set the default input to mic-in
  5770. */
  5771. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5772. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5773. /* Unmute DAC0~3 & spdif out*/
  5774. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5775. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5776. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5777. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5778. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5779. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5780. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5781. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5782. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5783. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5784. /* Unmute Stereo Mixer 15 */
  5785. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5786. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5787. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5788. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  5789. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5790. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5791. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5792. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5793. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5794. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5795. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5796. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5797. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5798. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5799. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5800. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5801. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5802. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5803. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5804. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5805. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  5806. { }
  5807. };
  5808. /* pcm configuration: identiacal with ALC880 */
  5809. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  5810. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  5811. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  5812. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  5813. #define ALC861_DIGOUT_NID 0x07
  5814. static struct hda_channel_mode alc861_8ch_modes[1] = {
  5815. { 8, NULL }
  5816. };
  5817. static hda_nid_t alc861_dac_nids[4] = {
  5818. /* front, surround, clfe, side */
  5819. 0x03, 0x06, 0x05, 0x04
  5820. };
  5821. static hda_nid_t alc660_dac_nids[3] = {
  5822. /* front, clfe, surround */
  5823. 0x03, 0x05, 0x06
  5824. };
  5825. static hda_nid_t alc861_adc_nids[1] = {
  5826. /* ADC0-2 */
  5827. 0x08,
  5828. };
  5829. static struct hda_input_mux alc861_capture_source = {
  5830. .num_items = 5,
  5831. .items = {
  5832. { "Mic", 0x0 },
  5833. { "Front Mic", 0x3 },
  5834. { "Line", 0x1 },
  5835. { "CD", 0x4 },
  5836. { "Mixer", 0x5 },
  5837. },
  5838. };
  5839. /* fill in the dac_nids table from the parsed pin configuration */
  5840. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5841. {
  5842. int i;
  5843. hda_nid_t nid;
  5844. spec->multiout.dac_nids = spec->private_dac_nids;
  5845. for (i = 0; i < cfg->line_outs; i++) {
  5846. nid = cfg->line_out_pins[i];
  5847. if (nid) {
  5848. if (i >= ARRAY_SIZE(alc861_dac_nids))
  5849. continue;
  5850. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  5851. }
  5852. }
  5853. spec->multiout.num_dacs = cfg->line_outs;
  5854. return 0;
  5855. }
  5856. /* add playback controls from the parsed DAC table */
  5857. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  5858. const struct auto_pin_cfg *cfg)
  5859. {
  5860. char name[32];
  5861. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  5862. hda_nid_t nid;
  5863. int i, idx, err;
  5864. for (i = 0; i < cfg->line_outs; i++) {
  5865. nid = spec->multiout.dac_nids[i];
  5866. if (! nid)
  5867. continue;
  5868. if (nid == 0x05) {
  5869. /* Center/LFE */
  5870. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  5871. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  5872. return err;
  5873. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  5874. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5875. return err;
  5876. } else {
  5877. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  5878. if (nid == alc861_dac_nids[idx])
  5879. break;
  5880. sprintf(name, "%s Playback Switch", chname[idx]);
  5881. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  5882. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5883. return err;
  5884. }
  5885. }
  5886. return 0;
  5887. }
  5888. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  5889. {
  5890. int err;
  5891. hda_nid_t nid;
  5892. if (! pin)
  5893. return 0;
  5894. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  5895. nid = 0x03;
  5896. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5897. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5898. return err;
  5899. spec->multiout.hp_nid = nid;
  5900. }
  5901. return 0;
  5902. }
  5903. /* create playback/capture controls for input pins */
  5904. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5905. {
  5906. struct hda_input_mux *imux = &spec->private_imux;
  5907. int i, err, idx, idx1;
  5908. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5909. switch(cfg->input_pins[i]) {
  5910. case 0x0c:
  5911. idx1 = 1;
  5912. idx = 2; // Line In
  5913. break;
  5914. case 0x0f:
  5915. idx1 = 2;
  5916. idx = 2; // Line In
  5917. break;
  5918. case 0x0d:
  5919. idx1 = 0;
  5920. idx = 1; // Mic In
  5921. break;
  5922. case 0x10:
  5923. idx1 = 3;
  5924. idx = 1; // Mic In
  5925. break;
  5926. case 0x11:
  5927. idx1 = 4;
  5928. idx = 0; // CD
  5929. break;
  5930. default:
  5931. continue;
  5932. }
  5933. err = new_analog_input(spec, cfg->input_pins[i],
  5934. auto_pin_cfg_labels[i], idx, 0x15);
  5935. if (err < 0)
  5936. return err;
  5937. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  5938. imux->items[imux->num_items].index = idx1;
  5939. imux->num_items++;
  5940. }
  5941. return 0;
  5942. }
  5943. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  5944. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5945. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5946. {
  5947. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5948. /* The multiple "Capture Source" controls confuse alsamixer
  5949. * So call somewhat different..
  5950. *FIXME: the controls appear in the "playback" view!
  5951. */
  5952. /* .name = "Capture Source", */
  5953. .name = "Input Source",
  5954. .count = 1,
  5955. .info = alc_mux_enum_info,
  5956. .get = alc_mux_enum_get,
  5957. .put = alc_mux_enum_put,
  5958. },
  5959. { } /* end */
  5960. };
  5961. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  5962. int pin_type, int dac_idx)
  5963. {
  5964. /* set as output */
  5965. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  5966. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  5967. }
  5968. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  5969. {
  5970. struct alc_spec *spec = codec->spec;
  5971. int i;
  5972. for (i = 0; i < spec->autocfg.line_outs; i++) {
  5973. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5974. if (nid)
  5975. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  5976. }
  5977. }
  5978. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  5979. {
  5980. struct alc_spec *spec = codec->spec;
  5981. hda_nid_t pin;
  5982. pin = spec->autocfg.hp_pins[0];
  5983. if (pin) /* connect to front */
  5984. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  5985. }
  5986. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  5987. {
  5988. struct alc_spec *spec = codec->spec;
  5989. int i;
  5990. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5991. hda_nid_t nid = spec->autocfg.input_pins[i];
  5992. if ((nid>=0x0c) && (nid <=0x11)) {
  5993. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5994. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  5995. }
  5996. }
  5997. }
  5998. /* parse the BIOS configuration and set up the alc_spec */
  5999. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6000. static int alc861_parse_auto_config(struct hda_codec *codec)
  6001. {
  6002. struct alc_spec *spec = codec->spec;
  6003. int err;
  6004. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6005. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6006. alc861_ignore)) < 0)
  6007. return err;
  6008. if (! spec->autocfg.line_outs)
  6009. return 0; /* can't find valid BIOS pin config */
  6010. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6011. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6012. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6013. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6014. return err;
  6015. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6016. if (spec->autocfg.dig_out_pin)
  6017. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6018. if (spec->kctl_alloc)
  6019. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6020. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6021. spec->num_mux_defs = 1;
  6022. spec->input_mux = &spec->private_imux;
  6023. spec->adc_nids = alc861_adc_nids;
  6024. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6025. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6026. spec->num_mixers++;
  6027. return 1;
  6028. }
  6029. /* additional initialization for auto-configuration model */
  6030. static void alc861_auto_init(struct hda_codec *codec)
  6031. {
  6032. alc861_auto_init_multi_out(codec);
  6033. alc861_auto_init_hp_out(codec);
  6034. alc861_auto_init_analog_input(codec);
  6035. }
  6036. /*
  6037. * configuration and preset
  6038. */
  6039. static struct hda_board_config alc861_cfg_tbl[] = {
  6040. { .modelname = "3stack", .config = ALC861_3ST },
  6041. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
  6042. .config = ALC861_3ST },
  6043. { .modelname = "3stack-660", .config = ALC660_3ST },
  6044. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
  6045. .config = ALC660_3ST },
  6046. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  6047. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  6048. { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
  6049. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
  6050. .config = ALC861_UNIWILL_M31 },
  6051. { .modelname = "auto", .config = ALC861_AUTO },
  6052. {}
  6053. };
  6054. static struct alc_config_preset alc861_presets[] = {
  6055. [ALC861_3ST] = {
  6056. .mixers = { alc861_3ST_mixer },
  6057. .init_verbs = { alc861_threestack_init_verbs },
  6058. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6059. .dac_nids = alc861_dac_nids,
  6060. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6061. .channel_mode = alc861_threestack_modes,
  6062. .need_dac_fix = 1,
  6063. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6064. .adc_nids = alc861_adc_nids,
  6065. .input_mux = &alc861_capture_source,
  6066. },
  6067. [ALC861_3ST_DIG] = {
  6068. .mixers = { alc861_base_mixer },
  6069. .init_verbs = { alc861_threestack_init_verbs },
  6070. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6071. .dac_nids = alc861_dac_nids,
  6072. .dig_out_nid = ALC861_DIGOUT_NID,
  6073. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6074. .channel_mode = alc861_threestack_modes,
  6075. .need_dac_fix = 1,
  6076. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6077. .adc_nids = alc861_adc_nids,
  6078. .input_mux = &alc861_capture_source,
  6079. },
  6080. [ALC861_6ST_DIG] = {
  6081. .mixers = { alc861_base_mixer },
  6082. .init_verbs = { alc861_base_init_verbs },
  6083. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6084. .dac_nids = alc861_dac_nids,
  6085. .dig_out_nid = ALC861_DIGOUT_NID,
  6086. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6087. .channel_mode = alc861_8ch_modes,
  6088. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6089. .adc_nids = alc861_adc_nids,
  6090. .input_mux = &alc861_capture_source,
  6091. },
  6092. [ALC660_3ST] = {
  6093. .mixers = { alc861_3ST_mixer },
  6094. .init_verbs = { alc861_threestack_init_verbs },
  6095. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6096. .dac_nids = alc660_dac_nids,
  6097. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6098. .channel_mode = alc861_threestack_modes,
  6099. .need_dac_fix = 1,
  6100. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6101. .adc_nids = alc861_adc_nids,
  6102. .input_mux = &alc861_capture_source,
  6103. },
  6104. [ALC861_UNIWILL_M31] = {
  6105. .mixers = { alc861_uniwill_m31_mixer },
  6106. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6107. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6108. .dac_nids = alc861_dac_nids,
  6109. .dig_out_nid = ALC861_DIGOUT_NID,
  6110. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6111. .channel_mode = alc861_uniwill_m31_modes,
  6112. .need_dac_fix = 1,
  6113. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6114. .adc_nids = alc861_adc_nids,
  6115. .input_mux = &alc861_capture_source,
  6116. },
  6117. };
  6118. static int patch_alc861(struct hda_codec *codec)
  6119. {
  6120. struct alc_spec *spec;
  6121. int board_config;
  6122. int err;
  6123. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  6124. if (spec == NULL)
  6125. return -ENOMEM;
  6126. codec->spec = spec;
  6127. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  6128. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  6129. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6130. "trying auto-probe from BIOS...\n");
  6131. board_config = ALC861_AUTO;
  6132. }
  6133. if (board_config == ALC861_AUTO) {
  6134. /* automatic parse from the BIOS config */
  6135. err = alc861_parse_auto_config(codec);
  6136. if (err < 0) {
  6137. alc_free(codec);
  6138. return err;
  6139. } else if (! err) {
  6140. printk(KERN_INFO
  6141. "hda_codec: Cannot set up configuration "
  6142. "from BIOS. Using base mode...\n");
  6143. board_config = ALC861_3ST_DIG;
  6144. }
  6145. }
  6146. if (board_config != ALC861_AUTO)
  6147. setup_preset(spec, &alc861_presets[board_config]);
  6148. spec->stream_name_analog = "ALC861 Analog";
  6149. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6150. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6151. spec->stream_name_digital = "ALC861 Digital";
  6152. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6153. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6154. codec->patch_ops = alc_patch_ops;
  6155. if (board_config == ALC861_AUTO)
  6156. spec->init_hook = alc861_auto_init;
  6157. return 0;
  6158. }
  6159. /*
  6160. * patch entries
  6161. */
  6162. struct hda_codec_preset snd_hda_preset_realtek[] = {
  6163. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  6164. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  6165. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  6166. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  6167. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  6168. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  6169. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  6170. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  6171. .patch = patch_alc861 },
  6172. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  6173. .patch = patch_alc861 },
  6174. {} /* terminator */
  6175. };