patch_realtek.c 238 KB

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