patch_realtek.c 232 KB

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