patch_realtek.c 226 KB

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