patch_realtek.c 224 KB

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