patch_sigmatel.c 182 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for SigmaTel STAC92xx
  5. *
  6. * Copyright (c) 2005 Embedded Alley Solutions, Inc.
  7. * Matt Porter <mporter@embeddedalley.com>
  8. *
  9. * Based on patch_cmedia.c and patch_realtek.c
  10. * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
  11. *
  12. * This driver is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This driver is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <linux/dmi.h>
  31. #include <linux/module.h>
  32. #include <sound/core.h>
  33. #include <sound/asoundef.h>
  34. #include <sound/jack.h>
  35. #include <sound/tlv.h>
  36. #include "hda_codec.h"
  37. #include "hda_local.h"
  38. #include "hda_auto_parser.h"
  39. #include "hda_beep.h"
  40. #include "hda_jack.h"
  41. enum {
  42. STAC_VREF_EVENT = 1,
  43. STAC_INSERT_EVENT,
  44. STAC_PWR_EVENT,
  45. STAC_HP_EVENT,
  46. STAC_LO_EVENT,
  47. STAC_MIC_EVENT,
  48. };
  49. enum {
  50. STAC_AUTO,
  51. STAC_REF,
  52. STAC_9200_OQO,
  53. STAC_9200_DELL_D21,
  54. STAC_9200_DELL_D22,
  55. STAC_9200_DELL_D23,
  56. STAC_9200_DELL_M21,
  57. STAC_9200_DELL_M22,
  58. STAC_9200_DELL_M23,
  59. STAC_9200_DELL_M24,
  60. STAC_9200_DELL_M25,
  61. STAC_9200_DELL_M26,
  62. STAC_9200_DELL_M27,
  63. STAC_9200_M4,
  64. STAC_9200_M4_2,
  65. STAC_9200_PANASONIC,
  66. STAC_9200_MODELS
  67. };
  68. enum {
  69. STAC_9205_AUTO,
  70. STAC_9205_REF,
  71. STAC_9205_DELL_M42,
  72. STAC_9205_DELL_M43,
  73. STAC_9205_DELL_M44,
  74. STAC_9205_EAPD,
  75. STAC_9205_MODELS
  76. };
  77. enum {
  78. STAC_92HD73XX_AUTO,
  79. STAC_92HD73XX_NO_JD, /* no jack-detection */
  80. STAC_92HD73XX_REF,
  81. STAC_92HD73XX_INTEL,
  82. STAC_DELL_M6_AMIC,
  83. STAC_DELL_M6_DMIC,
  84. STAC_DELL_M6_BOTH,
  85. STAC_DELL_EQ,
  86. STAC_ALIENWARE_M17X,
  87. STAC_92HD73XX_MODELS
  88. };
  89. enum {
  90. STAC_92HD83XXX_AUTO,
  91. STAC_92HD83XXX_REF,
  92. STAC_92HD83XXX_PWR_REF,
  93. STAC_DELL_S14,
  94. STAC_DELL_VOSTRO_3500,
  95. STAC_92HD83XXX_HP_cNB11_INTQUAD,
  96. STAC_HP_DV7_4000,
  97. STAC_HP_ZEPHYR,
  98. STAC_92HD83XXX_MODELS
  99. };
  100. enum {
  101. STAC_92HD71BXX_AUTO,
  102. STAC_92HD71BXX_REF,
  103. STAC_DELL_M4_1,
  104. STAC_DELL_M4_2,
  105. STAC_DELL_M4_3,
  106. STAC_HP_M4,
  107. STAC_HP_DV4,
  108. STAC_HP_DV5,
  109. STAC_HP_HDX,
  110. STAC_HP_DV4_1222NR,
  111. STAC_92HD71BXX_MODELS
  112. };
  113. enum {
  114. STAC_925x_AUTO,
  115. STAC_925x_REF,
  116. STAC_M1,
  117. STAC_M1_2,
  118. STAC_M2,
  119. STAC_M2_2,
  120. STAC_M3,
  121. STAC_M5,
  122. STAC_M6,
  123. STAC_925x_MODELS
  124. };
  125. enum {
  126. STAC_922X_AUTO,
  127. STAC_D945_REF,
  128. STAC_D945GTP3,
  129. STAC_D945GTP5,
  130. STAC_INTEL_MAC_V1,
  131. STAC_INTEL_MAC_V2,
  132. STAC_INTEL_MAC_V3,
  133. STAC_INTEL_MAC_V4,
  134. STAC_INTEL_MAC_V5,
  135. STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
  136. * is given, one of the above models will be
  137. * chosen according to the subsystem id. */
  138. /* for backward compatibility */
  139. STAC_MACMINI,
  140. STAC_MACBOOK,
  141. STAC_MACBOOK_PRO_V1,
  142. STAC_MACBOOK_PRO_V2,
  143. STAC_IMAC_INTEL,
  144. STAC_IMAC_INTEL_20,
  145. STAC_ECS_202,
  146. STAC_922X_DELL_D81,
  147. STAC_922X_DELL_D82,
  148. STAC_922X_DELL_M81,
  149. STAC_922X_DELL_M82,
  150. STAC_922X_MODELS
  151. };
  152. enum {
  153. STAC_927X_AUTO,
  154. STAC_D965_REF_NO_JD, /* no jack-detection */
  155. STAC_D965_REF,
  156. STAC_D965_3ST,
  157. STAC_D965_5ST,
  158. STAC_D965_5ST_NO_FP,
  159. STAC_DELL_3ST,
  160. STAC_DELL_BIOS,
  161. STAC_927X_VOLKNOB,
  162. STAC_927X_MODELS
  163. };
  164. enum {
  165. STAC_9872_AUTO,
  166. STAC_9872_VAIO,
  167. STAC_9872_MODELS
  168. };
  169. struct sigmatel_mic_route {
  170. hda_nid_t pin;
  171. signed char mux_idx;
  172. signed char dmux_idx;
  173. };
  174. #define MAX_PINS_NUM 16
  175. #define MAX_ADCS_NUM 4
  176. #define MAX_DMICS_NUM 4
  177. struct sigmatel_spec {
  178. struct snd_kcontrol_new *mixers[4];
  179. unsigned int num_mixers;
  180. int board_config;
  181. unsigned int eapd_switch: 1;
  182. unsigned int surr_switch: 1;
  183. unsigned int alt_switch: 1;
  184. unsigned int hp_detect: 1;
  185. unsigned int spdif_mute: 1;
  186. unsigned int check_volume_offset:1;
  187. unsigned int auto_mic:1;
  188. unsigned int linear_tone_beep:1;
  189. /* gpio lines */
  190. unsigned int eapd_mask;
  191. unsigned int gpio_mask;
  192. unsigned int gpio_dir;
  193. unsigned int gpio_data;
  194. unsigned int gpio_mute;
  195. unsigned int gpio_led;
  196. unsigned int gpio_led_polarity;
  197. unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
  198. unsigned int vref_led;
  199. /* stream */
  200. unsigned int stream_delay;
  201. /* analog loopback */
  202. const struct snd_kcontrol_new *aloopback_ctl;
  203. unsigned char aloopback_mask;
  204. unsigned char aloopback_shift;
  205. /* power management */
  206. unsigned int power_map_bits;
  207. unsigned int num_pwrs;
  208. const hda_nid_t *pwr_nids;
  209. const hda_nid_t *dac_list;
  210. /* playback */
  211. struct hda_input_mux *mono_mux;
  212. unsigned int cur_mmux;
  213. struct hda_multi_out multiout;
  214. hda_nid_t dac_nids[5];
  215. hda_nid_t hp_dacs[5];
  216. hda_nid_t speaker_dacs[5];
  217. int volume_offset;
  218. /* capture */
  219. const hda_nid_t *adc_nids;
  220. unsigned int num_adcs;
  221. const hda_nid_t *mux_nids;
  222. unsigned int num_muxes;
  223. const hda_nid_t *dmic_nids;
  224. unsigned int num_dmics;
  225. const hda_nid_t *dmux_nids;
  226. unsigned int num_dmuxes;
  227. const hda_nid_t *smux_nids;
  228. unsigned int num_smuxes;
  229. unsigned int num_analog_muxes;
  230. const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
  231. const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
  232. unsigned int num_caps; /* number of capture volume/switch elements */
  233. struct sigmatel_mic_route ext_mic;
  234. struct sigmatel_mic_route int_mic;
  235. struct sigmatel_mic_route dock_mic;
  236. const char * const *spdif_labels;
  237. hda_nid_t dig_in_nid;
  238. hda_nid_t mono_nid;
  239. hda_nid_t anabeep_nid;
  240. hda_nid_t digbeep_nid;
  241. /* pin widgets */
  242. const hda_nid_t *pin_nids;
  243. unsigned int num_pins;
  244. /* codec specific stuff */
  245. const struct hda_verb *init;
  246. const struct snd_kcontrol_new *mixer;
  247. /* capture source */
  248. struct hda_input_mux *dinput_mux;
  249. unsigned int cur_dmux[2];
  250. struct hda_input_mux *input_mux;
  251. unsigned int cur_mux[3];
  252. struct hda_input_mux *sinput_mux;
  253. unsigned int cur_smux[2];
  254. unsigned int cur_amux;
  255. hda_nid_t *amp_nids;
  256. unsigned int powerdown_adcs;
  257. /* i/o switches */
  258. unsigned int io_switch[2];
  259. unsigned int clfe_swap;
  260. hda_nid_t line_switch; /* shared line-in for input and output */
  261. hda_nid_t mic_switch; /* shared mic-in for input and output */
  262. hda_nid_t hp_switch; /* NID of HP as line-out */
  263. unsigned int aloopback;
  264. struct hda_pcm pcm_rec[2]; /* PCM information */
  265. /* dynamic controls and input_mux */
  266. struct auto_pin_cfg autocfg;
  267. struct snd_array kctls;
  268. struct hda_input_mux private_dimux;
  269. struct hda_input_mux private_imux;
  270. struct hda_input_mux private_smux;
  271. struct hda_input_mux private_mono_mux;
  272. /* auto spec */
  273. unsigned auto_pin_cnt;
  274. hda_nid_t auto_pin_nids[MAX_PINS_NUM];
  275. unsigned auto_adc_cnt;
  276. hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
  277. hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
  278. hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
  279. unsigned long auto_capvols[MAX_ADCS_NUM];
  280. unsigned auto_dmic_cnt;
  281. hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
  282. struct hda_vmaster_mute_hook vmaster_mute;
  283. };
  284. #define AC_VERB_IDT_SET_POWER_MAP 0x7ec
  285. #define AC_VERB_IDT_GET_POWER_MAP 0xfec
  286. static const hda_nid_t stac9200_adc_nids[1] = {
  287. 0x03,
  288. };
  289. static const hda_nid_t stac9200_mux_nids[1] = {
  290. 0x0c,
  291. };
  292. static const hda_nid_t stac9200_dac_nids[1] = {
  293. 0x02,
  294. };
  295. static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
  296. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  297. 0x0f, 0x10, 0x11
  298. };
  299. static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
  300. 0x26, 0,
  301. };
  302. static const hda_nid_t stac92hd73xx_adc_nids[2] = {
  303. 0x1a, 0x1b
  304. };
  305. #define STAC92HD73XX_NUM_DMICS 2
  306. static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
  307. 0x13, 0x14, 0
  308. };
  309. #define STAC92HD73_DAC_COUNT 5
  310. static const hda_nid_t stac92hd73xx_mux_nids[2] = {
  311. 0x20, 0x21,
  312. };
  313. static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
  314. 0x20, 0x21,
  315. };
  316. static const hda_nid_t stac92hd73xx_smux_nids[2] = {
  317. 0x22, 0x23,
  318. };
  319. #define STAC92HD73XX_NUM_CAPS 2
  320. static const unsigned long stac92hd73xx_capvols[] = {
  321. HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
  322. HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
  323. };
  324. #define stac92hd73xx_capsws stac92hd73xx_capvols
  325. #define STAC92HD83_DAC_COUNT 3
  326. static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
  327. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  328. 0x0f, 0x10
  329. };
  330. static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
  331. 0x1e, 0,
  332. };
  333. static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
  334. 0x11, 0x20,
  335. };
  336. static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
  337. 0x0a, 0x0d, 0x0f
  338. };
  339. static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
  340. 0x12, 0x13,
  341. };
  342. static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
  343. 0x1a, 0x1b
  344. };
  345. static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
  346. 0x1c, 0x1d,
  347. };
  348. static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
  349. 0x24, 0x25,
  350. };
  351. #define STAC92HD71BXX_NUM_DMICS 2
  352. static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
  353. 0x18, 0x19, 0
  354. };
  355. static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
  356. 0x18, 0
  357. };
  358. static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
  359. 0x22, 0
  360. };
  361. #define STAC92HD71BXX_NUM_CAPS 2
  362. static const unsigned long stac92hd71bxx_capvols[] = {
  363. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
  364. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  365. };
  366. #define stac92hd71bxx_capsws stac92hd71bxx_capvols
  367. static const hda_nid_t stac925x_adc_nids[1] = {
  368. 0x03,
  369. };
  370. static const hda_nid_t stac925x_mux_nids[1] = {
  371. 0x0f,
  372. };
  373. static const hda_nid_t stac925x_dac_nids[1] = {
  374. 0x02,
  375. };
  376. #define STAC925X_NUM_DMICS 1
  377. static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
  378. 0x15, 0
  379. };
  380. static const hda_nid_t stac925x_dmux_nids[1] = {
  381. 0x14,
  382. };
  383. static const unsigned long stac925x_capvols[] = {
  384. HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
  385. };
  386. static const unsigned long stac925x_capsws[] = {
  387. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  388. };
  389. static const hda_nid_t stac922x_adc_nids[2] = {
  390. 0x06, 0x07,
  391. };
  392. static const hda_nid_t stac922x_mux_nids[2] = {
  393. 0x12, 0x13,
  394. };
  395. #define STAC922X_NUM_CAPS 2
  396. static const unsigned long stac922x_capvols[] = {
  397. HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
  398. HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
  399. };
  400. #define stac922x_capsws stac922x_capvols
  401. static const hda_nid_t stac927x_slave_dig_outs[2] = {
  402. 0x1f, 0,
  403. };
  404. static const hda_nid_t stac927x_adc_nids[3] = {
  405. 0x07, 0x08, 0x09
  406. };
  407. static const hda_nid_t stac927x_mux_nids[3] = {
  408. 0x15, 0x16, 0x17
  409. };
  410. static const hda_nid_t stac927x_smux_nids[1] = {
  411. 0x21,
  412. };
  413. static const hda_nid_t stac927x_dac_nids[6] = {
  414. 0x02, 0x03, 0x04, 0x05, 0x06, 0
  415. };
  416. static const hda_nid_t stac927x_dmux_nids[1] = {
  417. 0x1b,
  418. };
  419. #define STAC927X_NUM_DMICS 2
  420. static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
  421. 0x13, 0x14, 0
  422. };
  423. #define STAC927X_NUM_CAPS 3
  424. static const unsigned long stac927x_capvols[] = {
  425. HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
  426. HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
  427. HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
  428. };
  429. static const unsigned long stac927x_capsws[] = {
  430. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
  431. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
  432. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  433. };
  434. static const char * const stac927x_spdif_labels[5] = {
  435. "Digital Playback", "ADAT", "Analog Mux 1",
  436. "Analog Mux 2", "Analog Mux 3"
  437. };
  438. static const hda_nid_t stac9205_adc_nids[2] = {
  439. 0x12, 0x13
  440. };
  441. static const hda_nid_t stac9205_mux_nids[2] = {
  442. 0x19, 0x1a
  443. };
  444. static const hda_nid_t stac9205_dmux_nids[1] = {
  445. 0x1d,
  446. };
  447. static const hda_nid_t stac9205_smux_nids[1] = {
  448. 0x21,
  449. };
  450. #define STAC9205_NUM_DMICS 2
  451. static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
  452. 0x17, 0x18, 0
  453. };
  454. #define STAC9205_NUM_CAPS 2
  455. static const unsigned long stac9205_capvols[] = {
  456. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
  457. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
  458. };
  459. static const unsigned long stac9205_capsws[] = {
  460. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  461. HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
  462. };
  463. static const hda_nid_t stac9200_pin_nids[8] = {
  464. 0x08, 0x09, 0x0d, 0x0e,
  465. 0x0f, 0x10, 0x11, 0x12,
  466. };
  467. static const hda_nid_t stac925x_pin_nids[8] = {
  468. 0x07, 0x08, 0x0a, 0x0b,
  469. 0x0c, 0x0d, 0x10, 0x11,
  470. };
  471. static const hda_nid_t stac922x_pin_nids[10] = {
  472. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  473. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  474. };
  475. static const hda_nid_t stac92hd73xx_pin_nids[13] = {
  476. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  477. 0x0f, 0x10, 0x11, 0x12, 0x13,
  478. 0x14, 0x22, 0x23
  479. };
  480. #define STAC92HD71BXX_NUM_PINS 13
  481. static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
  482. 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
  483. 0x00, 0x14, 0x18, 0x19, 0x1e,
  484. 0x1f, 0x20, 0x27
  485. };
  486. static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
  487. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  488. 0x0f, 0x14, 0x18, 0x19, 0x1e,
  489. 0x1f, 0x20, 0x27
  490. };
  491. static const hda_nid_t stac927x_pin_nids[14] = {
  492. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  493. 0x0f, 0x10, 0x11, 0x12, 0x13,
  494. 0x14, 0x21, 0x22, 0x23,
  495. };
  496. static const hda_nid_t stac9205_pin_nids[12] = {
  497. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  498. 0x0f, 0x14, 0x16, 0x17, 0x18,
  499. 0x21, 0x22,
  500. };
  501. static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
  502. struct snd_ctl_elem_info *uinfo)
  503. {
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. struct sigmatel_spec *spec = codec->spec;
  506. return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
  507. }
  508. static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
  509. struct snd_ctl_elem_value *ucontrol)
  510. {
  511. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  512. struct sigmatel_spec *spec = codec->spec;
  513. unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  514. ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
  515. return 0;
  516. }
  517. static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  521. struct sigmatel_spec *spec = codec->spec;
  522. unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  523. return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
  524. spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
  525. }
  526. static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
  527. struct snd_ctl_elem_info *uinfo)
  528. {
  529. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  530. struct sigmatel_spec *spec = codec->spec;
  531. return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
  532. }
  533. static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
  534. struct snd_ctl_elem_value *ucontrol)
  535. {
  536. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  537. struct sigmatel_spec *spec = codec->spec;
  538. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  539. ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
  540. return 0;
  541. }
  542. static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
  543. struct snd_ctl_elem_value *ucontrol)
  544. {
  545. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  546. struct sigmatel_spec *spec = codec->spec;
  547. struct hda_input_mux *smux = &spec->private_smux;
  548. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  549. int err, val;
  550. hda_nid_t nid;
  551. err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
  552. spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
  553. if (err < 0)
  554. return err;
  555. if (spec->spdif_mute) {
  556. if (smux_idx == 0)
  557. nid = spec->multiout.dig_out_nid;
  558. else
  559. nid = codec->slave_dig_outs[smux_idx - 1];
  560. if (spec->cur_smux[smux_idx] == smux->num_items - 1)
  561. val = HDA_AMP_MUTE;
  562. else
  563. val = 0;
  564. /* un/mute SPDIF out */
  565. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  566. HDA_AMP_MUTE, val);
  567. }
  568. return 0;
  569. }
  570. static int stac_vrefout_set(struct hda_codec *codec,
  571. hda_nid_t nid, unsigned int new_vref)
  572. {
  573. int error, pinctl;
  574. snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
  575. pinctl = snd_hda_codec_read(codec, nid, 0,
  576. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  577. if (pinctl < 0)
  578. return pinctl;
  579. pinctl &= 0xff;
  580. pinctl &= ~AC_PINCTL_VREFEN;
  581. pinctl |= (new_vref & AC_PINCTL_VREFEN);
  582. error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
  583. if (error < 0)
  584. return error;
  585. return 1;
  586. }
  587. static unsigned int stac92xx_vref_set(struct hda_codec *codec,
  588. hda_nid_t nid, unsigned int new_vref)
  589. {
  590. int error;
  591. unsigned int pincfg;
  592. pincfg = snd_hda_codec_read(codec, nid, 0,
  593. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  594. pincfg &= 0xff;
  595. pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
  596. pincfg |= new_vref;
  597. if (new_vref == AC_PINCTL_VREF_HIZ)
  598. pincfg |= AC_PINCTL_OUT_EN;
  599. else
  600. pincfg |= AC_PINCTL_IN_EN;
  601. error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
  602. if (error < 0)
  603. return error;
  604. else
  605. return 1;
  606. }
  607. static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
  608. {
  609. unsigned int vref;
  610. vref = snd_hda_codec_read(codec, nid, 0,
  611. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  612. vref &= AC_PINCTL_VREFEN;
  613. return vref;
  614. }
  615. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  616. {
  617. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  618. struct sigmatel_spec *spec = codec->spec;
  619. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  620. }
  621. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  622. {
  623. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  624. struct sigmatel_spec *spec = codec->spec;
  625. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  626. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  627. return 0;
  628. }
  629. static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  630. {
  631. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  632. struct sigmatel_spec *spec = codec->spec;
  633. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  634. const struct hda_input_mux *imux = spec->input_mux;
  635. unsigned int idx, prev_idx, didx;
  636. idx = ucontrol->value.enumerated.item[0];
  637. if (idx >= imux->num_items)
  638. idx = imux->num_items - 1;
  639. prev_idx = spec->cur_mux[adc_idx];
  640. if (prev_idx == idx)
  641. return 0;
  642. if (idx < spec->num_analog_muxes) {
  643. snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
  644. AC_VERB_SET_CONNECT_SEL,
  645. imux->items[idx].index);
  646. if (prev_idx >= spec->num_analog_muxes &&
  647. spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
  648. imux = spec->dinput_mux;
  649. /* 0 = analog */
  650. snd_hda_codec_write_cache(codec,
  651. spec->dmux_nids[adc_idx], 0,
  652. AC_VERB_SET_CONNECT_SEL,
  653. imux->items[0].index);
  654. }
  655. } else {
  656. imux = spec->dinput_mux;
  657. /* first dimux item is hardcoded to select analog imux,
  658. * so lets skip it
  659. */
  660. didx = idx - spec->num_analog_muxes + 1;
  661. snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
  662. AC_VERB_SET_CONNECT_SEL,
  663. imux->items[didx].index);
  664. }
  665. spec->cur_mux[adc_idx] = idx;
  666. return 1;
  667. }
  668. static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
  669. struct snd_ctl_elem_info *uinfo)
  670. {
  671. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  672. struct sigmatel_spec *spec = codec->spec;
  673. return snd_hda_input_mux_info(spec->mono_mux, uinfo);
  674. }
  675. static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
  676. struct snd_ctl_elem_value *ucontrol)
  677. {
  678. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  679. struct sigmatel_spec *spec = codec->spec;
  680. ucontrol->value.enumerated.item[0] = spec->cur_mmux;
  681. return 0;
  682. }
  683. static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
  684. struct snd_ctl_elem_value *ucontrol)
  685. {
  686. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  687. struct sigmatel_spec *spec = codec->spec;
  688. return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
  689. spec->mono_nid, &spec->cur_mmux);
  690. }
  691. #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
  692. static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
  693. struct snd_ctl_elem_value *ucontrol)
  694. {
  695. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  696. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  697. struct sigmatel_spec *spec = codec->spec;
  698. ucontrol->value.integer.value[0] = !!(spec->aloopback &
  699. (spec->aloopback_mask << idx));
  700. return 0;
  701. }
  702. static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
  703. struct snd_ctl_elem_value *ucontrol)
  704. {
  705. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  706. struct sigmatel_spec *spec = codec->spec;
  707. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  708. unsigned int dac_mode;
  709. unsigned int val, idx_val;
  710. idx_val = spec->aloopback_mask << idx;
  711. if (ucontrol->value.integer.value[0])
  712. val = spec->aloopback | idx_val;
  713. else
  714. val = spec->aloopback & ~idx_val;
  715. if (spec->aloopback == val)
  716. return 0;
  717. spec->aloopback = val;
  718. /* Only return the bits defined by the shift value of the
  719. * first two bytes of the mask
  720. */
  721. dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
  722. kcontrol->private_value & 0xFFFF, 0x0);
  723. dac_mode >>= spec->aloopback_shift;
  724. if (spec->aloopback & idx_val) {
  725. snd_hda_power_up(codec);
  726. dac_mode |= idx_val;
  727. } else {
  728. snd_hda_power_down(codec);
  729. dac_mode &= ~idx_val;
  730. }
  731. snd_hda_codec_write_cache(codec, codec->afg, 0,
  732. kcontrol->private_value >> 16, dac_mode);
  733. return 1;
  734. }
  735. static const struct hda_verb stac9200_core_init[] = {
  736. /* set dac0mux for dac converter */
  737. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  738. {}
  739. };
  740. static const struct hda_verb stac9200_eapd_init[] = {
  741. /* set dac0mux for dac converter */
  742. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  743. {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  744. {}
  745. };
  746. static const struct hda_verb dell_eq_core_init[] = {
  747. /* set master volume to max value without distortion
  748. * and direct control */
  749. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
  750. {}
  751. };
  752. static const struct hda_verb stac92hd73xx_core_init[] = {
  753. /* set master volume and direct control */
  754. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  755. {}
  756. };
  757. static const struct hda_verb stac92hd83xxx_core_init[] = {
  758. /* power state controls amps */
  759. { 0x01, AC_VERB_SET_EAPD, 1 << 2},
  760. {}
  761. };
  762. static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
  763. { 0x22, 0x785, 0x43 },
  764. { 0x22, 0x782, 0xe0 },
  765. { 0x22, 0x795, 0x00 },
  766. {}
  767. };
  768. static const struct hda_verb stac92hd71bxx_core_init[] = {
  769. /* set master volume and direct control */
  770. { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  771. {}
  772. };
  773. static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
  774. /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
  775. { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  776. { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  777. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  778. {}
  779. };
  780. static const struct hda_verb stac925x_core_init[] = {
  781. /* set dac0mux for dac converter */
  782. { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
  783. /* mute the master volume */
  784. { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  785. {}
  786. };
  787. static const struct hda_verb stac922x_core_init[] = {
  788. /* set master volume and direct control */
  789. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  790. {}
  791. };
  792. static const struct hda_verb d965_core_init[] = {
  793. /* set master volume and direct control */
  794. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  795. /* unmute node 0x1b */
  796. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  797. /* select node 0x03 as DAC */
  798. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  799. {}
  800. };
  801. static const struct hda_verb dell_3st_core_init[] = {
  802. /* don't set delta bit */
  803. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  804. /* unmute node 0x1b */
  805. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  806. /* select node 0x03 as DAC */
  807. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  808. {}
  809. };
  810. static const struct hda_verb stac927x_core_init[] = {
  811. /* set master volume and direct control */
  812. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  813. /* enable analog pc beep path */
  814. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  815. {}
  816. };
  817. static const struct hda_verb stac927x_volknob_core_init[] = {
  818. /* don't set delta bit */
  819. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  820. /* enable analog pc beep path */
  821. {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  822. {}
  823. };
  824. static const struct hda_verb stac9205_core_init[] = {
  825. /* set master volume and direct control */
  826. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  827. /* enable analog pc beep path */
  828. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  829. {}
  830. };
  831. #define STAC_MONO_MUX \
  832. { \
  833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  834. .name = "Mono Mux", \
  835. .count = 1, \
  836. .info = stac92xx_mono_mux_enum_info, \
  837. .get = stac92xx_mono_mux_enum_get, \
  838. .put = stac92xx_mono_mux_enum_put, \
  839. }
  840. #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
  841. { \
  842. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  843. .name = "Analog Loopback", \
  844. .count = cnt, \
  845. .info = stac92xx_aloopback_info, \
  846. .get = stac92xx_aloopback_get, \
  847. .put = stac92xx_aloopback_put, \
  848. .private_value = verb_read | (verb_write << 16), \
  849. }
  850. #define DC_BIAS(xname, idx, nid) \
  851. { \
  852. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  853. .name = xname, \
  854. .index = idx, \
  855. .info = stac92xx_dc_bias_info, \
  856. .get = stac92xx_dc_bias_get, \
  857. .put = stac92xx_dc_bias_put, \
  858. .private_value = nid, \
  859. }
  860. static const struct snd_kcontrol_new stac9200_mixer[] = {
  861. HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
  862. HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
  863. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  864. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  865. { } /* end */
  866. };
  867. static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
  868. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
  869. {}
  870. };
  871. static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
  872. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
  873. {}
  874. };
  875. static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
  876. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
  877. {}
  878. };
  879. static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
  880. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
  881. };
  882. static const struct snd_kcontrol_new stac925x_mixer[] = {
  883. HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
  884. HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
  885. { } /* end */
  886. };
  887. static const struct snd_kcontrol_new stac9205_loopback[] = {
  888. STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
  889. {}
  890. };
  891. static const struct snd_kcontrol_new stac927x_loopback[] = {
  892. STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
  893. {}
  894. };
  895. static struct snd_kcontrol_new stac_dmux_mixer = {
  896. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  897. .name = "Digital Input Source",
  898. /* count set later */
  899. .info = stac92xx_dmux_enum_info,
  900. .get = stac92xx_dmux_enum_get,
  901. .put = stac92xx_dmux_enum_put,
  902. };
  903. static struct snd_kcontrol_new stac_smux_mixer = {
  904. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  905. .name = "IEC958 Playback Source",
  906. /* count set later */
  907. .info = stac92xx_smux_enum_info,
  908. .get = stac92xx_smux_enum_get,
  909. .put = stac92xx_smux_enum_put,
  910. };
  911. static const char * const slave_pfxs[] = {
  912. "Front", "Surround", "Center", "LFE", "Side",
  913. "Headphone", "Speaker", "IEC958",
  914. NULL
  915. };
  916. static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
  917. static void stac92xx_vmaster_hook(void *private_data, int val)
  918. {
  919. stac92xx_update_led_status(private_data, val);
  920. }
  921. static void stac92xx_free_kctls(struct hda_codec *codec);
  922. static int stac92xx_build_controls(struct hda_codec *codec)
  923. {
  924. struct sigmatel_spec *spec = codec->spec;
  925. unsigned int vmaster_tlv[4];
  926. int err;
  927. int i;
  928. if (spec->mixer) {
  929. err = snd_hda_add_new_ctls(codec, spec->mixer);
  930. if (err < 0)
  931. return err;
  932. }
  933. for (i = 0; i < spec->num_mixers; i++) {
  934. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  935. if (err < 0)
  936. return err;
  937. }
  938. if (!spec->auto_mic && spec->num_dmuxes > 0 &&
  939. snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
  940. stac_dmux_mixer.count = spec->num_dmuxes;
  941. err = snd_hda_ctl_add(codec, 0,
  942. snd_ctl_new1(&stac_dmux_mixer, codec));
  943. if (err < 0)
  944. return err;
  945. }
  946. if (spec->num_smuxes > 0) {
  947. int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
  948. struct hda_input_mux *smux = &spec->private_smux;
  949. /* check for mute support on SPDIF out */
  950. if (wcaps & AC_WCAP_OUT_AMP) {
  951. snd_hda_add_imux_item(smux, "Off", 0, NULL);
  952. spec->spdif_mute = 1;
  953. }
  954. stac_smux_mixer.count = spec->num_smuxes;
  955. err = snd_hda_ctl_add(codec, 0,
  956. snd_ctl_new1(&stac_smux_mixer, codec));
  957. if (err < 0)
  958. return err;
  959. }
  960. if (spec->multiout.dig_out_nid) {
  961. err = snd_hda_create_spdif_out_ctls(codec,
  962. spec->multiout.dig_out_nid,
  963. spec->multiout.dig_out_nid);
  964. if (err < 0)
  965. return err;
  966. err = snd_hda_create_spdif_share_sw(codec,
  967. &spec->multiout);
  968. if (err < 0)
  969. return err;
  970. spec->multiout.share_spdif = 1;
  971. }
  972. if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
  973. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  974. if (err < 0)
  975. return err;
  976. }
  977. /* if we have no master control, let's create it */
  978. snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
  979. HDA_OUTPUT, vmaster_tlv);
  980. /* correct volume offset */
  981. vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
  982. /* minimum value is actually mute */
  983. vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
  984. err = snd_hda_add_vmaster(codec, "Master Playback Volume",
  985. vmaster_tlv, slave_pfxs,
  986. "Playback Volume");
  987. if (err < 0)
  988. return err;
  989. err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
  990. NULL, slave_pfxs,
  991. "Playback Switch", true,
  992. &spec->vmaster_mute.sw_kctl);
  993. if (err < 0)
  994. return err;
  995. if (spec->gpio_led) {
  996. spec->vmaster_mute.hook = stac92xx_vmaster_hook;
  997. err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
  998. if (err < 0)
  999. return err;
  1000. }
  1001. if (spec->aloopback_ctl &&
  1002. snd_hda_get_bool_hint(codec, "loopback") == 1) {
  1003. err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
  1004. if (err < 0)
  1005. return err;
  1006. }
  1007. stac92xx_free_kctls(codec); /* no longer needed */
  1008. err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
  1009. if (err < 0)
  1010. return err;
  1011. return 0;
  1012. }
  1013. static const unsigned int ref9200_pin_configs[8] = {
  1014. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  1015. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  1016. };
  1017. static const unsigned int gateway9200_m4_pin_configs[8] = {
  1018. 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
  1019. 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
  1020. };
  1021. static const unsigned int gateway9200_m4_2_pin_configs[8] = {
  1022. 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
  1023. 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
  1024. };
  1025. /*
  1026. STAC 9200 pin configs for
  1027. 102801A8
  1028. 102801DE
  1029. 102801E8
  1030. */
  1031. static const unsigned int dell9200_d21_pin_configs[8] = {
  1032. 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
  1033. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  1034. };
  1035. /*
  1036. STAC 9200 pin configs for
  1037. 102801C0
  1038. 102801C1
  1039. */
  1040. static const unsigned int dell9200_d22_pin_configs[8] = {
  1041. 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
  1042. 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
  1043. };
  1044. /*
  1045. STAC 9200 pin configs for
  1046. 102801C4 (Dell Dimension E310)
  1047. 102801C5
  1048. 102801C7
  1049. 102801D9
  1050. 102801DA
  1051. 102801E3
  1052. */
  1053. static const unsigned int dell9200_d23_pin_configs[8] = {
  1054. 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
  1055. 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
  1056. };
  1057. /*
  1058. STAC 9200-32 pin configs for
  1059. 102801B5 (Dell Inspiron 630m)
  1060. 102801D8 (Dell Inspiron 640m)
  1061. */
  1062. static const unsigned int dell9200_m21_pin_configs[8] = {
  1063. 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
  1064. 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
  1065. };
  1066. /*
  1067. STAC 9200-32 pin configs for
  1068. 102801C2 (Dell Latitude D620)
  1069. 102801C8
  1070. 102801CC (Dell Latitude D820)
  1071. 102801D4
  1072. 102801D6
  1073. */
  1074. static const unsigned int dell9200_m22_pin_configs[8] = {
  1075. 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
  1076. 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
  1077. };
  1078. /*
  1079. STAC 9200-32 pin configs for
  1080. 102801CE (Dell XPS M1710)
  1081. 102801CF (Dell Precision M90)
  1082. */
  1083. static const unsigned int dell9200_m23_pin_configs[8] = {
  1084. 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
  1085. 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
  1086. };
  1087. /*
  1088. STAC 9200-32 pin configs for
  1089. 102801C9
  1090. 102801CA
  1091. 102801CB (Dell Latitude 120L)
  1092. 102801D3
  1093. */
  1094. static const unsigned int dell9200_m24_pin_configs[8] = {
  1095. 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
  1096. 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
  1097. };
  1098. /*
  1099. STAC 9200-32 pin configs for
  1100. 102801BD (Dell Inspiron E1505n)
  1101. 102801EE
  1102. 102801EF
  1103. */
  1104. static const unsigned int dell9200_m25_pin_configs[8] = {
  1105. 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
  1106. 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
  1107. };
  1108. /*
  1109. STAC 9200-32 pin configs for
  1110. 102801F5 (Dell Inspiron 1501)
  1111. 102801F6
  1112. */
  1113. static const unsigned int dell9200_m26_pin_configs[8] = {
  1114. 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
  1115. 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
  1116. };
  1117. /*
  1118. STAC 9200-32
  1119. 102801CD (Dell Inspiron E1705/9400)
  1120. */
  1121. static const unsigned int dell9200_m27_pin_configs[8] = {
  1122. 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
  1123. 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
  1124. };
  1125. static const unsigned int oqo9200_pin_configs[8] = {
  1126. 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
  1127. 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
  1128. };
  1129. static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
  1130. [STAC_REF] = ref9200_pin_configs,
  1131. [STAC_9200_OQO] = oqo9200_pin_configs,
  1132. [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
  1133. [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
  1134. [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
  1135. [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
  1136. [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
  1137. [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
  1138. [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
  1139. [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
  1140. [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
  1141. [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
  1142. [STAC_9200_M4] = gateway9200_m4_pin_configs,
  1143. [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
  1144. [STAC_9200_PANASONIC] = ref9200_pin_configs,
  1145. };
  1146. static const char * const stac9200_models[STAC_9200_MODELS] = {
  1147. [STAC_AUTO] = "auto",
  1148. [STAC_REF] = "ref",
  1149. [STAC_9200_OQO] = "oqo",
  1150. [STAC_9200_DELL_D21] = "dell-d21",
  1151. [STAC_9200_DELL_D22] = "dell-d22",
  1152. [STAC_9200_DELL_D23] = "dell-d23",
  1153. [STAC_9200_DELL_M21] = "dell-m21",
  1154. [STAC_9200_DELL_M22] = "dell-m22",
  1155. [STAC_9200_DELL_M23] = "dell-m23",
  1156. [STAC_9200_DELL_M24] = "dell-m24",
  1157. [STAC_9200_DELL_M25] = "dell-m25",
  1158. [STAC_9200_DELL_M26] = "dell-m26",
  1159. [STAC_9200_DELL_M27] = "dell-m27",
  1160. [STAC_9200_M4] = "gateway-m4",
  1161. [STAC_9200_M4_2] = "gateway-m4-2",
  1162. [STAC_9200_PANASONIC] = "panasonic",
  1163. };
  1164. static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
  1165. /* SigmaTel reference board */
  1166. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1167. "DFI LanParty", STAC_REF),
  1168. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1169. "DFI LanParty", STAC_REF),
  1170. /* Dell laptops have BIOS problem */
  1171. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
  1172. "unknown Dell", STAC_9200_DELL_D21),
  1173. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
  1174. "Dell Inspiron 630m", STAC_9200_DELL_M21),
  1175. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
  1176. "Dell Inspiron E1505n", STAC_9200_DELL_M25),
  1177. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
  1178. "unknown Dell", STAC_9200_DELL_D22),
  1179. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
  1180. "unknown Dell", STAC_9200_DELL_D22),
  1181. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
  1182. "Dell Latitude D620", STAC_9200_DELL_M22),
  1183. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
  1184. "unknown Dell", STAC_9200_DELL_D23),
  1185. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
  1186. "unknown Dell", STAC_9200_DELL_D23),
  1187. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
  1188. "unknown Dell", STAC_9200_DELL_M22),
  1189. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
  1190. "unknown Dell", STAC_9200_DELL_M24),
  1191. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
  1192. "unknown Dell", STAC_9200_DELL_M24),
  1193. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
  1194. "Dell Latitude 120L", STAC_9200_DELL_M24),
  1195. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
  1196. "Dell Latitude D820", STAC_9200_DELL_M22),
  1197. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
  1198. "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
  1199. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
  1200. "Dell XPS M1710", STAC_9200_DELL_M23),
  1201. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
  1202. "Dell Precision M90", STAC_9200_DELL_M23),
  1203. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
  1204. "unknown Dell", STAC_9200_DELL_M22),
  1205. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
  1206. "unknown Dell", STAC_9200_DELL_M22),
  1207. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
  1208. "unknown Dell", STAC_9200_DELL_M22),
  1209. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
  1210. "Dell Inspiron 640m", STAC_9200_DELL_M21),
  1211. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
  1212. "unknown Dell", STAC_9200_DELL_D23),
  1213. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
  1214. "unknown Dell", STAC_9200_DELL_D23),
  1215. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
  1216. "unknown Dell", STAC_9200_DELL_D21),
  1217. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
  1218. "unknown Dell", STAC_9200_DELL_D23),
  1219. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
  1220. "unknown Dell", STAC_9200_DELL_D21),
  1221. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
  1222. "unknown Dell", STAC_9200_DELL_M25),
  1223. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
  1224. "unknown Dell", STAC_9200_DELL_M25),
  1225. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
  1226. "Dell Inspiron 1501", STAC_9200_DELL_M26),
  1227. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
  1228. "unknown Dell", STAC_9200_DELL_M26),
  1229. /* Panasonic */
  1230. SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
  1231. /* Gateway machines needs EAPD to be set on resume */
  1232. SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
  1233. SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
  1234. SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
  1235. /* OQO Mobile */
  1236. SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
  1237. {} /* terminator */
  1238. };
  1239. static const unsigned int ref925x_pin_configs[8] = {
  1240. 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
  1241. 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
  1242. };
  1243. static const unsigned int stac925xM1_pin_configs[8] = {
  1244. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1245. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1246. };
  1247. static const unsigned int stac925xM1_2_pin_configs[8] = {
  1248. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1249. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1250. };
  1251. static const unsigned int stac925xM2_pin_configs[8] = {
  1252. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1253. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1254. };
  1255. static const unsigned int stac925xM2_2_pin_configs[8] = {
  1256. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1257. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1258. };
  1259. static const unsigned int stac925xM3_pin_configs[8] = {
  1260. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1261. 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
  1262. };
  1263. static const unsigned int stac925xM5_pin_configs[8] = {
  1264. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1265. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1266. };
  1267. static const unsigned int stac925xM6_pin_configs[8] = {
  1268. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1269. 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
  1270. };
  1271. static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
  1272. [STAC_REF] = ref925x_pin_configs,
  1273. [STAC_M1] = stac925xM1_pin_configs,
  1274. [STAC_M1_2] = stac925xM1_2_pin_configs,
  1275. [STAC_M2] = stac925xM2_pin_configs,
  1276. [STAC_M2_2] = stac925xM2_2_pin_configs,
  1277. [STAC_M3] = stac925xM3_pin_configs,
  1278. [STAC_M5] = stac925xM5_pin_configs,
  1279. [STAC_M6] = stac925xM6_pin_configs,
  1280. };
  1281. static const char * const stac925x_models[STAC_925x_MODELS] = {
  1282. [STAC_925x_AUTO] = "auto",
  1283. [STAC_REF] = "ref",
  1284. [STAC_M1] = "m1",
  1285. [STAC_M1_2] = "m1-2",
  1286. [STAC_M2] = "m2",
  1287. [STAC_M2_2] = "m2-2",
  1288. [STAC_M3] = "m3",
  1289. [STAC_M5] = "m5",
  1290. [STAC_M6] = "m6",
  1291. };
  1292. static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
  1293. SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
  1294. SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
  1295. SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
  1296. SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
  1297. SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
  1298. /* Not sure about the brand name for those */
  1299. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
  1300. SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
  1301. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
  1302. SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
  1303. {} /* terminator */
  1304. };
  1305. static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
  1306. /* SigmaTel reference board */
  1307. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
  1308. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
  1309. SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
  1310. /* Default table for unknown ID */
  1311. SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
  1312. {} /* terminator */
  1313. };
  1314. static const unsigned int ref92hd73xx_pin_configs[13] = {
  1315. 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
  1316. 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
  1317. 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
  1318. 0x01452050,
  1319. };
  1320. static const unsigned int dell_m6_pin_configs[13] = {
  1321. 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
  1322. 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
  1323. 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
  1324. 0x4f0000f0,
  1325. };
  1326. static const unsigned int alienware_m17x_pin_configs[13] = {
  1327. 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
  1328. 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
  1329. 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
  1330. 0x904601b0,
  1331. };
  1332. static const unsigned int intel_dg45id_pin_configs[13] = {
  1333. 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
  1334. 0x01A19250, 0x01011212, 0x01016211
  1335. };
  1336. static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
  1337. [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
  1338. [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
  1339. [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
  1340. [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
  1341. [STAC_DELL_EQ] = dell_m6_pin_configs,
  1342. [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
  1343. [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
  1344. };
  1345. static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
  1346. [STAC_92HD73XX_AUTO] = "auto",
  1347. [STAC_92HD73XX_NO_JD] = "no-jd",
  1348. [STAC_92HD73XX_REF] = "ref",
  1349. [STAC_92HD73XX_INTEL] = "intel",
  1350. [STAC_DELL_M6_AMIC] = "dell-m6-amic",
  1351. [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
  1352. [STAC_DELL_M6_BOTH] = "dell-m6",
  1353. [STAC_DELL_EQ] = "dell-eq",
  1354. [STAC_ALIENWARE_M17X] = "alienware",
  1355. };
  1356. static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
  1357. /* SigmaTel reference board */
  1358. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1359. "DFI LanParty", STAC_92HD73XX_REF),
  1360. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1361. "DFI LanParty", STAC_92HD73XX_REF),
  1362. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
  1363. "Intel DG45ID", STAC_92HD73XX_INTEL),
  1364. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
  1365. "Intel DG45FC", STAC_92HD73XX_INTEL),
  1366. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
  1367. "Dell Studio 1535", STAC_DELL_M6_DMIC),
  1368. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
  1369. "unknown Dell", STAC_DELL_M6_DMIC),
  1370. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
  1371. "unknown Dell", STAC_DELL_M6_BOTH),
  1372. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
  1373. "unknown Dell", STAC_DELL_M6_BOTH),
  1374. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
  1375. "unknown Dell", STAC_DELL_M6_AMIC),
  1376. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
  1377. "unknown Dell", STAC_DELL_M6_AMIC),
  1378. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
  1379. "unknown Dell", STAC_DELL_M6_DMIC),
  1380. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
  1381. "unknown Dell", STAC_DELL_M6_DMIC),
  1382. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
  1383. "Dell Studio 1537", STAC_DELL_M6_DMIC),
  1384. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
  1385. "Dell Studio 17", STAC_DELL_M6_DMIC),
  1386. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
  1387. "Dell Studio 1555", STAC_DELL_M6_DMIC),
  1388. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
  1389. "Dell Studio 1557", STAC_DELL_M6_DMIC),
  1390. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
  1391. "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
  1392. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
  1393. "Dell Studio 1558", STAC_DELL_M6_DMIC),
  1394. {} /* terminator */
  1395. };
  1396. static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
  1397. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
  1398. "Alienware M17x", STAC_ALIENWARE_M17X),
  1399. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
  1400. "Alienware M17x", STAC_ALIENWARE_M17X),
  1401. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
  1402. "Alienware M17x R3", STAC_DELL_EQ),
  1403. {} /* terminator */
  1404. };
  1405. static const unsigned int ref92hd83xxx_pin_configs[10] = {
  1406. 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
  1407. 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
  1408. 0x01451160, 0x98560170,
  1409. };
  1410. static const unsigned int dell_s14_pin_configs[10] = {
  1411. 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
  1412. 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
  1413. 0x40f000f0, 0x40f000f0,
  1414. };
  1415. static const unsigned int dell_vostro_3500_pin_configs[10] = {
  1416. 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
  1417. 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
  1418. 0x400000f4, 0x400000f5,
  1419. };
  1420. static const unsigned int hp_dv7_4000_pin_configs[10] = {
  1421. 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
  1422. 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
  1423. 0x40f000f0, 0x40f000f0,
  1424. };
  1425. static const unsigned int hp_zephyr_pin_configs[10] = {
  1426. 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
  1427. 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
  1428. 0, 0,
  1429. };
  1430. static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
  1431. 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
  1432. 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
  1433. 0x40f000f0, 0x40f000f0,
  1434. };
  1435. static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
  1436. [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
  1437. [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
  1438. [STAC_DELL_S14] = dell_s14_pin_configs,
  1439. [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
  1440. [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
  1441. [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
  1442. [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
  1443. };
  1444. static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
  1445. [STAC_92HD83XXX_AUTO] = "auto",
  1446. [STAC_92HD83XXX_REF] = "ref",
  1447. [STAC_92HD83XXX_PWR_REF] = "mic-ref",
  1448. [STAC_DELL_S14] = "dell-s14",
  1449. [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
  1450. [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
  1451. [STAC_HP_DV7_4000] = "hp-dv7-4000",
  1452. [STAC_HP_ZEPHYR] = "hp-zephyr",
  1453. };
  1454. static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
  1455. /* SigmaTel reference board */
  1456. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1457. "DFI LanParty", STAC_92HD83XXX_REF),
  1458. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1459. "DFI LanParty", STAC_92HD83XXX_REF),
  1460. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
  1461. "unknown Dell", STAC_DELL_S14),
  1462. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
  1463. "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
  1464. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
  1465. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1466. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
  1467. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1468. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
  1469. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1470. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
  1471. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1472. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
  1473. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1474. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
  1475. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1476. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
  1477. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1478. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
  1479. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1480. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
  1481. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1482. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
  1483. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1484. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
  1485. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1486. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
  1487. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1488. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
  1489. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1490. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
  1491. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1492. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
  1493. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1494. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
  1495. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1496. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
  1497. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1498. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
  1499. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1500. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
  1501. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1502. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
  1503. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1504. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
  1505. "HP", STAC_HP_ZEPHYR),
  1506. {} /* terminator */
  1507. };
  1508. static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
  1509. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
  1510. "HP", STAC_HP_ZEPHYR),
  1511. {} /* terminator */
  1512. };
  1513. static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1514. 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
  1515. 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
  1516. 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
  1517. 0x00000000
  1518. };
  1519. static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1520. 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
  1521. 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
  1522. 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
  1523. 0x00000000
  1524. };
  1525. static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1526. 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
  1527. 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
  1528. 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
  1529. 0x00000000
  1530. };
  1531. static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1532. 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
  1533. 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
  1534. 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
  1535. 0x00000000
  1536. };
  1537. static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
  1538. [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
  1539. [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
  1540. [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
  1541. [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
  1542. [STAC_HP_M4] = NULL,
  1543. [STAC_HP_DV4] = NULL,
  1544. [STAC_HP_DV5] = NULL,
  1545. [STAC_HP_HDX] = NULL,
  1546. [STAC_HP_DV4_1222NR] = NULL,
  1547. };
  1548. static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
  1549. [STAC_92HD71BXX_AUTO] = "auto",
  1550. [STAC_92HD71BXX_REF] = "ref",
  1551. [STAC_DELL_M4_1] = "dell-m4-1",
  1552. [STAC_DELL_M4_2] = "dell-m4-2",
  1553. [STAC_DELL_M4_3] = "dell-m4-3",
  1554. [STAC_HP_M4] = "hp-m4",
  1555. [STAC_HP_DV4] = "hp-dv4",
  1556. [STAC_HP_DV5] = "hp-dv5",
  1557. [STAC_HP_HDX] = "hp-hdx",
  1558. [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
  1559. };
  1560. static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
  1561. /* SigmaTel reference board */
  1562. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1563. "DFI LanParty", STAC_92HD71BXX_REF),
  1564. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1565. "DFI LanParty", STAC_92HD71BXX_REF),
  1566. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
  1567. "HP dv4-1222nr", STAC_HP_DV4_1222NR),
  1568. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
  1569. "HP", STAC_HP_DV5),
  1570. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
  1571. "HP", STAC_HP_DV5),
  1572. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
  1573. "HP dv4-7", STAC_HP_DV4),
  1574. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
  1575. "HP dv4-7", STAC_HP_DV5),
  1576. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
  1577. "HP HDX", STAC_HP_HDX), /* HDX18 */
  1578. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
  1579. "HP mini 1000", STAC_HP_M4),
  1580. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
  1581. "HP HDX", STAC_HP_HDX), /* HDX16 */
  1582. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
  1583. "HP dv6", STAC_HP_DV5),
  1584. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
  1585. "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
  1586. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
  1587. "HP DV6", STAC_HP_DV5),
  1588. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
  1589. "HP", STAC_HP_DV5),
  1590. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
  1591. "unknown Dell", STAC_DELL_M4_1),
  1592. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
  1593. "unknown Dell", STAC_DELL_M4_1),
  1594. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
  1595. "unknown Dell", STAC_DELL_M4_1),
  1596. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
  1597. "unknown Dell", STAC_DELL_M4_1),
  1598. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
  1599. "unknown Dell", STAC_DELL_M4_1),
  1600. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
  1601. "unknown Dell", STAC_DELL_M4_1),
  1602. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
  1603. "unknown Dell", STAC_DELL_M4_1),
  1604. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
  1605. "unknown Dell", STAC_DELL_M4_2),
  1606. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
  1607. "unknown Dell", STAC_DELL_M4_2),
  1608. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
  1609. "unknown Dell", STAC_DELL_M4_2),
  1610. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
  1611. "unknown Dell", STAC_DELL_M4_2),
  1612. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
  1613. "unknown Dell", STAC_DELL_M4_3),
  1614. {} /* terminator */
  1615. };
  1616. static const unsigned int ref922x_pin_configs[10] = {
  1617. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  1618. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  1619. 0x40000100, 0x40000100,
  1620. };
  1621. /*
  1622. STAC 922X pin configs for
  1623. 102801A7
  1624. 102801AB
  1625. 102801A9
  1626. 102801D1
  1627. 102801D2
  1628. */
  1629. static const unsigned int dell_922x_d81_pin_configs[10] = {
  1630. 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
  1631. 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
  1632. 0x01813122, 0x400001f2,
  1633. };
  1634. /*
  1635. STAC 922X pin configs for
  1636. 102801AC
  1637. 102801D0
  1638. */
  1639. static const unsigned int dell_922x_d82_pin_configs[10] = {
  1640. 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
  1641. 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
  1642. 0x01813122, 0x400001f1,
  1643. };
  1644. /*
  1645. STAC 922X pin configs for
  1646. 102801BF
  1647. */
  1648. static const unsigned int dell_922x_m81_pin_configs[10] = {
  1649. 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
  1650. 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
  1651. 0x40C003f1, 0x405003f0,
  1652. };
  1653. /*
  1654. STAC 9221 A1 pin configs for
  1655. 102801D7 (Dell XPS M1210)
  1656. */
  1657. static const unsigned int dell_922x_m82_pin_configs[10] = {
  1658. 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
  1659. 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
  1660. 0x508003f3, 0x405003f4,
  1661. };
  1662. static const unsigned int d945gtp3_pin_configs[10] = {
  1663. 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
  1664. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  1665. 0x02a19120, 0x40000100,
  1666. };
  1667. static const unsigned int d945gtp5_pin_configs[10] = {
  1668. 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
  1669. 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
  1670. 0x02a19320, 0x40000100,
  1671. };
  1672. static const unsigned int intel_mac_v1_pin_configs[10] = {
  1673. 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
  1674. 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
  1675. 0x400000fc, 0x400000fb,
  1676. };
  1677. static const unsigned int intel_mac_v2_pin_configs[10] = {
  1678. 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
  1679. 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
  1680. 0x400000fc, 0x400000fb,
  1681. };
  1682. static const unsigned int intel_mac_v3_pin_configs[10] = {
  1683. 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
  1684. 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
  1685. 0x400000fc, 0x400000fb,
  1686. };
  1687. static const unsigned int intel_mac_v4_pin_configs[10] = {
  1688. 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
  1689. 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
  1690. 0x400000fc, 0x400000fb,
  1691. };
  1692. static const unsigned int intel_mac_v5_pin_configs[10] = {
  1693. 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
  1694. 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
  1695. 0x400000fc, 0x400000fb,
  1696. };
  1697. static const unsigned int ecs202_pin_configs[10] = {
  1698. 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
  1699. 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
  1700. 0x9037012e, 0x40e000f2,
  1701. };
  1702. static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
  1703. [STAC_D945_REF] = ref922x_pin_configs,
  1704. [STAC_D945GTP3] = d945gtp3_pin_configs,
  1705. [STAC_D945GTP5] = d945gtp5_pin_configs,
  1706. [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
  1707. [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
  1708. [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
  1709. [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
  1710. [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
  1711. [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
  1712. /* for backward compatibility */
  1713. [STAC_MACMINI] = intel_mac_v3_pin_configs,
  1714. [STAC_MACBOOK] = intel_mac_v5_pin_configs,
  1715. [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
  1716. [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
  1717. [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
  1718. [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
  1719. [STAC_ECS_202] = ecs202_pin_configs,
  1720. [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
  1721. [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
  1722. [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
  1723. [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
  1724. };
  1725. static const char * const stac922x_models[STAC_922X_MODELS] = {
  1726. [STAC_922X_AUTO] = "auto",
  1727. [STAC_D945_REF] = "ref",
  1728. [STAC_D945GTP5] = "5stack",
  1729. [STAC_D945GTP3] = "3stack",
  1730. [STAC_INTEL_MAC_V1] = "intel-mac-v1",
  1731. [STAC_INTEL_MAC_V2] = "intel-mac-v2",
  1732. [STAC_INTEL_MAC_V3] = "intel-mac-v3",
  1733. [STAC_INTEL_MAC_V4] = "intel-mac-v4",
  1734. [STAC_INTEL_MAC_V5] = "intel-mac-v5",
  1735. [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
  1736. /* for backward compatibility */
  1737. [STAC_MACMINI] = "macmini",
  1738. [STAC_MACBOOK] = "macbook",
  1739. [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
  1740. [STAC_MACBOOK_PRO_V2] = "macbook-pro",
  1741. [STAC_IMAC_INTEL] = "imac-intel",
  1742. [STAC_IMAC_INTEL_20] = "imac-intel-20",
  1743. [STAC_ECS_202] = "ecs202",
  1744. [STAC_922X_DELL_D81] = "dell-d81",
  1745. [STAC_922X_DELL_D82] = "dell-d82",
  1746. [STAC_922X_DELL_M81] = "dell-m81",
  1747. [STAC_922X_DELL_M82] = "dell-m82",
  1748. };
  1749. static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
  1750. /* SigmaTel reference board */
  1751. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1752. "DFI LanParty", STAC_D945_REF),
  1753. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1754. "DFI LanParty", STAC_D945_REF),
  1755. /* Intel 945G based systems */
  1756. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
  1757. "Intel D945G", STAC_D945GTP3),
  1758. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
  1759. "Intel D945G", STAC_D945GTP3),
  1760. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
  1761. "Intel D945G", STAC_D945GTP3),
  1762. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
  1763. "Intel D945G", STAC_D945GTP3),
  1764. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
  1765. "Intel D945G", STAC_D945GTP3),
  1766. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
  1767. "Intel D945G", STAC_D945GTP3),
  1768. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
  1769. "Intel D945G", STAC_D945GTP3),
  1770. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
  1771. "Intel D945G", STAC_D945GTP3),
  1772. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
  1773. "Intel D945G", STAC_D945GTP3),
  1774. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
  1775. "Intel D945G", STAC_D945GTP3),
  1776. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
  1777. "Intel D945G", STAC_D945GTP3),
  1778. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
  1779. "Intel D945G", STAC_D945GTP3),
  1780. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
  1781. "Intel D945G", STAC_D945GTP3),
  1782. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
  1783. "Intel D945G", STAC_D945GTP3),
  1784. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
  1785. "Intel D945G", STAC_D945GTP3),
  1786. /* Intel D945G 5-stack systems */
  1787. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
  1788. "Intel D945G", STAC_D945GTP5),
  1789. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
  1790. "Intel D945G", STAC_D945GTP5),
  1791. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
  1792. "Intel D945G", STAC_D945GTP5),
  1793. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
  1794. "Intel D945G", STAC_D945GTP5),
  1795. /* Intel 945P based systems */
  1796. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
  1797. "Intel D945P", STAC_D945GTP3),
  1798. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
  1799. "Intel D945P", STAC_D945GTP3),
  1800. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
  1801. "Intel D945P", STAC_D945GTP3),
  1802. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
  1803. "Intel D945P", STAC_D945GTP3),
  1804. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
  1805. "Intel D945P", STAC_D945GTP3),
  1806. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
  1807. "Intel D945P", STAC_D945GTP5),
  1808. /* other intel */
  1809. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
  1810. "Intel D945", STAC_D945_REF),
  1811. /* other systems */
  1812. /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
  1813. SND_PCI_QUIRK(0x8384, 0x7680,
  1814. "Mac", STAC_INTEL_MAC_AUTO),
  1815. /* Dell systems */
  1816. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
  1817. "unknown Dell", STAC_922X_DELL_D81),
  1818. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
  1819. "unknown Dell", STAC_922X_DELL_D81),
  1820. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
  1821. "unknown Dell", STAC_922X_DELL_D81),
  1822. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
  1823. "unknown Dell", STAC_922X_DELL_D82),
  1824. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
  1825. "unknown Dell", STAC_922X_DELL_M81),
  1826. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
  1827. "unknown Dell", STAC_922X_DELL_D82),
  1828. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
  1829. "unknown Dell", STAC_922X_DELL_D81),
  1830. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
  1831. "unknown Dell", STAC_922X_DELL_D81),
  1832. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
  1833. "Dell XPS M1210", STAC_922X_DELL_M82),
  1834. /* ECS/PC Chips boards */
  1835. SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
  1836. "ECS/PC chips", STAC_ECS_202),
  1837. {} /* terminator */
  1838. };
  1839. static const unsigned int ref927x_pin_configs[14] = {
  1840. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  1841. 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
  1842. 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
  1843. 0x01c42190, 0x40000100,
  1844. };
  1845. static const unsigned int d965_3st_pin_configs[14] = {
  1846. 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
  1847. 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
  1848. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  1849. 0x40000100, 0x40000100
  1850. };
  1851. static const unsigned int d965_5st_pin_configs[14] = {
  1852. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  1853. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  1854. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  1855. 0x40000100, 0x40000100
  1856. };
  1857. static const unsigned int d965_5st_no_fp_pin_configs[14] = {
  1858. 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
  1859. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  1860. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  1861. 0x40000100, 0x40000100
  1862. };
  1863. static const unsigned int dell_3st_pin_configs[14] = {
  1864. 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
  1865. 0x01111212, 0x01116211, 0x01813050, 0x01112214,
  1866. 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
  1867. 0x40c003fc, 0x40000100
  1868. };
  1869. static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
  1870. [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
  1871. [STAC_D965_REF] = ref927x_pin_configs,
  1872. [STAC_D965_3ST] = d965_3st_pin_configs,
  1873. [STAC_D965_5ST] = d965_5st_pin_configs,
  1874. [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
  1875. [STAC_DELL_3ST] = dell_3st_pin_configs,
  1876. [STAC_DELL_BIOS] = NULL,
  1877. [STAC_927X_VOLKNOB] = NULL,
  1878. };
  1879. static const char * const stac927x_models[STAC_927X_MODELS] = {
  1880. [STAC_927X_AUTO] = "auto",
  1881. [STAC_D965_REF_NO_JD] = "ref-no-jd",
  1882. [STAC_D965_REF] = "ref",
  1883. [STAC_D965_3ST] = "3stack",
  1884. [STAC_D965_5ST] = "5stack",
  1885. [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
  1886. [STAC_DELL_3ST] = "dell-3stack",
  1887. [STAC_DELL_BIOS] = "dell-bios",
  1888. [STAC_927X_VOLKNOB] = "volknob",
  1889. };
  1890. static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
  1891. /* SigmaTel reference board */
  1892. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1893. "DFI LanParty", STAC_D965_REF),
  1894. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1895. "DFI LanParty", STAC_D965_REF),
  1896. /* Intel 946 based systems */
  1897. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
  1898. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
  1899. /* 965 based 3 stack systems */
  1900. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
  1901. "Intel D965", STAC_D965_3ST),
  1902. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
  1903. "Intel D965", STAC_D965_3ST),
  1904. /* Dell 3 stack systems */
  1905. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
  1906. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
  1907. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
  1908. /* Dell 3 stack systems with verb table in BIOS */
  1909. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
  1910. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
  1911. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
  1912. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
  1913. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
  1914. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
  1915. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
  1916. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
  1917. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
  1918. /* 965 based 5 stack systems */
  1919. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
  1920. "Intel D965", STAC_D965_5ST),
  1921. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
  1922. "Intel D965", STAC_D965_5ST),
  1923. /* volume-knob fixes */
  1924. SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
  1925. {} /* terminator */
  1926. };
  1927. static const unsigned int ref9205_pin_configs[12] = {
  1928. 0x40000100, 0x40000100, 0x01016011, 0x01014010,
  1929. 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
  1930. 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
  1931. };
  1932. /*
  1933. STAC 9205 pin configs for
  1934. 102801F1
  1935. 102801F2
  1936. 102801FC
  1937. 102801FD
  1938. 10280204
  1939. 1028021F
  1940. 10280228 (Dell Vostro 1500)
  1941. 10280229 (Dell Vostro 1700)
  1942. */
  1943. static const unsigned int dell_9205_m42_pin_configs[12] = {
  1944. 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
  1945. 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
  1946. 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
  1947. };
  1948. /*
  1949. STAC 9205 pin configs for
  1950. 102801F9
  1951. 102801FA
  1952. 102801FE
  1953. 102801FF (Dell Precision M4300)
  1954. 10280206
  1955. 10280200
  1956. 10280201
  1957. */
  1958. static const unsigned int dell_9205_m43_pin_configs[12] = {
  1959. 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
  1960. 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
  1961. 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
  1962. };
  1963. static const unsigned int dell_9205_m44_pin_configs[12] = {
  1964. 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
  1965. 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
  1966. 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
  1967. };
  1968. static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
  1969. [STAC_9205_REF] = ref9205_pin_configs,
  1970. [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
  1971. [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
  1972. [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
  1973. [STAC_9205_EAPD] = NULL,
  1974. };
  1975. static const char * const stac9205_models[STAC_9205_MODELS] = {
  1976. [STAC_9205_AUTO] = "auto",
  1977. [STAC_9205_REF] = "ref",
  1978. [STAC_9205_DELL_M42] = "dell-m42",
  1979. [STAC_9205_DELL_M43] = "dell-m43",
  1980. [STAC_9205_DELL_M44] = "dell-m44",
  1981. [STAC_9205_EAPD] = "eapd",
  1982. };
  1983. static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
  1984. /* SigmaTel reference board */
  1985. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1986. "DFI LanParty", STAC_9205_REF),
  1987. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
  1988. "SigmaTel", STAC_9205_REF),
  1989. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1990. "DFI LanParty", STAC_9205_REF),
  1991. /* Dell */
  1992. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
  1993. "unknown Dell", STAC_9205_DELL_M42),
  1994. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
  1995. "unknown Dell", STAC_9205_DELL_M42),
  1996. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
  1997. "Dell Precision", STAC_9205_DELL_M43),
  1998. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
  1999. "Dell Precision", STAC_9205_DELL_M43),
  2000. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
  2001. "Dell Precision", STAC_9205_DELL_M43),
  2002. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
  2003. "unknown Dell", STAC_9205_DELL_M42),
  2004. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
  2005. "unknown Dell", STAC_9205_DELL_M42),
  2006. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
  2007. "Dell Precision", STAC_9205_DELL_M43),
  2008. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
  2009. "Dell Precision M4300", STAC_9205_DELL_M43),
  2010. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
  2011. "unknown Dell", STAC_9205_DELL_M42),
  2012. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
  2013. "Dell Precision", STAC_9205_DELL_M43),
  2014. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
  2015. "Dell Precision", STAC_9205_DELL_M43),
  2016. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
  2017. "Dell Precision", STAC_9205_DELL_M43),
  2018. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
  2019. "Dell Inspiron", STAC_9205_DELL_M44),
  2020. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
  2021. "Dell Vostro 1500", STAC_9205_DELL_M42),
  2022. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
  2023. "Dell Vostro 1700", STAC_9205_DELL_M42),
  2024. /* Gateway */
  2025. SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
  2026. SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
  2027. {} /* terminator */
  2028. };
  2029. static void stac92xx_set_config_regs(struct hda_codec *codec,
  2030. const unsigned int *pincfgs)
  2031. {
  2032. int i;
  2033. struct sigmatel_spec *spec = codec->spec;
  2034. if (!pincfgs)
  2035. return;
  2036. for (i = 0; i < spec->num_pins; i++)
  2037. if (spec->pin_nids[i] && pincfgs[i])
  2038. snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
  2039. pincfgs[i]);
  2040. }
  2041. /*
  2042. * Analog playback callbacks
  2043. */
  2044. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2045. struct hda_codec *codec,
  2046. struct snd_pcm_substream *substream)
  2047. {
  2048. struct sigmatel_spec *spec = codec->spec;
  2049. if (spec->stream_delay)
  2050. msleep(spec->stream_delay);
  2051. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  2052. hinfo);
  2053. }
  2054. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2055. struct hda_codec *codec,
  2056. unsigned int stream_tag,
  2057. unsigned int format,
  2058. struct snd_pcm_substream *substream)
  2059. {
  2060. struct sigmatel_spec *spec = codec->spec;
  2061. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  2062. }
  2063. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2064. struct hda_codec *codec,
  2065. struct snd_pcm_substream *substream)
  2066. {
  2067. struct sigmatel_spec *spec = codec->spec;
  2068. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  2069. }
  2070. /*
  2071. * Digital playback callbacks
  2072. */
  2073. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2074. struct hda_codec *codec,
  2075. struct snd_pcm_substream *substream)
  2076. {
  2077. struct sigmatel_spec *spec = codec->spec;
  2078. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2079. }
  2080. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2081. struct hda_codec *codec,
  2082. struct snd_pcm_substream *substream)
  2083. {
  2084. struct sigmatel_spec *spec = codec->spec;
  2085. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2086. }
  2087. static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2088. struct hda_codec *codec,
  2089. unsigned int stream_tag,
  2090. unsigned int format,
  2091. struct snd_pcm_substream *substream)
  2092. {
  2093. struct sigmatel_spec *spec = codec->spec;
  2094. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2095. stream_tag, format, substream);
  2096. }
  2097. static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2098. struct hda_codec *codec,
  2099. struct snd_pcm_substream *substream)
  2100. {
  2101. struct sigmatel_spec *spec = codec->spec;
  2102. return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
  2103. }
  2104. /*
  2105. * Analog capture callbacks
  2106. */
  2107. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2108. struct hda_codec *codec,
  2109. unsigned int stream_tag,
  2110. unsigned int format,
  2111. struct snd_pcm_substream *substream)
  2112. {
  2113. struct sigmatel_spec *spec = codec->spec;
  2114. hda_nid_t nid = spec->adc_nids[substream->number];
  2115. if (spec->powerdown_adcs) {
  2116. msleep(40);
  2117. snd_hda_codec_write(codec, nid, 0,
  2118. AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
  2119. }
  2120. snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
  2121. return 0;
  2122. }
  2123. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2124. struct hda_codec *codec,
  2125. struct snd_pcm_substream *substream)
  2126. {
  2127. struct sigmatel_spec *spec = codec->spec;
  2128. hda_nid_t nid = spec->adc_nids[substream->number];
  2129. snd_hda_codec_cleanup_stream(codec, nid);
  2130. if (spec->powerdown_adcs)
  2131. snd_hda_codec_write(codec, nid, 0,
  2132. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  2133. return 0;
  2134. }
  2135. static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  2136. .substreams = 1,
  2137. .channels_min = 2,
  2138. .channels_max = 2,
  2139. /* NID is set in stac92xx_build_pcms */
  2140. .ops = {
  2141. .open = stac92xx_dig_playback_pcm_open,
  2142. .close = stac92xx_dig_playback_pcm_close,
  2143. .prepare = stac92xx_dig_playback_pcm_prepare,
  2144. .cleanup = stac92xx_dig_playback_pcm_cleanup
  2145. },
  2146. };
  2147. static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  2148. .substreams = 1,
  2149. .channels_min = 2,
  2150. .channels_max = 2,
  2151. /* NID is set in stac92xx_build_pcms */
  2152. };
  2153. static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  2154. .substreams = 1,
  2155. .channels_min = 2,
  2156. .channels_max = 8,
  2157. .nid = 0x02, /* NID to query formats and rates */
  2158. .ops = {
  2159. .open = stac92xx_playback_pcm_open,
  2160. .prepare = stac92xx_playback_pcm_prepare,
  2161. .cleanup = stac92xx_playback_pcm_cleanup
  2162. },
  2163. };
  2164. static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  2165. .substreams = 1,
  2166. .channels_min = 2,
  2167. .channels_max = 2,
  2168. .nid = 0x06, /* NID to query formats and rates */
  2169. .ops = {
  2170. .open = stac92xx_playback_pcm_open,
  2171. .prepare = stac92xx_playback_pcm_prepare,
  2172. .cleanup = stac92xx_playback_pcm_cleanup
  2173. },
  2174. };
  2175. static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  2176. .channels_min = 2,
  2177. .channels_max = 2,
  2178. /* NID + .substreams is set in stac92xx_build_pcms */
  2179. .ops = {
  2180. .prepare = stac92xx_capture_pcm_prepare,
  2181. .cleanup = stac92xx_capture_pcm_cleanup
  2182. },
  2183. };
  2184. static int stac92xx_build_pcms(struct hda_codec *codec)
  2185. {
  2186. struct sigmatel_spec *spec = codec->spec;
  2187. struct hda_pcm *info = spec->pcm_rec;
  2188. codec->num_pcms = 1;
  2189. codec->pcm_info = info;
  2190. info->name = "STAC92xx Analog";
  2191. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  2192. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
  2193. spec->multiout.dac_nids[0];
  2194. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  2195. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2196. info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
  2197. if (spec->alt_switch) {
  2198. codec->num_pcms++;
  2199. info++;
  2200. info->name = "STAC92xx Analog Alt";
  2201. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  2202. }
  2203. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2204. codec->num_pcms++;
  2205. info++;
  2206. info->name = "STAC92xx Digital";
  2207. info->pcm_type = spec->autocfg.dig_out_type[0];
  2208. if (spec->multiout.dig_out_nid) {
  2209. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  2210. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2211. }
  2212. if (spec->dig_in_nid) {
  2213. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  2214. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2215. }
  2216. }
  2217. return 0;
  2218. }
  2219. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  2220. {
  2221. snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
  2222. }
  2223. #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
  2224. static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
  2225. struct snd_ctl_elem_value *ucontrol)
  2226. {
  2227. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2228. struct sigmatel_spec *spec = codec->spec;
  2229. ucontrol->value.integer.value[0] = !!spec->hp_switch;
  2230. return 0;
  2231. }
  2232. static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
  2233. static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
  2234. struct snd_ctl_elem_value *ucontrol)
  2235. {
  2236. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2237. struct sigmatel_spec *spec = codec->spec;
  2238. int nid = kcontrol->private_value;
  2239. spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
  2240. /* check to be sure that the ports are up to date with
  2241. * switch changes
  2242. */
  2243. stac_issue_unsol_event(codec, nid);
  2244. return 1;
  2245. }
  2246. static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
  2247. struct snd_ctl_elem_info *uinfo)
  2248. {
  2249. int i;
  2250. static const char * const texts[] = {
  2251. "Mic In", "Line In", "Line Out"
  2252. };
  2253. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2254. struct sigmatel_spec *spec = codec->spec;
  2255. hda_nid_t nid = kcontrol->private_value;
  2256. if (nid == spec->mic_switch || nid == spec->line_switch)
  2257. i = 3;
  2258. else
  2259. i = 2;
  2260. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2261. uinfo->value.enumerated.items = i;
  2262. uinfo->count = 1;
  2263. if (uinfo->value.enumerated.item >= i)
  2264. uinfo->value.enumerated.item = i-1;
  2265. strcpy(uinfo->value.enumerated.name,
  2266. texts[uinfo->value.enumerated.item]);
  2267. return 0;
  2268. }
  2269. static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
  2270. struct snd_ctl_elem_value *ucontrol)
  2271. {
  2272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2273. hda_nid_t nid = kcontrol->private_value;
  2274. unsigned int vref = stac92xx_vref_get(codec, nid);
  2275. if (vref == snd_hda_get_default_vref(codec, nid))
  2276. ucontrol->value.enumerated.item[0] = 0;
  2277. else if (vref == AC_PINCTL_VREF_GRD)
  2278. ucontrol->value.enumerated.item[0] = 1;
  2279. else if (vref == AC_PINCTL_VREF_HIZ)
  2280. ucontrol->value.enumerated.item[0] = 2;
  2281. return 0;
  2282. }
  2283. static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
  2284. struct snd_ctl_elem_value *ucontrol)
  2285. {
  2286. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2287. unsigned int new_vref = 0;
  2288. int error;
  2289. hda_nid_t nid = kcontrol->private_value;
  2290. if (ucontrol->value.enumerated.item[0] == 0)
  2291. new_vref = snd_hda_get_default_vref(codec, nid);
  2292. else if (ucontrol->value.enumerated.item[0] == 1)
  2293. new_vref = AC_PINCTL_VREF_GRD;
  2294. else if (ucontrol->value.enumerated.item[0] == 2)
  2295. new_vref = AC_PINCTL_VREF_HIZ;
  2296. else
  2297. return 0;
  2298. if (new_vref != stac92xx_vref_get(codec, nid)) {
  2299. error = stac92xx_vref_set(codec, nid, new_vref);
  2300. return error;
  2301. }
  2302. return 0;
  2303. }
  2304. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
  2305. struct snd_ctl_elem_info *uinfo)
  2306. {
  2307. char *texts[2];
  2308. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2309. struct sigmatel_spec *spec = codec->spec;
  2310. if (kcontrol->private_value == spec->line_switch)
  2311. texts[0] = "Line In";
  2312. else
  2313. texts[0] = "Mic In";
  2314. texts[1] = "Line Out";
  2315. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2316. uinfo->value.enumerated.items = 2;
  2317. uinfo->count = 1;
  2318. if (uinfo->value.enumerated.item >= 2)
  2319. uinfo->value.enumerated.item = 1;
  2320. strcpy(uinfo->value.enumerated.name,
  2321. texts[uinfo->value.enumerated.item]);
  2322. return 0;
  2323. }
  2324. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  2325. {
  2326. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2327. struct sigmatel_spec *spec = codec->spec;
  2328. hda_nid_t nid = kcontrol->private_value;
  2329. int io_idx = (nid == spec->mic_switch) ? 1 : 0;
  2330. ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
  2331. return 0;
  2332. }
  2333. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  2334. {
  2335. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2336. struct sigmatel_spec *spec = codec->spec;
  2337. hda_nid_t nid = kcontrol->private_value;
  2338. int io_idx = (nid == spec->mic_switch) ? 1 : 0;
  2339. unsigned short val = !!ucontrol->value.enumerated.item[0];
  2340. spec->io_switch[io_idx] = val;
  2341. if (val)
  2342. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  2343. else {
  2344. unsigned int pinctl = AC_PINCTL_IN_EN;
  2345. if (io_idx) /* set VREF for mic */
  2346. pinctl |= snd_hda_get_default_vref(codec, nid);
  2347. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  2348. }
  2349. /* check the auto-mute again: we need to mute/unmute the speaker
  2350. * appropriately according to the pin direction
  2351. */
  2352. if (spec->hp_detect)
  2353. stac_issue_unsol_event(codec, nid);
  2354. return 1;
  2355. }
  2356. #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
  2357. static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
  2358. struct snd_ctl_elem_value *ucontrol)
  2359. {
  2360. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2361. struct sigmatel_spec *spec = codec->spec;
  2362. ucontrol->value.integer.value[0] = spec->clfe_swap;
  2363. return 0;
  2364. }
  2365. static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
  2366. struct snd_ctl_elem_value *ucontrol)
  2367. {
  2368. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2369. struct sigmatel_spec *spec = codec->spec;
  2370. hda_nid_t nid = kcontrol->private_value & 0xff;
  2371. unsigned int val = !!ucontrol->value.integer.value[0];
  2372. if (spec->clfe_swap == val)
  2373. return 0;
  2374. spec->clfe_swap = val;
  2375. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
  2376. spec->clfe_swap ? 0x4 : 0x0);
  2377. return 1;
  2378. }
  2379. #define STAC_CODEC_HP_SWITCH(xname) \
  2380. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2381. .name = xname, \
  2382. .index = 0, \
  2383. .info = stac92xx_hp_switch_info, \
  2384. .get = stac92xx_hp_switch_get, \
  2385. .put = stac92xx_hp_switch_put, \
  2386. }
  2387. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  2388. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2389. .name = xname, \
  2390. .index = 0, \
  2391. .info = stac92xx_io_switch_info, \
  2392. .get = stac92xx_io_switch_get, \
  2393. .put = stac92xx_io_switch_put, \
  2394. .private_value = xpval, \
  2395. }
  2396. #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
  2397. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2398. .name = xname, \
  2399. .index = 0, \
  2400. .info = stac92xx_clfe_switch_info, \
  2401. .get = stac92xx_clfe_switch_get, \
  2402. .put = stac92xx_clfe_switch_put, \
  2403. .private_value = xpval, \
  2404. }
  2405. enum {
  2406. STAC_CTL_WIDGET_VOL,
  2407. STAC_CTL_WIDGET_MUTE,
  2408. STAC_CTL_WIDGET_MUTE_BEEP,
  2409. STAC_CTL_WIDGET_MONO_MUX,
  2410. STAC_CTL_WIDGET_HP_SWITCH,
  2411. STAC_CTL_WIDGET_IO_SWITCH,
  2412. STAC_CTL_WIDGET_CLFE_SWITCH,
  2413. STAC_CTL_WIDGET_DC_BIAS
  2414. };
  2415. static const struct snd_kcontrol_new stac92xx_control_templates[] = {
  2416. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2417. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2418. HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
  2419. STAC_MONO_MUX,
  2420. STAC_CODEC_HP_SWITCH(NULL),
  2421. STAC_CODEC_IO_SWITCH(NULL, 0),
  2422. STAC_CODEC_CLFE_SWITCH(NULL, 0),
  2423. DC_BIAS(NULL, 0, 0),
  2424. };
  2425. /* add dynamic controls */
  2426. static struct snd_kcontrol_new *
  2427. stac_control_new(struct sigmatel_spec *spec,
  2428. const struct snd_kcontrol_new *ktemp,
  2429. const char *name,
  2430. unsigned int subdev)
  2431. {
  2432. struct snd_kcontrol_new *knew;
  2433. snd_array_init(&spec->kctls, sizeof(*knew), 32);
  2434. knew = snd_array_new(&spec->kctls);
  2435. if (!knew)
  2436. return NULL;
  2437. *knew = *ktemp;
  2438. knew->name = kstrdup(name, GFP_KERNEL);
  2439. if (!knew->name) {
  2440. /* roolback */
  2441. memset(knew, 0, sizeof(*knew));
  2442. spec->kctls.alloced--;
  2443. return NULL;
  2444. }
  2445. knew->subdevice = subdev;
  2446. return knew;
  2447. }
  2448. static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
  2449. const struct snd_kcontrol_new *ktemp,
  2450. int idx, const char *name,
  2451. unsigned long val)
  2452. {
  2453. struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
  2454. HDA_SUBDEV_AMP_FLAG);
  2455. if (!knew)
  2456. return -ENOMEM;
  2457. knew->index = idx;
  2458. knew->private_value = val;
  2459. return 0;
  2460. }
  2461. static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
  2462. int type, int idx, const char *name,
  2463. unsigned long val)
  2464. {
  2465. return stac92xx_add_control_temp(spec,
  2466. &stac92xx_control_templates[type],
  2467. idx, name, val);
  2468. }
  2469. /* add dynamic controls */
  2470. static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
  2471. const char *name, unsigned long val)
  2472. {
  2473. return stac92xx_add_control_idx(spec, type, 0, name, val);
  2474. }
  2475. static const struct snd_kcontrol_new stac_input_src_temp = {
  2476. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2477. .name = "Input Source",
  2478. .info = stac92xx_mux_enum_info,
  2479. .get = stac92xx_mux_enum_get,
  2480. .put = stac92xx_mux_enum_put,
  2481. };
  2482. static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
  2483. hda_nid_t nid, int idx)
  2484. {
  2485. int def_conf = snd_hda_codec_get_pincfg(codec, nid);
  2486. int control = 0;
  2487. struct sigmatel_spec *spec = codec->spec;
  2488. char name[22];
  2489. if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
  2490. if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
  2491. && nid == spec->line_switch)
  2492. control = STAC_CTL_WIDGET_IO_SWITCH;
  2493. else if (snd_hda_query_pin_caps(codec, nid)
  2494. & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
  2495. control = STAC_CTL_WIDGET_DC_BIAS;
  2496. else if (nid == spec->mic_switch)
  2497. control = STAC_CTL_WIDGET_IO_SWITCH;
  2498. }
  2499. if (control) {
  2500. snd_hda_get_pin_label(codec, nid, &spec->autocfg,
  2501. name, sizeof(name), NULL);
  2502. return stac92xx_add_control(codec->spec, control,
  2503. strcat(name, " Jack Mode"), nid);
  2504. }
  2505. return 0;
  2506. }
  2507. static int stac92xx_add_input_source(struct sigmatel_spec *spec)
  2508. {
  2509. struct snd_kcontrol_new *knew;
  2510. struct hda_input_mux *imux = &spec->private_imux;
  2511. if (spec->auto_mic)
  2512. return 0; /* no need for input source */
  2513. if (!spec->num_adcs || imux->num_items <= 1)
  2514. return 0; /* no need for input source control */
  2515. knew = stac_control_new(spec, &stac_input_src_temp,
  2516. stac_input_src_temp.name, 0);
  2517. if (!knew)
  2518. return -ENOMEM;
  2519. knew->count = spec->num_adcs;
  2520. return 0;
  2521. }
  2522. /* check whether the line-input can be used as line-out */
  2523. static hda_nid_t check_line_out_switch(struct hda_codec *codec)
  2524. {
  2525. struct sigmatel_spec *spec = codec->spec;
  2526. struct auto_pin_cfg *cfg = &spec->autocfg;
  2527. hda_nid_t nid;
  2528. unsigned int pincap;
  2529. int i;
  2530. if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
  2531. return 0;
  2532. for (i = 0; i < cfg->num_inputs; i++) {
  2533. if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
  2534. nid = cfg->inputs[i].pin;
  2535. pincap = snd_hda_query_pin_caps(codec, nid);
  2536. if (pincap & AC_PINCAP_OUT)
  2537. return nid;
  2538. }
  2539. }
  2540. return 0;
  2541. }
  2542. static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
  2543. /* check whether the mic-input can be used as line-out */
  2544. static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
  2545. {
  2546. struct sigmatel_spec *spec = codec->spec;
  2547. struct auto_pin_cfg *cfg = &spec->autocfg;
  2548. unsigned int def_conf, pincap;
  2549. int i;
  2550. *dac = 0;
  2551. if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
  2552. return 0;
  2553. for (i = 0; i < cfg->num_inputs; i++) {
  2554. hda_nid_t nid = cfg->inputs[i].pin;
  2555. if (cfg->inputs[i].type != AUTO_PIN_MIC)
  2556. continue;
  2557. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  2558. /* some laptops have an internal analog microphone
  2559. * which can't be used as a output */
  2560. if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
  2561. pincap = snd_hda_query_pin_caps(codec, nid);
  2562. if (pincap & AC_PINCAP_OUT) {
  2563. *dac = get_unassigned_dac(codec, nid);
  2564. if (*dac)
  2565. return nid;
  2566. }
  2567. }
  2568. }
  2569. return 0;
  2570. }
  2571. static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  2572. {
  2573. int i;
  2574. for (i = 0; i < spec->multiout.num_dacs; i++) {
  2575. if (spec->multiout.dac_nids[i] == nid)
  2576. return 1;
  2577. }
  2578. return 0;
  2579. }
  2580. static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  2581. {
  2582. int i;
  2583. if (is_in_dac_nids(spec, nid))
  2584. return 1;
  2585. for (i = 0; i < spec->autocfg.hp_outs; i++)
  2586. if (spec->hp_dacs[i] == nid)
  2587. return 1;
  2588. for (i = 0; i < spec->autocfg.speaker_outs; i++)
  2589. if (spec->speaker_dacs[i] == nid)
  2590. return 1;
  2591. return 0;
  2592. }
  2593. static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
  2594. {
  2595. struct sigmatel_spec *spec = codec->spec;
  2596. struct auto_pin_cfg *cfg = &spec->autocfg;
  2597. int j, conn_len;
  2598. hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
  2599. unsigned int wcaps, wtype;
  2600. conn_len = snd_hda_get_connections(codec, nid, conn,
  2601. HDA_MAX_CONNECTIONS);
  2602. /* 92HD88: trace back up the link of nids to find the DAC */
  2603. while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
  2604. != AC_WID_AUD_OUT)) {
  2605. nid = conn[0];
  2606. conn_len = snd_hda_get_connections(codec, nid, conn,
  2607. HDA_MAX_CONNECTIONS);
  2608. }
  2609. for (j = 0; j < conn_len; j++) {
  2610. wcaps = get_wcaps(codec, conn[j]);
  2611. wtype = get_wcaps_type(wcaps);
  2612. /* we check only analog outputs */
  2613. if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
  2614. continue;
  2615. /* if this route has a free DAC, assign it */
  2616. if (!check_all_dac_nids(spec, conn[j])) {
  2617. if (conn_len > 1) {
  2618. /* select this DAC in the pin's input mux */
  2619. snd_hda_codec_write_cache(codec, nid, 0,
  2620. AC_VERB_SET_CONNECT_SEL, j);
  2621. }
  2622. return conn[j];
  2623. }
  2624. }
  2625. /* if all DACs are already assigned, connect to the primary DAC,
  2626. unless we're assigning a secondary headphone */
  2627. fallback_dac = spec->multiout.dac_nids[0];
  2628. if (spec->multiout.hp_nid) {
  2629. for (j = 0; j < cfg->hp_outs; j++)
  2630. if (cfg->hp_pins[j] == nid) {
  2631. fallback_dac = spec->multiout.hp_nid;
  2632. break;
  2633. }
  2634. }
  2635. if (conn_len > 1) {
  2636. for (j = 0; j < conn_len; j++) {
  2637. if (conn[j] == fallback_dac) {
  2638. snd_hda_codec_write_cache(codec, nid, 0,
  2639. AC_VERB_SET_CONNECT_SEL, j);
  2640. break;
  2641. }
  2642. }
  2643. }
  2644. return 0;
  2645. }
  2646. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
  2647. static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
  2648. /*
  2649. * Fill in the dac_nids table from the parsed pin configuration
  2650. * This function only works when every pin in line_out_pins[]
  2651. * contains atleast one DAC in its connection list. Some 92xx
  2652. * codecs are not connected directly to a DAC, such as the 9200
  2653. * and 9202/925x. For those, dac_nids[] must be hard-coded.
  2654. */
  2655. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
  2656. {
  2657. struct sigmatel_spec *spec = codec->spec;
  2658. struct auto_pin_cfg *cfg = &spec->autocfg;
  2659. int i;
  2660. hda_nid_t nid, dac;
  2661. for (i = 0; i < cfg->line_outs; i++) {
  2662. nid = cfg->line_out_pins[i];
  2663. dac = get_unassigned_dac(codec, nid);
  2664. if (!dac) {
  2665. if (spec->multiout.num_dacs > 0) {
  2666. /* we have already working output pins,
  2667. * so let's drop the broken ones again
  2668. */
  2669. cfg->line_outs = spec->multiout.num_dacs;
  2670. break;
  2671. }
  2672. /* error out, no available DAC found */
  2673. snd_printk(KERN_ERR
  2674. "%s: No available DAC for pin 0x%x\n",
  2675. __func__, nid);
  2676. return -ENODEV;
  2677. }
  2678. add_spec_dacs(spec, dac);
  2679. }
  2680. for (i = 0; i < cfg->hp_outs; i++) {
  2681. nid = cfg->hp_pins[i];
  2682. dac = get_unassigned_dac(codec, nid);
  2683. if (dac) {
  2684. if (!spec->multiout.hp_nid)
  2685. spec->multiout.hp_nid = dac;
  2686. else
  2687. add_spec_extra_dacs(spec, dac);
  2688. }
  2689. spec->hp_dacs[i] = dac;
  2690. }
  2691. for (i = 0; i < cfg->speaker_outs; i++) {
  2692. nid = cfg->speaker_pins[i];
  2693. dac = get_unassigned_dac(codec, nid);
  2694. if (dac)
  2695. add_spec_extra_dacs(spec, dac);
  2696. spec->speaker_dacs[i] = dac;
  2697. }
  2698. /* add line-in as output */
  2699. nid = check_line_out_switch(codec);
  2700. if (nid) {
  2701. dac = get_unassigned_dac(codec, nid);
  2702. if (dac) {
  2703. snd_printdd("STAC: Add line-in 0x%x as output %d\n",
  2704. nid, cfg->line_outs);
  2705. cfg->line_out_pins[cfg->line_outs] = nid;
  2706. cfg->line_outs++;
  2707. spec->line_switch = nid;
  2708. add_spec_dacs(spec, dac);
  2709. }
  2710. }
  2711. /* add mic as output */
  2712. nid = check_mic_out_switch(codec, &dac);
  2713. if (nid && dac) {
  2714. snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
  2715. nid, cfg->line_outs);
  2716. cfg->line_out_pins[cfg->line_outs] = nid;
  2717. cfg->line_outs++;
  2718. spec->mic_switch = nid;
  2719. add_spec_dacs(spec, dac);
  2720. }
  2721. snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
  2722. spec->multiout.num_dacs,
  2723. spec->multiout.dac_nids[0],
  2724. spec->multiout.dac_nids[1],
  2725. spec->multiout.dac_nids[2],
  2726. spec->multiout.dac_nids[3],
  2727. spec->multiout.dac_nids[4]);
  2728. return 0;
  2729. }
  2730. /* create volume control/switch for the given prefx type */
  2731. static int create_controls_idx(struct hda_codec *codec, const char *pfx,
  2732. int idx, hda_nid_t nid, int chs)
  2733. {
  2734. struct sigmatel_spec *spec = codec->spec;
  2735. char name[32];
  2736. int err;
  2737. if (!spec->check_volume_offset) {
  2738. unsigned int caps, step, nums, db_scale;
  2739. caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  2740. step = (caps & AC_AMPCAP_STEP_SIZE) >>
  2741. AC_AMPCAP_STEP_SIZE_SHIFT;
  2742. step = (step + 1) * 25; /* in .01dB unit */
  2743. nums = (caps & AC_AMPCAP_NUM_STEPS) >>
  2744. AC_AMPCAP_NUM_STEPS_SHIFT;
  2745. db_scale = nums * step;
  2746. /* if dB scale is over -64dB, and finer enough,
  2747. * let's reduce it to half
  2748. */
  2749. if (db_scale > 6400 && nums >= 0x1f)
  2750. spec->volume_offset = nums / 2;
  2751. spec->check_volume_offset = 1;
  2752. }
  2753. sprintf(name, "%s Playback Volume", pfx);
  2754. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
  2755. HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
  2756. spec->volume_offset));
  2757. if (err < 0)
  2758. return err;
  2759. sprintf(name, "%s Playback Switch", pfx);
  2760. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
  2761. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  2762. if (err < 0)
  2763. return err;
  2764. return 0;
  2765. }
  2766. #define create_controls(codec, pfx, nid, chs) \
  2767. create_controls_idx(codec, pfx, 0, nid, chs)
  2768. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  2769. {
  2770. if (spec->multiout.num_dacs > 4) {
  2771. printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
  2772. return 1;
  2773. } else {
  2774. snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
  2775. spec->dac_nids[spec->multiout.num_dacs] = nid;
  2776. spec->multiout.num_dacs++;
  2777. }
  2778. return 0;
  2779. }
  2780. static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  2781. {
  2782. int i;
  2783. for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
  2784. if (!spec->multiout.extra_out_nid[i]) {
  2785. spec->multiout.extra_out_nid[i] = nid;
  2786. return 0;
  2787. }
  2788. }
  2789. printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
  2790. return 1;
  2791. }
  2792. /* Create output controls
  2793. * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
  2794. */
  2795. static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
  2796. const hda_nid_t *pins,
  2797. const hda_nid_t *dac_nids,
  2798. int type)
  2799. {
  2800. struct sigmatel_spec *spec = codec->spec;
  2801. static const char * const chname[4] = {
  2802. "Front", "Surround", NULL /*CLFE*/, "Side"
  2803. };
  2804. hda_nid_t nid;
  2805. int i, err;
  2806. unsigned int wid_caps;
  2807. for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
  2808. if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
  2809. if (is_jack_detectable(codec, pins[i]))
  2810. spec->hp_detect = 1;
  2811. }
  2812. nid = dac_nids[i];
  2813. if (!nid)
  2814. continue;
  2815. if (type != AUTO_PIN_HP_OUT && i == 2) {
  2816. /* Center/LFE */
  2817. err = create_controls(codec, "Center", nid, 1);
  2818. if (err < 0)
  2819. return err;
  2820. err = create_controls(codec, "LFE", nid, 2);
  2821. if (err < 0)
  2822. return err;
  2823. wid_caps = get_wcaps(codec, nid);
  2824. if (wid_caps & AC_WCAP_LR_SWAP) {
  2825. err = stac92xx_add_control(spec,
  2826. STAC_CTL_WIDGET_CLFE_SWITCH,
  2827. "Swap Center/LFE Playback Switch", nid);
  2828. if (err < 0)
  2829. return err;
  2830. }
  2831. } else {
  2832. const char *name;
  2833. int idx;
  2834. switch (type) {
  2835. case AUTO_PIN_HP_OUT:
  2836. name = "Headphone";
  2837. idx = i;
  2838. break;
  2839. case AUTO_PIN_SPEAKER_OUT:
  2840. name = "Speaker";
  2841. idx = i;
  2842. break;
  2843. default:
  2844. name = chname[i];
  2845. idx = 0;
  2846. break;
  2847. }
  2848. err = create_controls_idx(codec, name, idx, nid, 3);
  2849. if (err < 0)
  2850. return err;
  2851. }
  2852. }
  2853. return 0;
  2854. }
  2855. static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
  2856. unsigned long sw, int idx)
  2857. {
  2858. int err;
  2859. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
  2860. "Capture Volume", vol);
  2861. if (err < 0)
  2862. return err;
  2863. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
  2864. "Capture Switch", sw);
  2865. if (err < 0)
  2866. return err;
  2867. return 0;
  2868. }
  2869. /* add playback controls from the parsed DAC table */
  2870. static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
  2871. const struct auto_pin_cfg *cfg)
  2872. {
  2873. struct sigmatel_spec *spec = codec->spec;
  2874. hda_nid_t nid;
  2875. int err;
  2876. int idx;
  2877. err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
  2878. spec->multiout.dac_nids,
  2879. cfg->line_out_type);
  2880. if (err < 0)
  2881. return err;
  2882. if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
  2883. err = stac92xx_add_control(spec,
  2884. STAC_CTL_WIDGET_HP_SWITCH,
  2885. "Headphone as Line Out Switch",
  2886. cfg->hp_pins[cfg->hp_outs - 1]);
  2887. if (err < 0)
  2888. return err;
  2889. }
  2890. for (idx = 0; idx < cfg->num_inputs; idx++) {
  2891. if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
  2892. break;
  2893. nid = cfg->inputs[idx].pin;
  2894. err = stac92xx_add_jack_mode_control(codec, nid, idx);
  2895. if (err < 0)
  2896. return err;
  2897. }
  2898. return 0;
  2899. }
  2900. /* add playback controls for Speaker and HP outputs */
  2901. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
  2902. struct auto_pin_cfg *cfg)
  2903. {
  2904. struct sigmatel_spec *spec = codec->spec;
  2905. int err;
  2906. err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
  2907. spec->hp_dacs, AUTO_PIN_HP_OUT);
  2908. if (err < 0)
  2909. return err;
  2910. err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
  2911. spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
  2912. if (err < 0)
  2913. return err;
  2914. return 0;
  2915. }
  2916. /* labels for mono mux outputs */
  2917. static const char * const stac92xx_mono_labels[4] = {
  2918. "DAC0", "DAC1", "Mixer", "DAC2"
  2919. };
  2920. /* create mono mux for mono out on capable codecs */
  2921. static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
  2922. {
  2923. struct sigmatel_spec *spec = codec->spec;
  2924. struct hda_input_mux *mono_mux = &spec->private_mono_mux;
  2925. int i, num_cons;
  2926. hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
  2927. num_cons = snd_hda_get_connections(codec,
  2928. spec->mono_nid,
  2929. con_lst,
  2930. HDA_MAX_NUM_INPUTS);
  2931. if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
  2932. return -EINVAL;
  2933. for (i = 0; i < num_cons; i++)
  2934. snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
  2935. NULL);
  2936. return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
  2937. "Mono Mux", spec->mono_nid);
  2938. }
  2939. /* create PC beep volume controls */
  2940. static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
  2941. hda_nid_t nid)
  2942. {
  2943. struct sigmatel_spec *spec = codec->spec;
  2944. u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  2945. int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
  2946. if (spec->anabeep_nid == nid)
  2947. type = STAC_CTL_WIDGET_MUTE;
  2948. /* check for mute support for the the amp */
  2949. if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
  2950. err = stac92xx_add_control(spec, type,
  2951. "Beep Playback Switch",
  2952. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
  2953. if (err < 0)
  2954. return err;
  2955. }
  2956. /* check to see if there is volume support for the amp */
  2957. if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
  2958. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
  2959. "Beep Playback Volume",
  2960. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
  2961. if (err < 0)
  2962. return err;
  2963. }
  2964. return 0;
  2965. }
  2966. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  2967. #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
  2968. static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
  2969. struct snd_ctl_elem_value *ucontrol)
  2970. {
  2971. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2972. ucontrol->value.integer.value[0] = codec->beep->enabled;
  2973. return 0;
  2974. }
  2975. static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
  2976. struct snd_ctl_elem_value *ucontrol)
  2977. {
  2978. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2979. return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
  2980. }
  2981. static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
  2982. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2983. .info = stac92xx_dig_beep_switch_info,
  2984. .get = stac92xx_dig_beep_switch_get,
  2985. .put = stac92xx_dig_beep_switch_put,
  2986. };
  2987. static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
  2988. {
  2989. return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
  2990. 0, "Beep Playback Switch", 0);
  2991. }
  2992. #endif
  2993. static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
  2994. {
  2995. struct sigmatel_spec *spec = codec->spec;
  2996. int i, j, err = 0;
  2997. for (i = 0; i < spec->num_muxes; i++) {
  2998. hda_nid_t nid;
  2999. unsigned int wcaps;
  3000. unsigned long val;
  3001. nid = spec->mux_nids[i];
  3002. wcaps = get_wcaps(codec, nid);
  3003. if (!(wcaps & AC_WCAP_OUT_AMP))
  3004. continue;
  3005. /* check whether already the same control was created as
  3006. * normal Capture Volume.
  3007. */
  3008. val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3009. for (j = 0; j < spec->num_caps; j++) {
  3010. if (spec->capvols[j] == val)
  3011. break;
  3012. }
  3013. if (j < spec->num_caps)
  3014. continue;
  3015. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
  3016. "Mux Capture Volume", val);
  3017. if (err < 0)
  3018. return err;
  3019. }
  3020. return 0;
  3021. };
  3022. static const char * const stac92xx_spdif_labels[3] = {
  3023. "Digital Playback", "Analog Mux 1", "Analog Mux 2",
  3024. };
  3025. static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
  3026. {
  3027. struct sigmatel_spec *spec = codec->spec;
  3028. struct hda_input_mux *spdif_mux = &spec->private_smux;
  3029. const char * const *labels = spec->spdif_labels;
  3030. int i, num_cons;
  3031. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  3032. num_cons = snd_hda_get_connections(codec,
  3033. spec->smux_nids[0],
  3034. con_lst,
  3035. HDA_MAX_NUM_INPUTS);
  3036. if (num_cons <= 0)
  3037. return -EINVAL;
  3038. if (!labels)
  3039. labels = stac92xx_spdif_labels;
  3040. for (i = 0; i < num_cons; i++)
  3041. snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
  3042. return 0;
  3043. }
  3044. /* labels for dmic mux inputs */
  3045. static const char * const stac92xx_dmic_labels[5] = {
  3046. "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
  3047. "Digital Mic 3", "Digital Mic 4"
  3048. };
  3049. static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
  3050. int idx)
  3051. {
  3052. hda_nid_t conn[HDA_MAX_NUM_INPUTS];
  3053. int nums;
  3054. nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
  3055. if (idx >= 0 && idx < nums)
  3056. return conn[idx];
  3057. return 0;
  3058. }
  3059. /* look for NID recursively */
  3060. #define get_connection_index(codec, mux, nid) \
  3061. snd_hda_get_conn_index(codec, mux, nid, 1)
  3062. /* create a volume assigned to the given pin (only if supported) */
  3063. /* return 1 if the volume control is created */
  3064. static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
  3065. const char *label, int idx, int direction)
  3066. {
  3067. unsigned int caps, nums;
  3068. char name[32];
  3069. int err;
  3070. if (direction == HDA_OUTPUT)
  3071. caps = AC_WCAP_OUT_AMP;
  3072. else
  3073. caps = AC_WCAP_IN_AMP;
  3074. if (!(get_wcaps(codec, nid) & caps))
  3075. return 0;
  3076. caps = query_amp_caps(codec, nid, direction);
  3077. nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
  3078. if (!nums)
  3079. return 0;
  3080. snprintf(name, sizeof(name), "%s Capture Volume", label);
  3081. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
  3082. HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
  3083. if (err < 0)
  3084. return err;
  3085. return 1;
  3086. }
  3087. /* create playback/capture controls for input pins on dmic capable codecs */
  3088. static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
  3089. const struct auto_pin_cfg *cfg)
  3090. {
  3091. struct sigmatel_spec *spec = codec->spec;
  3092. struct hda_input_mux *imux = &spec->private_imux;
  3093. struct hda_input_mux *dimux = &spec->private_dimux;
  3094. int err, i;
  3095. unsigned int def_conf;
  3096. snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
  3097. for (i = 0; i < spec->num_dmics; i++) {
  3098. hda_nid_t nid;
  3099. int index, type_idx;
  3100. char label[32];
  3101. nid = spec->dmic_nids[i];
  3102. if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
  3103. continue;
  3104. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  3105. if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
  3106. continue;
  3107. index = get_connection_index(codec, spec->dmux_nids[0], nid);
  3108. if (index < 0)
  3109. continue;
  3110. snd_hda_get_pin_label(codec, nid, &spec->autocfg,
  3111. label, sizeof(label), NULL);
  3112. snd_hda_add_imux_item(dimux, label, index, &type_idx);
  3113. if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
  3114. snd_hda_add_imux_item(imux, label, index, &type_idx);
  3115. err = create_elem_capture_vol(codec, nid, label, type_idx,
  3116. HDA_INPUT);
  3117. if (err < 0)
  3118. return err;
  3119. if (!err) {
  3120. err = create_elem_capture_vol(codec, nid, label,
  3121. type_idx, HDA_OUTPUT);
  3122. if (err < 0)
  3123. return err;
  3124. if (!err) {
  3125. nid = get_connected_node(codec,
  3126. spec->dmux_nids[0], index);
  3127. if (nid)
  3128. err = create_elem_capture_vol(codec,
  3129. nid, label,
  3130. type_idx, HDA_INPUT);
  3131. if (err < 0)
  3132. return err;
  3133. }
  3134. }
  3135. }
  3136. return 0;
  3137. }
  3138. static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
  3139. hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
  3140. {
  3141. unsigned int cfg;
  3142. unsigned int type;
  3143. if (!nid)
  3144. return 0;
  3145. cfg = snd_hda_codec_get_pincfg(codec, nid);
  3146. type = get_defcfg_device(cfg);
  3147. switch (snd_hda_get_input_pin_attr(cfg)) {
  3148. case INPUT_PIN_ATTR_INT:
  3149. if (*fixed)
  3150. return 1; /* already occupied */
  3151. if (type != AC_JACK_MIC_IN)
  3152. return 1; /* invalid type */
  3153. *fixed = nid;
  3154. break;
  3155. case INPUT_PIN_ATTR_UNUSED:
  3156. break;
  3157. case INPUT_PIN_ATTR_DOCK:
  3158. if (*dock)
  3159. return 1; /* already occupied */
  3160. if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
  3161. return 1; /* invalid type */
  3162. *dock = nid;
  3163. break;
  3164. default:
  3165. if (*ext)
  3166. return 1; /* already occupied */
  3167. if (type != AC_JACK_MIC_IN)
  3168. return 1; /* invalid type */
  3169. *ext = nid;
  3170. break;
  3171. }
  3172. return 0;
  3173. }
  3174. static int set_mic_route(struct hda_codec *codec,
  3175. struct sigmatel_mic_route *mic,
  3176. hda_nid_t pin)
  3177. {
  3178. struct sigmatel_spec *spec = codec->spec;
  3179. struct auto_pin_cfg *cfg = &spec->autocfg;
  3180. int i;
  3181. mic->pin = pin;
  3182. if (pin == 0)
  3183. return 0;
  3184. for (i = 0; i < cfg->num_inputs; i++) {
  3185. if (pin == cfg->inputs[i].pin)
  3186. break;
  3187. }
  3188. if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
  3189. /* analog pin */
  3190. i = get_connection_index(codec, spec->mux_nids[0], pin);
  3191. if (i < 0)
  3192. return -1;
  3193. mic->mux_idx = i;
  3194. mic->dmux_idx = -1;
  3195. if (spec->dmux_nids)
  3196. mic->dmux_idx = get_connection_index(codec,
  3197. spec->dmux_nids[0],
  3198. spec->mux_nids[0]);
  3199. } else if (spec->dmux_nids) {
  3200. /* digital pin */
  3201. i = get_connection_index(codec, spec->dmux_nids[0], pin);
  3202. if (i < 0)
  3203. return -1;
  3204. mic->dmux_idx = i;
  3205. mic->mux_idx = -1;
  3206. if (spec->mux_nids)
  3207. mic->mux_idx = get_connection_index(codec,
  3208. spec->mux_nids[0],
  3209. spec->dmux_nids[0]);
  3210. }
  3211. return 0;
  3212. }
  3213. /* return non-zero if the device is for automatic mic switch */
  3214. static int stac_check_auto_mic(struct hda_codec *codec)
  3215. {
  3216. struct sigmatel_spec *spec = codec->spec;
  3217. struct auto_pin_cfg *cfg = &spec->autocfg;
  3218. hda_nid_t fixed, ext, dock;
  3219. int i;
  3220. fixed = ext = dock = 0;
  3221. for (i = 0; i < cfg->num_inputs; i++)
  3222. if (check_mic_pin(codec, cfg->inputs[i].pin,
  3223. &fixed, &ext, &dock))
  3224. return 0;
  3225. for (i = 0; i < spec->num_dmics; i++)
  3226. if (check_mic_pin(codec, spec->dmic_nids[i],
  3227. &fixed, &ext, &dock))
  3228. return 0;
  3229. if (!fixed || (!ext && !dock))
  3230. return 0; /* no input to switch */
  3231. if (!is_jack_detectable(codec, ext))
  3232. return 0; /* no unsol support */
  3233. if (set_mic_route(codec, &spec->ext_mic, ext) ||
  3234. set_mic_route(codec, &spec->int_mic, fixed) ||
  3235. set_mic_route(codec, &spec->dock_mic, dock))
  3236. return 0; /* something is wrong */
  3237. return 1;
  3238. }
  3239. /* create playback/capture controls for input pins */
  3240. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  3241. {
  3242. struct sigmatel_spec *spec = codec->spec;
  3243. struct hda_input_mux *imux = &spec->private_imux;
  3244. int i, j;
  3245. const char *label;
  3246. for (i = 0; i < cfg->num_inputs; i++) {
  3247. hda_nid_t nid = cfg->inputs[i].pin;
  3248. int index, err, type_idx;
  3249. index = -1;
  3250. for (j = 0; j < spec->num_muxes; j++) {
  3251. index = get_connection_index(codec, spec->mux_nids[j],
  3252. nid);
  3253. if (index >= 0)
  3254. break;
  3255. }
  3256. if (index < 0)
  3257. continue;
  3258. label = hda_get_autocfg_input_label(codec, cfg, i);
  3259. snd_hda_add_imux_item(imux, label, index, &type_idx);
  3260. err = create_elem_capture_vol(codec, nid,
  3261. label, type_idx,
  3262. HDA_INPUT);
  3263. if (err < 0)
  3264. return err;
  3265. }
  3266. spec->num_analog_muxes = imux->num_items;
  3267. if (imux->num_items) {
  3268. /*
  3269. * Set the current input for the muxes.
  3270. * The STAC9221 has two input muxes with identical source
  3271. * NID lists. Hopefully this won't get confused.
  3272. */
  3273. for (i = 0; i < spec->num_muxes; i++) {
  3274. snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
  3275. AC_VERB_SET_CONNECT_SEL,
  3276. imux->items[0].index);
  3277. }
  3278. }
  3279. return 0;
  3280. }
  3281. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  3282. {
  3283. struct sigmatel_spec *spec = codec->spec;
  3284. int i;
  3285. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3286. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3287. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  3288. }
  3289. }
  3290. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  3291. {
  3292. struct sigmatel_spec *spec = codec->spec;
  3293. int i;
  3294. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  3295. hda_nid_t pin;
  3296. pin = spec->autocfg.hp_pins[i];
  3297. if (pin) /* connect to front */
  3298. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  3299. }
  3300. for (i = 0; i < spec->autocfg.speaker_outs; i++) {
  3301. hda_nid_t pin;
  3302. pin = spec->autocfg.speaker_pins[i];
  3303. if (pin) /* connect to front */
  3304. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
  3305. }
  3306. }
  3307. static int is_dual_headphones(struct hda_codec *codec)
  3308. {
  3309. struct sigmatel_spec *spec = codec->spec;
  3310. int i, valid_hps;
  3311. if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
  3312. spec->autocfg.hp_outs <= 1)
  3313. return 0;
  3314. valid_hps = 0;
  3315. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  3316. hda_nid_t nid = spec->autocfg.hp_pins[i];
  3317. unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
  3318. if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
  3319. continue;
  3320. valid_hps++;
  3321. }
  3322. return (valid_hps > 1);
  3323. }
  3324. static int stac92xx_parse_auto_config(struct hda_codec *codec)
  3325. {
  3326. struct sigmatel_spec *spec = codec->spec;
  3327. hda_nid_t dig_out = 0, dig_in = 0;
  3328. int hp_swap = 0;
  3329. int i, err;
  3330. if ((err = snd_hda_parse_pin_def_config(codec,
  3331. &spec->autocfg,
  3332. spec->dmic_nids)) < 0)
  3333. return err;
  3334. if (! spec->autocfg.line_outs)
  3335. return 0; /* can't find valid pin config */
  3336. /* If we have no real line-out pin and multiple hp-outs, HPs should
  3337. * be set up as multi-channel outputs.
  3338. */
  3339. if (is_dual_headphones(codec)) {
  3340. /* Copy hp_outs to line_outs, backup line_outs in
  3341. * speaker_outs so that the following routines can handle
  3342. * HP pins as primary outputs.
  3343. */
  3344. snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
  3345. memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
  3346. sizeof(spec->autocfg.line_out_pins));
  3347. spec->autocfg.speaker_outs = spec->autocfg.line_outs;
  3348. memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
  3349. sizeof(spec->autocfg.hp_pins));
  3350. spec->autocfg.line_outs = spec->autocfg.hp_outs;
  3351. spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
  3352. spec->autocfg.hp_outs = 0;
  3353. hp_swap = 1;
  3354. }
  3355. if (spec->autocfg.mono_out_pin) {
  3356. int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
  3357. (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
  3358. u32 caps = query_amp_caps(codec,
  3359. spec->autocfg.mono_out_pin, dir);
  3360. hda_nid_t conn_list[1];
  3361. /* get the mixer node and then the mono mux if it exists */
  3362. if (snd_hda_get_connections(codec,
  3363. spec->autocfg.mono_out_pin, conn_list, 1) &&
  3364. snd_hda_get_connections(codec, conn_list[0],
  3365. conn_list, 1) > 0) {
  3366. int wcaps = get_wcaps(codec, conn_list[0]);
  3367. int wid_type = get_wcaps_type(wcaps);
  3368. /* LR swap check, some stac925x have a mux that
  3369. * changes the DACs output path instead of the
  3370. * mono-mux path.
  3371. */
  3372. if (wid_type == AC_WID_AUD_SEL &&
  3373. !(wcaps & AC_WCAP_LR_SWAP))
  3374. spec->mono_nid = conn_list[0];
  3375. }
  3376. if (dir) {
  3377. hda_nid_t nid = spec->autocfg.mono_out_pin;
  3378. /* most mono outs have a least a mute/unmute switch */
  3379. dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
  3380. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
  3381. "Mono Playback Switch",
  3382. HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
  3383. if (err < 0)
  3384. return err;
  3385. /* check for volume support for the amp */
  3386. if ((caps & AC_AMPCAP_NUM_STEPS)
  3387. >> AC_AMPCAP_NUM_STEPS_SHIFT) {
  3388. err = stac92xx_add_control(spec,
  3389. STAC_CTL_WIDGET_VOL,
  3390. "Mono Playback Volume",
  3391. HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
  3392. if (err < 0)
  3393. return err;
  3394. }
  3395. }
  3396. stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
  3397. AC_PINCTL_OUT_EN);
  3398. }
  3399. if (!spec->multiout.num_dacs) {
  3400. err = stac92xx_auto_fill_dac_nids(codec);
  3401. if (err < 0)
  3402. return err;
  3403. err = stac92xx_auto_create_multi_out_ctls(codec,
  3404. &spec->autocfg);
  3405. if (err < 0)
  3406. return err;
  3407. }
  3408. /* setup analog beep controls */
  3409. if (spec->anabeep_nid > 0) {
  3410. err = stac92xx_auto_create_beep_ctls(codec,
  3411. spec->anabeep_nid);
  3412. if (err < 0)
  3413. return err;
  3414. }
  3415. /* setup digital beep controls and input device */
  3416. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  3417. if (spec->digbeep_nid > 0) {
  3418. hda_nid_t nid = spec->digbeep_nid;
  3419. unsigned int caps;
  3420. err = stac92xx_auto_create_beep_ctls(codec, nid);
  3421. if (err < 0)
  3422. return err;
  3423. err = snd_hda_attach_beep_device(codec, nid);
  3424. if (err < 0)
  3425. return err;
  3426. if (codec->beep) {
  3427. /* IDT/STAC codecs have linear beep tone parameter */
  3428. codec->beep->linear_tone = spec->linear_tone_beep;
  3429. /* if no beep switch is available, make its own one */
  3430. caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  3431. if (!(caps & AC_AMPCAP_MUTE)) {
  3432. err = stac92xx_beep_switch_ctl(codec);
  3433. if (err < 0)
  3434. return err;
  3435. }
  3436. }
  3437. }
  3438. #endif
  3439. err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
  3440. if (err < 0)
  3441. return err;
  3442. /* All output parsing done, now restore the swapped hp pins */
  3443. if (hp_swap) {
  3444. memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
  3445. sizeof(spec->autocfg.hp_pins));
  3446. spec->autocfg.hp_outs = spec->autocfg.line_outs;
  3447. spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
  3448. spec->autocfg.line_outs = 0;
  3449. }
  3450. if (stac_check_auto_mic(codec)) {
  3451. spec->auto_mic = 1;
  3452. /* only one capture for auto-mic */
  3453. spec->num_adcs = 1;
  3454. spec->num_caps = 1;
  3455. spec->num_muxes = 1;
  3456. }
  3457. for (i = 0; i < spec->num_caps; i++) {
  3458. err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
  3459. spec->capsws[i], i);
  3460. if (err < 0)
  3461. return err;
  3462. }
  3463. err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
  3464. if (err < 0)
  3465. return err;
  3466. if (spec->mono_nid > 0) {
  3467. err = stac92xx_auto_create_mono_output_ctls(codec);
  3468. if (err < 0)
  3469. return err;
  3470. }
  3471. if (spec->num_dmics > 0 && !spec->dinput_mux)
  3472. if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
  3473. &spec->autocfg)) < 0)
  3474. return err;
  3475. if (spec->num_muxes > 0) {
  3476. err = stac92xx_auto_create_mux_input_ctls(codec);
  3477. if (err < 0)
  3478. return err;
  3479. }
  3480. if (spec->num_smuxes > 0) {
  3481. err = stac92xx_auto_create_spdif_mux_ctls(codec);
  3482. if (err < 0)
  3483. return err;
  3484. }
  3485. err = stac92xx_add_input_source(spec);
  3486. if (err < 0)
  3487. return err;
  3488. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3489. if (spec->multiout.max_channels > 2)
  3490. spec->surr_switch = 1;
  3491. /* find digital out and in converters */
  3492. for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
  3493. unsigned int wid_caps = get_wcaps(codec, i);
  3494. if (wid_caps & AC_WCAP_DIGITAL) {
  3495. switch (get_wcaps_type(wid_caps)) {
  3496. case AC_WID_AUD_OUT:
  3497. if (!dig_out)
  3498. dig_out = i;
  3499. break;
  3500. case AC_WID_AUD_IN:
  3501. if (!dig_in)
  3502. dig_in = i;
  3503. break;
  3504. }
  3505. }
  3506. }
  3507. if (spec->autocfg.dig_outs)
  3508. spec->multiout.dig_out_nid = dig_out;
  3509. if (dig_in && spec->autocfg.dig_in_pin)
  3510. spec->dig_in_nid = dig_in;
  3511. if (spec->kctls.list)
  3512. spec->mixers[spec->num_mixers++] = spec->kctls.list;
  3513. spec->input_mux = &spec->private_imux;
  3514. if (!spec->dinput_mux)
  3515. spec->dinput_mux = &spec->private_dimux;
  3516. spec->sinput_mux = &spec->private_smux;
  3517. spec->mono_mux = &spec->private_mono_mux;
  3518. return 1;
  3519. }
  3520. /* add playback controls for HP output */
  3521. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  3522. struct auto_pin_cfg *cfg)
  3523. {
  3524. struct sigmatel_spec *spec = codec->spec;
  3525. hda_nid_t pin = cfg->hp_pins[0];
  3526. if (! pin)
  3527. return 0;
  3528. if (is_jack_detectable(codec, pin))
  3529. spec->hp_detect = 1;
  3530. return 0;
  3531. }
  3532. /* add playback controls for LFE output */
  3533. static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
  3534. struct auto_pin_cfg *cfg)
  3535. {
  3536. struct sigmatel_spec *spec = codec->spec;
  3537. int err;
  3538. hda_nid_t lfe_pin = 0x0;
  3539. int i;
  3540. /*
  3541. * search speaker outs and line outs for a mono speaker pin
  3542. * with an amp. If one is found, add LFE controls
  3543. * for it.
  3544. */
  3545. for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
  3546. hda_nid_t pin = spec->autocfg.speaker_pins[i];
  3547. unsigned int wcaps = get_wcaps(codec, pin);
  3548. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  3549. if (wcaps == AC_WCAP_OUT_AMP)
  3550. /* found a mono speaker with an amp, must be lfe */
  3551. lfe_pin = pin;
  3552. }
  3553. /* if speaker_outs is 0, then speakers may be in line_outs */
  3554. if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
  3555. for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
  3556. hda_nid_t pin = spec->autocfg.line_out_pins[i];
  3557. unsigned int defcfg;
  3558. defcfg = snd_hda_codec_get_pincfg(codec, pin);
  3559. if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
  3560. unsigned int wcaps = get_wcaps(codec, pin);
  3561. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  3562. if (wcaps == AC_WCAP_OUT_AMP)
  3563. /* found a mono speaker with an amp,
  3564. must be lfe */
  3565. lfe_pin = pin;
  3566. }
  3567. }
  3568. }
  3569. if (lfe_pin) {
  3570. err = create_controls(codec, "LFE", lfe_pin, 1);
  3571. if (err < 0)
  3572. return err;
  3573. }
  3574. return 0;
  3575. }
  3576. static int stac9200_parse_auto_config(struct hda_codec *codec)
  3577. {
  3578. struct sigmatel_spec *spec = codec->spec;
  3579. int err;
  3580. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  3581. return err;
  3582. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  3583. return err;
  3584. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  3585. return err;
  3586. if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
  3587. return err;
  3588. if (spec->num_muxes > 0) {
  3589. err = stac92xx_auto_create_mux_input_ctls(codec);
  3590. if (err < 0)
  3591. return err;
  3592. }
  3593. err = stac92xx_add_input_source(spec);
  3594. if (err < 0)
  3595. return err;
  3596. if (spec->autocfg.dig_outs)
  3597. spec->multiout.dig_out_nid = 0x05;
  3598. if (spec->autocfg.dig_in_pin)
  3599. spec->dig_in_nid = 0x04;
  3600. if (spec->kctls.list)
  3601. spec->mixers[spec->num_mixers++] = spec->kctls.list;
  3602. spec->input_mux = &spec->private_imux;
  3603. spec->dinput_mux = &spec->private_dimux;
  3604. return 1;
  3605. }
  3606. /*
  3607. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  3608. * funky external mute control using GPIO pins.
  3609. */
  3610. static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
  3611. unsigned int dir_mask, unsigned int data)
  3612. {
  3613. unsigned int gpiostate, gpiomask, gpiodir;
  3614. snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
  3615. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  3616. AC_VERB_GET_GPIO_DATA, 0);
  3617. gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
  3618. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  3619. AC_VERB_GET_GPIO_MASK, 0);
  3620. gpiomask |= mask;
  3621. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  3622. AC_VERB_GET_GPIO_DIRECTION, 0);
  3623. gpiodir |= dir_mask;
  3624. /* Configure GPIOx as CMOS */
  3625. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  3626. snd_hda_codec_write(codec, codec->afg, 0,
  3627. AC_VERB_SET_GPIO_MASK, gpiomask);
  3628. snd_hda_codec_read(codec, codec->afg, 0,
  3629. AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
  3630. msleep(1);
  3631. snd_hda_codec_read(codec, codec->afg, 0,
  3632. AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
  3633. }
  3634. static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
  3635. unsigned char type, int data)
  3636. {
  3637. struct hda_jack_tbl *event;
  3638. event = snd_hda_jack_tbl_new(codec, nid);
  3639. if (!event)
  3640. return -ENOMEM;
  3641. event->action = type;
  3642. event->private_data = data;
  3643. return 0;
  3644. }
  3645. /* check if given nid is a valid pin and no other events are assigned
  3646. * to it. If OK, assign the event, set the unsol flag, and returns 1.
  3647. * Otherwise, returns zero.
  3648. */
  3649. static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
  3650. unsigned int type)
  3651. {
  3652. struct hda_jack_tbl *event;
  3653. if (!is_jack_detectable(codec, nid))
  3654. return 0;
  3655. event = snd_hda_jack_tbl_new(codec, nid);
  3656. if (!event)
  3657. return -ENOMEM;
  3658. if (event->action && event->action != type)
  3659. return 0;
  3660. event->action = type;
  3661. snd_hda_jack_detect_enable(codec, nid, 0);
  3662. return 1;
  3663. }
  3664. static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
  3665. {
  3666. int i;
  3667. for (i = 0; i < cfg->hp_outs; i++)
  3668. if (cfg->hp_pins[i] == nid)
  3669. return 1; /* nid is a HP-Out */
  3670. for (i = 0; i < cfg->line_outs; i++)
  3671. if (cfg->line_out_pins[i] == nid)
  3672. return 1; /* nid is a line-Out */
  3673. return 0; /* nid is not a HP-Out */
  3674. };
  3675. static void stac92xx_power_down(struct hda_codec *codec)
  3676. {
  3677. struct sigmatel_spec *spec = codec->spec;
  3678. /* power down inactive DACs */
  3679. const hda_nid_t *dac;
  3680. for (dac = spec->dac_list; *dac; dac++)
  3681. if (!check_all_dac_nids(spec, *dac))
  3682. snd_hda_codec_write(codec, *dac, 0,
  3683. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  3684. }
  3685. static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
  3686. int enable);
  3687. static inline int get_int_hint(struct hda_codec *codec, const char *key,
  3688. int *valp)
  3689. {
  3690. const char *p;
  3691. p = snd_hda_get_hint(codec, key);
  3692. if (p) {
  3693. unsigned long val;
  3694. if (!strict_strtoul(p, 0, &val)) {
  3695. *valp = val;
  3696. return 1;
  3697. }
  3698. }
  3699. return 0;
  3700. }
  3701. /* override some hints from the hwdep entry */
  3702. static void stac_store_hints(struct hda_codec *codec)
  3703. {
  3704. struct sigmatel_spec *spec = codec->spec;
  3705. int val;
  3706. val = snd_hda_get_bool_hint(codec, "hp_detect");
  3707. if (val >= 0)
  3708. spec->hp_detect = val;
  3709. if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
  3710. spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
  3711. spec->gpio_mask;
  3712. }
  3713. if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
  3714. spec->gpio_mask &= spec->gpio_mask;
  3715. if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
  3716. spec->gpio_dir &= spec->gpio_mask;
  3717. if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
  3718. spec->eapd_mask &= spec->gpio_mask;
  3719. if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
  3720. spec->gpio_mute &= spec->gpio_mask;
  3721. val = snd_hda_get_bool_hint(codec, "eapd_switch");
  3722. if (val >= 0)
  3723. spec->eapd_switch = val;
  3724. }
  3725. static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
  3726. const hda_nid_t *pins)
  3727. {
  3728. while (num_pins--)
  3729. stac_issue_unsol_event(codec, *pins++);
  3730. }
  3731. /* fake event to set up pins */
  3732. static void stac_fake_hp_events(struct hda_codec *codec)
  3733. {
  3734. struct sigmatel_spec *spec = codec->spec;
  3735. if (spec->autocfg.hp_outs)
  3736. stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
  3737. spec->autocfg.hp_pins);
  3738. if (spec->autocfg.line_outs &&
  3739. spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
  3740. stac_issue_unsol_events(codec, spec->autocfg.line_outs,
  3741. spec->autocfg.line_out_pins);
  3742. }
  3743. static int stac92xx_init(struct hda_codec *codec)
  3744. {
  3745. struct sigmatel_spec *spec = codec->spec;
  3746. struct auto_pin_cfg *cfg = &spec->autocfg;
  3747. unsigned int gpio;
  3748. int i;
  3749. snd_hda_sequence_write(codec, spec->init);
  3750. /* power down adcs initially */
  3751. if (spec->powerdown_adcs)
  3752. for (i = 0; i < spec->num_adcs; i++)
  3753. snd_hda_codec_write(codec,
  3754. spec->adc_nids[i], 0,
  3755. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  3756. /* override some hints */
  3757. stac_store_hints(codec);
  3758. /* set up GPIO */
  3759. gpio = spec->gpio_data;
  3760. /* turn on EAPD statically when spec->eapd_switch isn't set.
  3761. * otherwise, unsol event will turn it on/off dynamically
  3762. */
  3763. if (!spec->eapd_switch)
  3764. gpio |= spec->eapd_mask;
  3765. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
  3766. /* set up pins */
  3767. if (spec->hp_detect) {
  3768. /* Enable unsolicited responses on the HP widget */
  3769. for (i = 0; i < cfg->hp_outs; i++) {
  3770. hda_nid_t nid = cfg->hp_pins[i];
  3771. enable_pin_detect(codec, nid, STAC_HP_EVENT);
  3772. }
  3773. if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
  3774. cfg->speaker_outs > 0) {
  3775. /* enable pin-detect for line-outs as well */
  3776. for (i = 0; i < cfg->line_outs; i++) {
  3777. hda_nid_t nid = cfg->line_out_pins[i];
  3778. enable_pin_detect(codec, nid, STAC_LO_EVENT);
  3779. }
  3780. }
  3781. /* force to enable the first line-out; the others are set up
  3782. * in unsol_event
  3783. */
  3784. stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
  3785. AC_PINCTL_OUT_EN);
  3786. /* fake event to set up pins */
  3787. stac_fake_hp_events(codec);
  3788. } else {
  3789. stac92xx_auto_init_multi_out(codec);
  3790. stac92xx_auto_init_hp_out(codec);
  3791. for (i = 0; i < cfg->hp_outs; i++)
  3792. stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
  3793. }
  3794. if (spec->auto_mic) {
  3795. /* initialize connection to analog input */
  3796. if (spec->dmux_nids)
  3797. snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
  3798. AC_VERB_SET_CONNECT_SEL, 0);
  3799. if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
  3800. stac_issue_unsol_event(codec, spec->ext_mic.pin);
  3801. if (enable_pin_detect(codec, spec->dock_mic.pin,
  3802. STAC_MIC_EVENT))
  3803. stac_issue_unsol_event(codec, spec->dock_mic.pin);
  3804. }
  3805. for (i = 0; i < cfg->num_inputs; i++) {
  3806. hda_nid_t nid = cfg->inputs[i].pin;
  3807. int type = cfg->inputs[i].type;
  3808. unsigned int pinctl, conf;
  3809. if (type == AUTO_PIN_MIC) {
  3810. /* for mic pins, force to initialize */
  3811. pinctl = snd_hda_get_default_vref(codec, nid);
  3812. pinctl |= AC_PINCTL_IN_EN;
  3813. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  3814. } else {
  3815. pinctl = snd_hda_codec_read(codec, nid, 0,
  3816. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3817. /* if PINCTL already set then skip */
  3818. /* Also, if both INPUT and OUTPUT are set,
  3819. * it must be a BIOS bug; need to override, too
  3820. */
  3821. if (!(pinctl & AC_PINCTL_IN_EN) ||
  3822. (pinctl & AC_PINCTL_OUT_EN)) {
  3823. pinctl &= ~AC_PINCTL_OUT_EN;
  3824. pinctl |= AC_PINCTL_IN_EN;
  3825. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  3826. }
  3827. }
  3828. conf = snd_hda_codec_get_pincfg(codec, nid);
  3829. if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
  3830. if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
  3831. stac_issue_unsol_event(codec, nid);
  3832. }
  3833. }
  3834. for (i = 0; i < spec->num_dmics; i++)
  3835. stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
  3836. AC_PINCTL_IN_EN);
  3837. if (cfg->dig_out_pins[0])
  3838. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
  3839. AC_PINCTL_OUT_EN);
  3840. if (cfg->dig_in_pin)
  3841. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  3842. AC_PINCTL_IN_EN);
  3843. for (i = 0; i < spec->num_pwrs; i++) {
  3844. hda_nid_t nid = spec->pwr_nids[i];
  3845. unsigned int pinctl, def_conf;
  3846. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  3847. def_conf = get_defcfg_connect(def_conf);
  3848. if (def_conf == AC_JACK_PORT_NONE) {
  3849. /* power off unused ports */
  3850. stac_toggle_power_map(codec, nid, 0);
  3851. continue;
  3852. }
  3853. if (def_conf == AC_JACK_PORT_FIXED) {
  3854. /* no need for jack detection for fixed pins */
  3855. stac_toggle_power_map(codec, nid, 1);
  3856. continue;
  3857. }
  3858. /* power on when no jack detection is available */
  3859. /* or when the VREF is used for controlling LED */
  3860. if (!spec->hp_detect ||
  3861. spec->vref_mute_led_nid == nid ||
  3862. !is_jack_detectable(codec, nid)) {
  3863. stac_toggle_power_map(codec, nid, 1);
  3864. continue;
  3865. }
  3866. if (is_nid_out_jack_pin(cfg, nid))
  3867. continue; /* already has an unsol event */
  3868. pinctl = snd_hda_codec_read(codec, nid, 0,
  3869. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3870. /* outputs are only ports capable of power management
  3871. * any attempts on powering down a input port cause the
  3872. * referenced VREF to act quirky.
  3873. */
  3874. if (pinctl & AC_PINCTL_IN_EN) {
  3875. stac_toggle_power_map(codec, nid, 1);
  3876. continue;
  3877. }
  3878. if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
  3879. stac_issue_unsol_event(codec, nid);
  3880. continue;
  3881. }
  3882. /* none of the above, turn the port OFF */
  3883. stac_toggle_power_map(codec, nid, 0);
  3884. }
  3885. snd_hda_jack_report_sync(codec);
  3886. /* sync mute LED */
  3887. snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
  3888. /* sync the power-map */
  3889. if (spec->num_pwrs)
  3890. snd_hda_codec_write(codec, codec->afg, 0,
  3891. AC_VERB_IDT_SET_POWER_MAP,
  3892. spec->power_map_bits);
  3893. if (spec->dac_list)
  3894. stac92xx_power_down(codec);
  3895. return 0;
  3896. }
  3897. static void stac92xx_free_kctls(struct hda_codec *codec)
  3898. {
  3899. struct sigmatel_spec *spec = codec->spec;
  3900. if (spec->kctls.list) {
  3901. struct snd_kcontrol_new *kctl = spec->kctls.list;
  3902. int i;
  3903. for (i = 0; i < spec->kctls.used; i++)
  3904. kfree(kctl[i].name);
  3905. }
  3906. snd_array_free(&spec->kctls);
  3907. }
  3908. static void stac92xx_shutup_pins(struct hda_codec *codec)
  3909. {
  3910. unsigned int i, def_conf;
  3911. if (codec->bus->shutdown)
  3912. return;
  3913. for (i = 0; i < codec->init_pins.used; i++) {
  3914. struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
  3915. def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
  3916. if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
  3917. snd_hda_set_pin_ctl(codec, pin->nid, 0);
  3918. }
  3919. }
  3920. static void stac92xx_shutup(struct hda_codec *codec)
  3921. {
  3922. struct sigmatel_spec *spec = codec->spec;
  3923. stac92xx_shutup_pins(codec);
  3924. if (spec->eapd_mask)
  3925. stac_gpio_set(codec, spec->gpio_mask,
  3926. spec->gpio_dir, spec->gpio_data &
  3927. ~spec->eapd_mask);
  3928. }
  3929. static void stac92xx_free(struct hda_codec *codec)
  3930. {
  3931. struct sigmatel_spec *spec = codec->spec;
  3932. if (! spec)
  3933. return;
  3934. stac92xx_shutup(codec);
  3935. kfree(spec);
  3936. snd_hda_detach_beep_device(codec);
  3937. }
  3938. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  3939. unsigned int flag)
  3940. {
  3941. unsigned int old_ctl, pin_ctl;
  3942. pin_ctl = snd_hda_codec_read(codec, nid,
  3943. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  3944. if (pin_ctl & AC_PINCTL_IN_EN) {
  3945. /*
  3946. * we need to check the current set-up direction of
  3947. * shared input pins since they can be switched via
  3948. * "xxx as Output" mixer switch
  3949. */
  3950. struct sigmatel_spec *spec = codec->spec;
  3951. if (nid == spec->line_switch || nid == spec->mic_switch)
  3952. return;
  3953. }
  3954. old_ctl = pin_ctl;
  3955. /* if setting pin direction bits, clear the current
  3956. direction bits first */
  3957. if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
  3958. pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
  3959. pin_ctl |= flag;
  3960. if (old_ctl != pin_ctl)
  3961. snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
  3962. }
  3963. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  3964. unsigned int flag)
  3965. {
  3966. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  3967. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  3968. if (pin_ctl & flag)
  3969. snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
  3970. }
  3971. static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
  3972. {
  3973. if (!nid)
  3974. return 0;
  3975. return snd_hda_jack_detect(codec, nid);
  3976. }
  3977. static void stac92xx_line_out_detect(struct hda_codec *codec,
  3978. int presence)
  3979. {
  3980. struct sigmatel_spec *spec = codec->spec;
  3981. struct auto_pin_cfg *cfg = &spec->autocfg;
  3982. int i;
  3983. for (i = 0; i < cfg->line_outs; i++) {
  3984. if (presence)
  3985. break;
  3986. presence = get_pin_presence(codec, cfg->line_out_pins[i]);
  3987. if (presence) {
  3988. unsigned int pinctl;
  3989. pinctl = snd_hda_codec_read(codec,
  3990. cfg->line_out_pins[i], 0,
  3991. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3992. if (pinctl & AC_PINCTL_IN_EN)
  3993. presence = 0; /* mic- or line-input */
  3994. }
  3995. }
  3996. if (presence) {
  3997. /* disable speakers */
  3998. for (i = 0; i < cfg->speaker_outs; i++)
  3999. stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
  4000. AC_PINCTL_OUT_EN);
  4001. if (spec->eapd_mask && spec->eapd_switch)
  4002. stac_gpio_set(codec, spec->gpio_mask,
  4003. spec->gpio_dir, spec->gpio_data &
  4004. ~spec->eapd_mask);
  4005. } else {
  4006. /* enable speakers */
  4007. for (i = 0; i < cfg->speaker_outs; i++)
  4008. stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
  4009. AC_PINCTL_OUT_EN);
  4010. if (spec->eapd_mask && spec->eapd_switch)
  4011. stac_gpio_set(codec, spec->gpio_mask,
  4012. spec->gpio_dir, spec->gpio_data |
  4013. spec->eapd_mask);
  4014. }
  4015. }
  4016. /* return non-zero if the hp-pin of the given array index isn't
  4017. * a jack-detection target
  4018. */
  4019. static int no_hp_sensing(struct sigmatel_spec *spec, int i)
  4020. {
  4021. struct auto_pin_cfg *cfg = &spec->autocfg;
  4022. /* ignore sensing of shared line and mic jacks */
  4023. if (cfg->hp_pins[i] == spec->line_switch)
  4024. return 1;
  4025. if (cfg->hp_pins[i] == spec->mic_switch)
  4026. return 1;
  4027. /* ignore if the pin is set as line-out */
  4028. if (cfg->hp_pins[i] == spec->hp_switch)
  4029. return 1;
  4030. return 0;
  4031. }
  4032. static void stac92xx_hp_detect(struct hda_codec *codec)
  4033. {
  4034. struct sigmatel_spec *spec = codec->spec;
  4035. struct auto_pin_cfg *cfg = &spec->autocfg;
  4036. int i, presence;
  4037. presence = 0;
  4038. if (spec->gpio_mute)
  4039. presence = !(snd_hda_codec_read(codec, codec->afg, 0,
  4040. AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
  4041. for (i = 0; i < cfg->hp_outs; i++) {
  4042. if (presence)
  4043. break;
  4044. if (no_hp_sensing(spec, i))
  4045. continue;
  4046. presence = get_pin_presence(codec, cfg->hp_pins[i]);
  4047. if (presence) {
  4048. unsigned int pinctl;
  4049. pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
  4050. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  4051. if (pinctl & AC_PINCTL_IN_EN)
  4052. presence = 0; /* mic- or line-input */
  4053. }
  4054. }
  4055. if (presence) {
  4056. /* disable lineouts */
  4057. if (spec->hp_switch)
  4058. stac92xx_reset_pinctl(codec, spec->hp_switch,
  4059. AC_PINCTL_OUT_EN);
  4060. for (i = 0; i < cfg->line_outs; i++)
  4061. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  4062. AC_PINCTL_OUT_EN);
  4063. } else {
  4064. /* enable lineouts */
  4065. if (spec->hp_switch)
  4066. stac92xx_set_pinctl(codec, spec->hp_switch,
  4067. AC_PINCTL_OUT_EN);
  4068. for (i = 0; i < cfg->line_outs; i++)
  4069. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  4070. AC_PINCTL_OUT_EN);
  4071. }
  4072. stac92xx_line_out_detect(codec, presence);
  4073. /* toggle hp outs */
  4074. for (i = 0; i < cfg->hp_outs; i++) {
  4075. unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
  4076. if (no_hp_sensing(spec, i))
  4077. continue;
  4078. if (1 /*presence*/)
  4079. stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
  4080. #if 0 /* FIXME */
  4081. /* Resetting the pinctl like below may lead to (a sort of) regressions
  4082. * on some devices since they use the HP pin actually for line/speaker
  4083. * outs although the default pin config shows a different pin (that is
  4084. * wrong and useless).
  4085. *
  4086. * So, it's basically a problem of default pin configs, likely a BIOS issue.
  4087. * But, disabling the code below just works around it, and I'm too tired of
  4088. * bug reports with such devices...
  4089. */
  4090. else
  4091. stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
  4092. #endif /* FIXME */
  4093. }
  4094. }
  4095. static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
  4096. int enable)
  4097. {
  4098. struct sigmatel_spec *spec = codec->spec;
  4099. unsigned int idx, val;
  4100. for (idx = 0; idx < spec->num_pwrs; idx++) {
  4101. if (spec->pwr_nids[idx] == nid)
  4102. break;
  4103. }
  4104. if (idx >= spec->num_pwrs)
  4105. return;
  4106. idx = 1 << idx;
  4107. val = spec->power_map_bits;
  4108. if (enable)
  4109. val &= ~idx;
  4110. else
  4111. val |= idx;
  4112. /* power down unused output ports */
  4113. if (val != spec->power_map_bits) {
  4114. spec->power_map_bits = val;
  4115. snd_hda_codec_write(codec, codec->afg, 0,
  4116. AC_VERB_IDT_SET_POWER_MAP, val);
  4117. }
  4118. }
  4119. static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
  4120. {
  4121. stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
  4122. }
  4123. /* get the pin connection (fixed, none, etc) */
  4124. static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
  4125. {
  4126. struct sigmatel_spec *spec = codec->spec;
  4127. unsigned int cfg;
  4128. cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
  4129. return get_defcfg_connect(cfg);
  4130. }
  4131. static int stac92xx_connected_ports(struct hda_codec *codec,
  4132. const hda_nid_t *nids, int num_nids)
  4133. {
  4134. struct sigmatel_spec *spec = codec->spec;
  4135. int idx, num;
  4136. unsigned int def_conf;
  4137. for (num = 0; num < num_nids; num++) {
  4138. for (idx = 0; idx < spec->num_pins; idx++)
  4139. if (spec->pin_nids[idx] == nids[num])
  4140. break;
  4141. if (idx >= spec->num_pins)
  4142. break;
  4143. def_conf = stac_get_defcfg_connect(codec, idx);
  4144. if (def_conf == AC_JACK_PORT_NONE)
  4145. break;
  4146. }
  4147. return num;
  4148. }
  4149. static void stac92xx_mic_detect(struct hda_codec *codec)
  4150. {
  4151. struct sigmatel_spec *spec = codec->spec;
  4152. struct sigmatel_mic_route *mic;
  4153. if (get_pin_presence(codec, spec->ext_mic.pin))
  4154. mic = &spec->ext_mic;
  4155. else if (get_pin_presence(codec, spec->dock_mic.pin))
  4156. mic = &spec->dock_mic;
  4157. else
  4158. mic = &spec->int_mic;
  4159. if (mic->dmux_idx >= 0)
  4160. snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
  4161. AC_VERB_SET_CONNECT_SEL,
  4162. mic->dmux_idx);
  4163. if (mic->mux_idx >= 0)
  4164. snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
  4165. AC_VERB_SET_CONNECT_SEL,
  4166. mic->mux_idx);
  4167. }
  4168. static void handle_unsol_event(struct hda_codec *codec,
  4169. struct hda_jack_tbl *event)
  4170. {
  4171. struct sigmatel_spec *spec = codec->spec;
  4172. int data;
  4173. switch (event->action) {
  4174. case STAC_HP_EVENT:
  4175. case STAC_LO_EVENT:
  4176. stac92xx_hp_detect(codec);
  4177. break;
  4178. case STAC_MIC_EVENT:
  4179. stac92xx_mic_detect(codec);
  4180. break;
  4181. }
  4182. switch (event->action) {
  4183. case STAC_HP_EVENT:
  4184. case STAC_LO_EVENT:
  4185. case STAC_MIC_EVENT:
  4186. case STAC_INSERT_EVENT:
  4187. case STAC_PWR_EVENT:
  4188. if (spec->num_pwrs > 0)
  4189. stac92xx_pin_sense(codec, event->nid);
  4190. switch (codec->subsystem_id) {
  4191. case 0x103c308f:
  4192. if (event->nid == 0xb) {
  4193. int pin = AC_PINCTL_IN_EN;
  4194. if (get_pin_presence(codec, 0xa)
  4195. && get_pin_presence(codec, 0xb))
  4196. pin |= AC_PINCTL_VREF_80;
  4197. if (!get_pin_presence(codec, 0xb))
  4198. pin |= AC_PINCTL_VREF_80;
  4199. /* toggle VREF state based on mic + hp pin
  4200. * status
  4201. */
  4202. stac92xx_auto_set_pinctl(codec, 0x0a, pin);
  4203. }
  4204. }
  4205. break;
  4206. case STAC_VREF_EVENT:
  4207. data = snd_hda_codec_read(codec, codec->afg, 0,
  4208. AC_VERB_GET_GPIO_DATA, 0);
  4209. /* toggle VREF state based on GPIOx status */
  4210. snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
  4211. !!(data & (1 << event->private_data)));
  4212. break;
  4213. }
  4214. }
  4215. static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
  4216. {
  4217. struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
  4218. if (!event)
  4219. return;
  4220. handle_unsol_event(codec, event);
  4221. }
  4222. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  4223. {
  4224. struct hda_jack_tbl *event;
  4225. int tag;
  4226. tag = (res >> 26) & 0x7f;
  4227. event = snd_hda_jack_tbl_get_from_tag(codec, tag);
  4228. if (!event)
  4229. return;
  4230. event->jack_dirty = 1;
  4231. handle_unsol_event(codec, event);
  4232. snd_hda_jack_report_sync(codec);
  4233. }
  4234. static int hp_blike_system(u32 subsystem_id);
  4235. static void set_hp_led_gpio(struct hda_codec *codec)
  4236. {
  4237. struct sigmatel_spec *spec = codec->spec;
  4238. unsigned int gpio;
  4239. if (spec->gpio_led)
  4240. return;
  4241. gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  4242. gpio &= AC_GPIO_IO_COUNT;
  4243. if (gpio > 3)
  4244. spec->gpio_led = 0x08; /* GPIO 3 */
  4245. else
  4246. spec->gpio_led = 0x01; /* GPIO 0 */
  4247. }
  4248. /*
  4249. * This method searches for the mute LED GPIO configuration
  4250. * provided as OEM string in SMBIOS. The format of that string
  4251. * is HP_Mute_LED_P_G or HP_Mute_LED_P
  4252. * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
  4253. * that corresponds to the NOT muted state of the master volume
  4254. * and G is the index of the GPIO to use as the mute LED control (0..9)
  4255. * If _G portion is missing it is assigned based on the codec ID
  4256. *
  4257. * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
  4258. * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
  4259. *
  4260. *
  4261. * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
  4262. * SMBIOS - at least the ones I have seen do not have them - which include
  4263. * my own system (HP Pavilion dv6-1110ax) and my cousin's
  4264. * HP Pavilion dv9500t CTO.
  4265. * Need more information on whether it is true across the entire series.
  4266. * -- kunal
  4267. */
  4268. static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
  4269. {
  4270. struct sigmatel_spec *spec = codec->spec;
  4271. const struct dmi_device *dev = NULL;
  4272. if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
  4273. get_int_hint(codec, "gpio_led_polarity",
  4274. &spec->gpio_led_polarity);
  4275. return 1;
  4276. }
  4277. if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
  4278. while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
  4279. NULL, dev))) {
  4280. if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
  4281. &spec->gpio_led_polarity,
  4282. &spec->gpio_led) == 2) {
  4283. unsigned int max_gpio;
  4284. max_gpio = snd_hda_param_read(codec, codec->afg,
  4285. AC_PAR_GPIO_CAP);
  4286. max_gpio &= AC_GPIO_IO_COUNT;
  4287. if (spec->gpio_led < max_gpio)
  4288. spec->gpio_led = 1 << spec->gpio_led;
  4289. else
  4290. spec->vref_mute_led_nid = spec->gpio_led;
  4291. return 1;
  4292. }
  4293. if (sscanf(dev->name, "HP_Mute_LED_%d",
  4294. &spec->gpio_led_polarity) == 1) {
  4295. set_hp_led_gpio(codec);
  4296. return 1;
  4297. }
  4298. /* BIOS bug: unfilled OEM string */
  4299. if (strstr(dev->name, "HP_Mute_LED_P_G")) {
  4300. set_hp_led_gpio(codec);
  4301. switch (codec->subsystem_id) {
  4302. case 0x103c148a:
  4303. spec->gpio_led_polarity = 0;
  4304. break;
  4305. default:
  4306. spec->gpio_led_polarity = 1;
  4307. break;
  4308. }
  4309. return 1;
  4310. }
  4311. }
  4312. /*
  4313. * Fallback case - if we don't find the DMI strings,
  4314. * we statically set the GPIO - if not a B-series system
  4315. * and default polarity is provided
  4316. */
  4317. if (!hp_blike_system(codec->subsystem_id) &&
  4318. (default_polarity == 0 || default_polarity == 1)) {
  4319. set_hp_led_gpio(codec);
  4320. spec->gpio_led_polarity = default_polarity;
  4321. return 1;
  4322. }
  4323. }
  4324. return 0;
  4325. }
  4326. static int hp_blike_system(u32 subsystem_id)
  4327. {
  4328. switch (subsystem_id) {
  4329. case 0x103c1520:
  4330. case 0x103c1521:
  4331. case 0x103c1523:
  4332. case 0x103c1524:
  4333. case 0x103c1525:
  4334. case 0x103c1722:
  4335. case 0x103c1723:
  4336. case 0x103c1724:
  4337. case 0x103c1725:
  4338. case 0x103c1726:
  4339. case 0x103c1727:
  4340. case 0x103c1728:
  4341. case 0x103c1729:
  4342. case 0x103c172a:
  4343. case 0x103c172b:
  4344. case 0x103c307e:
  4345. case 0x103c307f:
  4346. case 0x103c3080:
  4347. case 0x103c3081:
  4348. case 0x103c7007:
  4349. case 0x103c7008:
  4350. return 1;
  4351. }
  4352. return 0;
  4353. }
  4354. #ifdef CONFIG_PROC_FS
  4355. static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
  4356. struct hda_codec *codec, hda_nid_t nid)
  4357. {
  4358. if (nid == codec->afg)
  4359. snd_iprintf(buffer, "Power-Map: 0x%02x\n",
  4360. snd_hda_codec_read(codec, nid, 0,
  4361. AC_VERB_IDT_GET_POWER_MAP, 0));
  4362. }
  4363. static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
  4364. struct hda_codec *codec,
  4365. unsigned int verb)
  4366. {
  4367. snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
  4368. snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
  4369. }
  4370. /* stac92hd71bxx, stac92hd73xx */
  4371. static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
  4372. struct hda_codec *codec, hda_nid_t nid)
  4373. {
  4374. stac92hd_proc_hook(buffer, codec, nid);
  4375. if (nid == codec->afg)
  4376. analog_loop_proc_hook(buffer, codec, 0xfa0);
  4377. }
  4378. static void stac9205_proc_hook(struct snd_info_buffer *buffer,
  4379. struct hda_codec *codec, hda_nid_t nid)
  4380. {
  4381. if (nid == codec->afg)
  4382. analog_loop_proc_hook(buffer, codec, 0xfe0);
  4383. }
  4384. static void stac927x_proc_hook(struct snd_info_buffer *buffer,
  4385. struct hda_codec *codec, hda_nid_t nid)
  4386. {
  4387. if (nid == codec->afg)
  4388. analog_loop_proc_hook(buffer, codec, 0xfeb);
  4389. }
  4390. #else
  4391. #define stac92hd_proc_hook NULL
  4392. #define stac92hd7x_proc_hook NULL
  4393. #define stac9205_proc_hook NULL
  4394. #define stac927x_proc_hook NULL
  4395. #endif
  4396. #ifdef CONFIG_PM
  4397. static int stac92xx_resume(struct hda_codec *codec)
  4398. {
  4399. stac92xx_init(codec);
  4400. snd_hda_codec_resume_amp(codec);
  4401. snd_hda_codec_resume_cache(codec);
  4402. /* fake event to set up pins again to override cached values */
  4403. stac_fake_hp_events(codec);
  4404. return 0;
  4405. }
  4406. static int stac92xx_suspend(struct hda_codec *codec)
  4407. {
  4408. stac92xx_shutup(codec);
  4409. return 0;
  4410. }
  4411. static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
  4412. unsigned int power_state)
  4413. {
  4414. unsigned int afg_power_state = power_state;
  4415. struct sigmatel_spec *spec = codec->spec;
  4416. if (power_state == AC_PWRST_D3) {
  4417. if (spec->vref_mute_led_nid) {
  4418. /* with vref-out pin used for mute led control
  4419. * codec AFG is prevented from D3 state
  4420. */
  4421. afg_power_state = AC_PWRST_D1;
  4422. }
  4423. /* this delay seems necessary to avoid click noise at power-down */
  4424. msleep(100);
  4425. }
  4426. snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
  4427. afg_power_state);
  4428. snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
  4429. }
  4430. #else
  4431. #define stac92xx_suspend NULL
  4432. #define stac92xx_resume NULL
  4433. #define stac92xx_set_power_state NULL
  4434. #endif /* CONFIG_PM */
  4435. /* update mute-LED accoring to the master switch */
  4436. static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
  4437. {
  4438. struct sigmatel_spec *spec = codec->spec;
  4439. int muted = !enabled;
  4440. if (!spec->gpio_led)
  4441. return;
  4442. /* LED state is inverted on these systems */
  4443. if (spec->gpio_led_polarity)
  4444. muted = !muted;
  4445. if (!spec->vref_mute_led_nid) {
  4446. if (muted)
  4447. spec->gpio_data |= spec->gpio_led;
  4448. else
  4449. spec->gpio_data &= ~spec->gpio_led;
  4450. stac_gpio_set(codec, spec->gpio_mask,
  4451. spec->gpio_dir, spec->gpio_data);
  4452. } else {
  4453. spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
  4454. stac_vrefout_set(codec, spec->vref_mute_led_nid,
  4455. spec->vref_led);
  4456. }
  4457. }
  4458. static const struct hda_codec_ops stac92xx_patch_ops = {
  4459. .build_controls = stac92xx_build_controls,
  4460. .build_pcms = stac92xx_build_pcms,
  4461. .init = stac92xx_init,
  4462. .free = stac92xx_free,
  4463. .unsol_event = stac92xx_unsol_event,
  4464. #ifdef CONFIG_PM
  4465. .suspend = stac92xx_suspend,
  4466. .resume = stac92xx_resume,
  4467. #endif
  4468. .reboot_notify = stac92xx_shutup,
  4469. };
  4470. static int patch_stac9200(struct hda_codec *codec)
  4471. {
  4472. struct sigmatel_spec *spec;
  4473. int err;
  4474. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4475. if (spec == NULL)
  4476. return -ENOMEM;
  4477. codec->no_trigger_sense = 1;
  4478. codec->spec = spec;
  4479. spec->linear_tone_beep = 1;
  4480. spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
  4481. spec->pin_nids = stac9200_pin_nids;
  4482. spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
  4483. stac9200_models,
  4484. stac9200_cfg_tbl);
  4485. if (spec->board_config < 0)
  4486. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4487. codec->chip_name);
  4488. else
  4489. stac92xx_set_config_regs(codec,
  4490. stac9200_brd_tbl[spec->board_config]);
  4491. spec->multiout.max_channels = 2;
  4492. spec->multiout.num_dacs = 1;
  4493. spec->multiout.dac_nids = stac9200_dac_nids;
  4494. spec->adc_nids = stac9200_adc_nids;
  4495. spec->mux_nids = stac9200_mux_nids;
  4496. spec->num_muxes = 1;
  4497. spec->num_dmics = 0;
  4498. spec->num_adcs = 1;
  4499. spec->num_pwrs = 0;
  4500. if (spec->board_config == STAC_9200_M4 ||
  4501. spec->board_config == STAC_9200_M4_2 ||
  4502. spec->board_config == STAC_9200_OQO)
  4503. spec->init = stac9200_eapd_init;
  4504. else
  4505. spec->init = stac9200_core_init;
  4506. spec->mixer = stac9200_mixer;
  4507. if (spec->board_config == STAC_9200_PANASONIC) {
  4508. spec->gpio_mask = spec->gpio_dir = 0x09;
  4509. spec->gpio_data = 0x00;
  4510. }
  4511. err = stac9200_parse_auto_config(codec);
  4512. if (err < 0) {
  4513. stac92xx_free(codec);
  4514. return err;
  4515. }
  4516. /* CF-74 has no headphone detection, and the driver should *NOT*
  4517. * do detection and HP/speaker toggle because the hardware does it.
  4518. */
  4519. if (spec->board_config == STAC_9200_PANASONIC)
  4520. spec->hp_detect = 0;
  4521. codec->patch_ops = stac92xx_patch_ops;
  4522. return 0;
  4523. }
  4524. static int patch_stac925x(struct hda_codec *codec)
  4525. {
  4526. struct sigmatel_spec *spec;
  4527. int err;
  4528. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4529. if (spec == NULL)
  4530. return -ENOMEM;
  4531. codec->no_trigger_sense = 1;
  4532. codec->spec = spec;
  4533. spec->linear_tone_beep = 1;
  4534. spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
  4535. spec->pin_nids = stac925x_pin_nids;
  4536. /* Check first for codec ID */
  4537. spec->board_config = snd_hda_check_board_codec_sid_config(codec,
  4538. STAC_925x_MODELS,
  4539. stac925x_models,
  4540. stac925x_codec_id_cfg_tbl);
  4541. /* Now checks for PCI ID, if codec ID is not found */
  4542. if (spec->board_config < 0)
  4543. spec->board_config = snd_hda_check_board_config(codec,
  4544. STAC_925x_MODELS,
  4545. stac925x_models,
  4546. stac925x_cfg_tbl);
  4547. again:
  4548. if (spec->board_config < 0)
  4549. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4550. codec->chip_name);
  4551. else
  4552. stac92xx_set_config_regs(codec,
  4553. stac925x_brd_tbl[spec->board_config]);
  4554. spec->multiout.max_channels = 2;
  4555. spec->multiout.num_dacs = 1;
  4556. spec->multiout.dac_nids = stac925x_dac_nids;
  4557. spec->adc_nids = stac925x_adc_nids;
  4558. spec->mux_nids = stac925x_mux_nids;
  4559. spec->num_muxes = 1;
  4560. spec->num_adcs = 1;
  4561. spec->num_pwrs = 0;
  4562. switch (codec->vendor_id) {
  4563. case 0x83847632: /* STAC9202 */
  4564. case 0x83847633: /* STAC9202D */
  4565. case 0x83847636: /* STAC9251 */
  4566. case 0x83847637: /* STAC9251D */
  4567. spec->num_dmics = STAC925X_NUM_DMICS;
  4568. spec->dmic_nids = stac925x_dmic_nids;
  4569. spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
  4570. spec->dmux_nids = stac925x_dmux_nids;
  4571. break;
  4572. default:
  4573. spec->num_dmics = 0;
  4574. break;
  4575. }
  4576. spec->init = stac925x_core_init;
  4577. spec->mixer = stac925x_mixer;
  4578. spec->num_caps = 1;
  4579. spec->capvols = stac925x_capvols;
  4580. spec->capsws = stac925x_capsws;
  4581. err = stac92xx_parse_auto_config(codec);
  4582. if (!err) {
  4583. if (spec->board_config < 0) {
  4584. printk(KERN_WARNING "hda_codec: No auto-config is "
  4585. "available, default to model=ref\n");
  4586. spec->board_config = STAC_925x_REF;
  4587. goto again;
  4588. }
  4589. err = -EINVAL;
  4590. }
  4591. if (err < 0) {
  4592. stac92xx_free(codec);
  4593. return err;
  4594. }
  4595. codec->patch_ops = stac92xx_patch_ops;
  4596. return 0;
  4597. }
  4598. static int patch_stac92hd73xx(struct hda_codec *codec)
  4599. {
  4600. struct sigmatel_spec *spec;
  4601. hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
  4602. int err = 0;
  4603. int num_dacs;
  4604. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4605. if (spec == NULL)
  4606. return -ENOMEM;
  4607. codec->no_trigger_sense = 1;
  4608. codec->spec = spec;
  4609. spec->linear_tone_beep = 0;
  4610. codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
  4611. spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
  4612. spec->pin_nids = stac92hd73xx_pin_nids;
  4613. spec->board_config = snd_hda_check_board_config(codec,
  4614. STAC_92HD73XX_MODELS,
  4615. stac92hd73xx_models,
  4616. stac92hd73xx_cfg_tbl);
  4617. /* check codec subsystem id if not found */
  4618. if (spec->board_config < 0)
  4619. spec->board_config =
  4620. snd_hda_check_board_codec_sid_config(codec,
  4621. STAC_92HD73XX_MODELS, stac92hd73xx_models,
  4622. stac92hd73xx_codec_id_cfg_tbl);
  4623. again:
  4624. if (spec->board_config < 0)
  4625. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4626. codec->chip_name);
  4627. else
  4628. stac92xx_set_config_regs(codec,
  4629. stac92hd73xx_brd_tbl[spec->board_config]);
  4630. num_dacs = snd_hda_get_connections(codec, 0x0a,
  4631. conn, STAC92HD73_DAC_COUNT + 2) - 1;
  4632. if (num_dacs < 3 || num_dacs > 5) {
  4633. printk(KERN_WARNING "hda_codec: Could not determine "
  4634. "number of channels defaulting to DAC count\n");
  4635. num_dacs = STAC92HD73_DAC_COUNT;
  4636. }
  4637. spec->init = stac92hd73xx_core_init;
  4638. switch (num_dacs) {
  4639. case 0x3: /* 6 Channel */
  4640. spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
  4641. break;
  4642. case 0x4: /* 8 Channel */
  4643. spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
  4644. break;
  4645. case 0x5: /* 10 Channel */
  4646. spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
  4647. break;
  4648. }
  4649. spec->multiout.dac_nids = spec->dac_nids;
  4650. spec->aloopback_mask = 0x01;
  4651. spec->aloopback_shift = 8;
  4652. spec->digbeep_nid = 0x1c;
  4653. spec->mux_nids = stac92hd73xx_mux_nids;
  4654. spec->adc_nids = stac92hd73xx_adc_nids;
  4655. spec->dmic_nids = stac92hd73xx_dmic_nids;
  4656. spec->dmux_nids = stac92hd73xx_dmux_nids;
  4657. spec->smux_nids = stac92hd73xx_smux_nids;
  4658. spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
  4659. spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
  4660. spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
  4661. spec->num_caps = STAC92HD73XX_NUM_CAPS;
  4662. spec->capvols = stac92hd73xx_capvols;
  4663. spec->capsws = stac92hd73xx_capsws;
  4664. switch (spec->board_config) {
  4665. case STAC_DELL_EQ:
  4666. spec->init = dell_eq_core_init;
  4667. /* fallthru */
  4668. case STAC_DELL_M6_AMIC:
  4669. case STAC_DELL_M6_DMIC:
  4670. case STAC_DELL_M6_BOTH:
  4671. spec->num_smuxes = 0;
  4672. spec->eapd_switch = 0;
  4673. switch (spec->board_config) {
  4674. case STAC_DELL_M6_AMIC: /* Analog Mics */
  4675. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  4676. spec->num_dmics = 0;
  4677. break;
  4678. case STAC_DELL_M6_DMIC: /* Digital Mics */
  4679. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  4680. spec->num_dmics = 1;
  4681. break;
  4682. case STAC_DELL_M6_BOTH: /* Both */
  4683. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  4684. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  4685. spec->num_dmics = 1;
  4686. break;
  4687. }
  4688. break;
  4689. case STAC_ALIENWARE_M17X:
  4690. spec->num_dmics = STAC92HD73XX_NUM_DMICS;
  4691. spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
  4692. spec->eapd_switch = 0;
  4693. break;
  4694. default:
  4695. spec->num_dmics = STAC92HD73XX_NUM_DMICS;
  4696. spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
  4697. spec->eapd_switch = 1;
  4698. break;
  4699. }
  4700. if (spec->board_config != STAC_92HD73XX_REF) {
  4701. /* GPIO0 High = Enable EAPD */
  4702. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  4703. spec->gpio_data = 0x01;
  4704. }
  4705. spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
  4706. spec->pwr_nids = stac92hd73xx_pwr_nids;
  4707. err = stac92xx_parse_auto_config(codec);
  4708. if (!err) {
  4709. if (spec->board_config < 0) {
  4710. printk(KERN_WARNING "hda_codec: No auto-config is "
  4711. "available, default to model=ref\n");
  4712. spec->board_config = STAC_92HD73XX_REF;
  4713. goto again;
  4714. }
  4715. err = -EINVAL;
  4716. }
  4717. if (err < 0) {
  4718. stac92xx_free(codec);
  4719. return err;
  4720. }
  4721. if (spec->board_config == STAC_92HD73XX_NO_JD)
  4722. spec->hp_detect = 0;
  4723. codec->patch_ops = stac92xx_patch_ops;
  4724. codec->proc_widget_hook = stac92hd7x_proc_hook;
  4725. return 0;
  4726. }
  4727. static int hp_bnb2011_with_dock(struct hda_codec *codec)
  4728. {
  4729. if (codec->vendor_id != 0x111d7605 &&
  4730. codec->vendor_id != 0x111d76d1)
  4731. return 0;
  4732. switch (codec->subsystem_id) {
  4733. case 0x103c1618:
  4734. case 0x103c1619:
  4735. case 0x103c161a:
  4736. case 0x103c161b:
  4737. case 0x103c161c:
  4738. case 0x103c161d:
  4739. case 0x103c161e:
  4740. case 0x103c161f:
  4741. case 0x103c162a:
  4742. case 0x103c162b:
  4743. case 0x103c1630:
  4744. case 0x103c1631:
  4745. case 0x103c1633:
  4746. case 0x103c1634:
  4747. case 0x103c1635:
  4748. case 0x103c3587:
  4749. case 0x103c3588:
  4750. case 0x103c3589:
  4751. case 0x103c358a:
  4752. case 0x103c3667:
  4753. case 0x103c3668:
  4754. case 0x103c3669:
  4755. return 1;
  4756. }
  4757. return 0;
  4758. }
  4759. static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
  4760. {
  4761. struct sigmatel_spec *spec = codec->spec;
  4762. unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
  4763. int i;
  4764. spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
  4765. spec->auto_pin_cnt++;
  4766. if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
  4767. get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
  4768. for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
  4769. if (nid == stac92hd83xxx_dmic_nids[i]) {
  4770. spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
  4771. spec->auto_dmic_cnt++;
  4772. }
  4773. }
  4774. }
  4775. }
  4776. static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
  4777. {
  4778. struct sigmatel_spec *spec = codec->spec;
  4779. spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
  4780. spec->auto_adc_cnt++;
  4781. }
  4782. static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
  4783. {
  4784. int i, j;
  4785. struct sigmatel_spec *spec = codec->spec;
  4786. for (i = 0; i < spec->auto_adc_cnt; i++) {
  4787. if (get_connection_index(codec,
  4788. spec->auto_adc_nids[i], nid) >= 0) {
  4789. /* mux and volume for adc_nids[i] */
  4790. if (!spec->auto_mux_nids[i]) {
  4791. spec->auto_mux_nids[i] = nid;
  4792. /* 92hd codecs capture volume is in mux */
  4793. spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
  4794. 3, 0, HDA_OUTPUT);
  4795. }
  4796. for (j = 0; j < spec->auto_dmic_cnt; j++) {
  4797. if (get_connection_index(codec, nid,
  4798. spec->auto_dmic_nids[j]) >= 0) {
  4799. /* dmux for adc_nids[i] */
  4800. if (!spec->auto_dmux_nids[i])
  4801. spec->auto_dmux_nids[i] = nid;
  4802. break;
  4803. }
  4804. }
  4805. break;
  4806. }
  4807. }
  4808. }
  4809. static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
  4810. {
  4811. hda_nid_t nid, end_nid;
  4812. unsigned int wid_caps, wid_type;
  4813. struct sigmatel_spec *spec = codec->spec;
  4814. end_nid = codec->start_nid + codec->num_nodes;
  4815. for (nid = codec->start_nid; nid < end_nid; nid++) {
  4816. wid_caps = get_wcaps(codec, nid);
  4817. wid_type = get_wcaps_type(wid_caps);
  4818. if (wid_type == AC_WID_PIN)
  4819. stac92hd8x_add_pin(codec, nid);
  4820. if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
  4821. stac92hd8x_add_adc(codec, nid);
  4822. }
  4823. for (nid = codec->start_nid; nid < end_nid; nid++) {
  4824. wid_caps = get_wcaps(codec, nid);
  4825. wid_type = get_wcaps_type(wid_caps);
  4826. if (wid_type == AC_WID_AUD_SEL)
  4827. stac92hd8x_add_mux(codec, nid);
  4828. }
  4829. spec->pin_nids = spec->auto_pin_nids;
  4830. spec->num_pins = spec->auto_pin_cnt;
  4831. spec->adc_nids = spec->auto_adc_nids;
  4832. spec->num_adcs = spec->auto_adc_cnt;
  4833. spec->capvols = spec->auto_capvols;
  4834. spec->capsws = spec->auto_capvols;
  4835. spec->num_caps = spec->auto_adc_cnt;
  4836. spec->mux_nids = spec->auto_mux_nids;
  4837. spec->num_muxes = spec->auto_adc_cnt;
  4838. spec->dmux_nids = spec->auto_dmux_nids;
  4839. spec->num_dmuxes = spec->auto_adc_cnt;
  4840. spec->dmic_nids = spec->auto_dmic_nids;
  4841. spec->num_dmics = spec->auto_dmic_cnt;
  4842. }
  4843. static int patch_stac92hd83xxx(struct hda_codec *codec)
  4844. {
  4845. struct sigmatel_spec *spec;
  4846. int err;
  4847. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4848. if (spec == NULL)
  4849. return -ENOMEM;
  4850. if (hp_bnb2011_with_dock(codec)) {
  4851. snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
  4852. snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
  4853. }
  4854. codec->no_trigger_sense = 1;
  4855. codec->spec = spec;
  4856. stac92hd8x_fill_auto_spec(codec);
  4857. spec->linear_tone_beep = 0;
  4858. codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
  4859. spec->digbeep_nid = 0x21;
  4860. spec->pwr_nids = stac92hd83xxx_pwr_nids;
  4861. spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
  4862. spec->multiout.dac_nids = spec->dac_nids;
  4863. spec->init = stac92hd83xxx_core_init;
  4864. spec->board_config = snd_hda_check_board_config(codec,
  4865. STAC_92HD83XXX_MODELS,
  4866. stac92hd83xxx_models,
  4867. stac92hd83xxx_cfg_tbl);
  4868. /* check codec subsystem id if not found */
  4869. if (spec->board_config < 0)
  4870. spec->board_config =
  4871. snd_hda_check_board_codec_sid_config(codec,
  4872. STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
  4873. stac92hd83xxx_codec_id_cfg_tbl);
  4874. again:
  4875. if (spec->board_config < 0)
  4876. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4877. codec->chip_name);
  4878. else
  4879. stac92xx_set_config_regs(codec,
  4880. stac92hd83xxx_brd_tbl[spec->board_config]);
  4881. codec->patch_ops = stac92xx_patch_ops;
  4882. switch (spec->board_config) {
  4883. case STAC_HP_ZEPHYR:
  4884. spec->init = stac92hd83xxx_hp_zephyr_init;
  4885. break;
  4886. }
  4887. if (find_mute_led_cfg(codec, -1/*no default cfg*/))
  4888. snd_printd("mute LED gpio %d polarity %d\n",
  4889. spec->gpio_led,
  4890. spec->gpio_led_polarity);
  4891. if (spec->gpio_led) {
  4892. if (!spec->vref_mute_led_nid) {
  4893. spec->gpio_mask |= spec->gpio_led;
  4894. spec->gpio_dir |= spec->gpio_led;
  4895. spec->gpio_data |= spec->gpio_led;
  4896. } else {
  4897. codec->patch_ops.set_power_state =
  4898. stac92xx_set_power_state;
  4899. }
  4900. }
  4901. err = stac92xx_parse_auto_config(codec);
  4902. if (!err) {
  4903. if (spec->board_config < 0) {
  4904. printk(KERN_WARNING "hda_codec: No auto-config is "
  4905. "available, default to model=ref\n");
  4906. spec->board_config = STAC_92HD83XXX_REF;
  4907. goto again;
  4908. }
  4909. err = -EINVAL;
  4910. }
  4911. if (err < 0) {
  4912. stac92xx_free(codec);
  4913. return err;
  4914. }
  4915. codec->proc_widget_hook = stac92hd_proc_hook;
  4916. return 0;
  4917. }
  4918. static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
  4919. hda_nid_t dig0pin)
  4920. {
  4921. struct sigmatel_spec *spec = codec->spec;
  4922. int idx;
  4923. for (idx = 0; idx < spec->num_pins; idx++)
  4924. if (spec->pin_nids[idx] == dig0pin)
  4925. break;
  4926. if ((idx + 2) >= spec->num_pins)
  4927. return 0;
  4928. /* dig1pin case */
  4929. if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
  4930. return 2;
  4931. /* dig0pin + dig2pin case */
  4932. if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
  4933. return 2;
  4934. if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
  4935. return 1;
  4936. else
  4937. return 0;
  4938. }
  4939. /* HP dv7 bass switch - GPIO5 */
  4940. #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
  4941. static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
  4942. struct snd_ctl_elem_value *ucontrol)
  4943. {
  4944. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4945. struct sigmatel_spec *spec = codec->spec;
  4946. ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
  4947. return 0;
  4948. }
  4949. static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
  4950. struct snd_ctl_elem_value *ucontrol)
  4951. {
  4952. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4953. struct sigmatel_spec *spec = codec->spec;
  4954. unsigned int gpio_data;
  4955. gpio_data = (spec->gpio_data & ~0x20) |
  4956. (ucontrol->value.integer.value[0] ? 0x20 : 0);
  4957. if (gpio_data == spec->gpio_data)
  4958. return 0;
  4959. spec->gpio_data = gpio_data;
  4960. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
  4961. return 1;
  4962. }
  4963. static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
  4964. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4965. .info = stac_hp_bass_gpio_info,
  4966. .get = stac_hp_bass_gpio_get,
  4967. .put = stac_hp_bass_gpio_put,
  4968. };
  4969. static int stac_add_hp_bass_switch(struct hda_codec *codec)
  4970. {
  4971. struct sigmatel_spec *spec = codec->spec;
  4972. if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
  4973. "Bass Speaker Playback Switch", 0))
  4974. return -ENOMEM;
  4975. spec->gpio_mask |= 0x20;
  4976. spec->gpio_dir |= 0x20;
  4977. spec->gpio_data |= 0x20;
  4978. return 0;
  4979. }
  4980. static int patch_stac92hd71bxx(struct hda_codec *codec)
  4981. {
  4982. struct sigmatel_spec *spec;
  4983. const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
  4984. unsigned int pin_cfg;
  4985. int err = 0;
  4986. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4987. if (spec == NULL)
  4988. return -ENOMEM;
  4989. codec->no_trigger_sense = 1;
  4990. codec->spec = spec;
  4991. spec->linear_tone_beep = 0;
  4992. codec->patch_ops = stac92xx_patch_ops;
  4993. spec->num_pins = STAC92HD71BXX_NUM_PINS;
  4994. switch (codec->vendor_id) {
  4995. case 0x111d76b6:
  4996. case 0x111d76b7:
  4997. spec->pin_nids = stac92hd71bxx_pin_nids_4port;
  4998. break;
  4999. case 0x111d7603:
  5000. case 0x111d7608:
  5001. /* On 92HD75Bx 0x27 isn't a pin nid */
  5002. spec->num_pins--;
  5003. /* fallthrough */
  5004. default:
  5005. spec->pin_nids = stac92hd71bxx_pin_nids_6port;
  5006. }
  5007. spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
  5008. spec->board_config = snd_hda_check_board_config(codec,
  5009. STAC_92HD71BXX_MODELS,
  5010. stac92hd71bxx_models,
  5011. stac92hd71bxx_cfg_tbl);
  5012. again:
  5013. if (spec->board_config < 0)
  5014. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5015. codec->chip_name);
  5016. else
  5017. stac92xx_set_config_regs(codec,
  5018. stac92hd71bxx_brd_tbl[spec->board_config]);
  5019. if (spec->board_config != STAC_92HD71BXX_REF) {
  5020. /* GPIO0 = EAPD */
  5021. spec->gpio_mask = 0x01;
  5022. spec->gpio_dir = 0x01;
  5023. spec->gpio_data = 0x01;
  5024. }
  5025. spec->dmic_nids = stac92hd71bxx_dmic_nids;
  5026. spec->dmux_nids = stac92hd71bxx_dmux_nids;
  5027. spec->num_caps = STAC92HD71BXX_NUM_CAPS;
  5028. spec->capvols = stac92hd71bxx_capvols;
  5029. spec->capsws = stac92hd71bxx_capsws;
  5030. switch (codec->vendor_id) {
  5031. case 0x111d76b6: /* 4 Port without Analog Mixer */
  5032. case 0x111d76b7:
  5033. unmute_init++;
  5034. /* fallthru */
  5035. case 0x111d76b4: /* 6 Port without Analog Mixer */
  5036. case 0x111d76b5:
  5037. spec->init = stac92hd71bxx_core_init;
  5038. codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
  5039. spec->num_dmics = stac92xx_connected_ports(codec,
  5040. stac92hd71bxx_dmic_nids,
  5041. STAC92HD71BXX_NUM_DMICS);
  5042. break;
  5043. case 0x111d7608: /* 5 Port with Analog Mixer */
  5044. switch (spec->board_config) {
  5045. case STAC_HP_M4:
  5046. /* Enable VREF power saving on GPIO1 detect */
  5047. err = stac_add_event(codec, codec->afg,
  5048. STAC_VREF_EVENT, 0x02);
  5049. if (err < 0)
  5050. return err;
  5051. snd_hda_codec_write_cache(codec, codec->afg, 0,
  5052. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
  5053. snd_hda_jack_detect_enable(codec, codec->afg, 0);
  5054. spec->gpio_mask |= 0x02;
  5055. break;
  5056. }
  5057. if ((codec->revision_id & 0xf) == 0 ||
  5058. (codec->revision_id & 0xf) == 1)
  5059. spec->stream_delay = 40; /* 40 milliseconds */
  5060. /* disable VSW */
  5061. spec->init = stac92hd71bxx_core_init;
  5062. unmute_init++;
  5063. snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
  5064. snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
  5065. spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
  5066. spec->num_dmics = stac92xx_connected_ports(codec,
  5067. stac92hd71bxx_dmic_5port_nids,
  5068. STAC92HD71BXX_NUM_DMICS - 1);
  5069. break;
  5070. case 0x111d7603: /* 6 Port with Analog Mixer */
  5071. if ((codec->revision_id & 0xf) == 1)
  5072. spec->stream_delay = 40; /* 40 milliseconds */
  5073. /* fallthru */
  5074. default:
  5075. spec->init = stac92hd71bxx_core_init;
  5076. codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
  5077. spec->num_dmics = stac92xx_connected_ports(codec,
  5078. stac92hd71bxx_dmic_nids,
  5079. STAC92HD71BXX_NUM_DMICS);
  5080. break;
  5081. }
  5082. if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
  5083. snd_hda_sequence_write_cache(codec, unmute_init);
  5084. spec->aloopback_ctl = stac92hd71bxx_loopback;
  5085. spec->aloopback_mask = 0x50;
  5086. spec->aloopback_shift = 0;
  5087. spec->powerdown_adcs = 1;
  5088. spec->digbeep_nid = 0x26;
  5089. spec->mux_nids = stac92hd71bxx_mux_nids;
  5090. spec->adc_nids = stac92hd71bxx_adc_nids;
  5091. spec->smux_nids = stac92hd71bxx_smux_nids;
  5092. spec->pwr_nids = stac92hd71bxx_pwr_nids;
  5093. spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
  5094. spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
  5095. spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
  5096. spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
  5097. snd_printdd("Found board config: %d\n", spec->board_config);
  5098. switch (spec->board_config) {
  5099. case STAC_HP_M4:
  5100. /* enable internal microphone */
  5101. snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
  5102. stac92xx_auto_set_pinctl(codec, 0x0e,
  5103. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
  5104. /* fallthru */
  5105. case STAC_DELL_M4_2:
  5106. spec->num_dmics = 0;
  5107. spec->num_smuxes = 0;
  5108. spec->num_dmuxes = 0;
  5109. break;
  5110. case STAC_DELL_M4_1:
  5111. case STAC_DELL_M4_3:
  5112. spec->num_dmics = 1;
  5113. spec->num_smuxes = 0;
  5114. spec->num_dmuxes = 1;
  5115. break;
  5116. case STAC_HP_DV4_1222NR:
  5117. spec->num_dmics = 1;
  5118. /* I don't know if it needs 1 or 2 smuxes - will wait for
  5119. * bug reports to fix if needed
  5120. */
  5121. spec->num_smuxes = 1;
  5122. spec->num_dmuxes = 1;
  5123. /* fallthrough */
  5124. case STAC_HP_DV4:
  5125. spec->gpio_led = 0x01;
  5126. /* fallthrough */
  5127. case STAC_HP_DV5:
  5128. snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
  5129. stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
  5130. /* HP dv6 gives the headphone pin as a line-out. Thus we
  5131. * need to set hp_detect flag here to force to enable HP
  5132. * detection.
  5133. */
  5134. spec->hp_detect = 1;
  5135. break;
  5136. case STAC_HP_HDX:
  5137. spec->num_dmics = 1;
  5138. spec->num_dmuxes = 1;
  5139. spec->num_smuxes = 1;
  5140. spec->gpio_led = 0x08;
  5141. break;
  5142. }
  5143. if (hp_blike_system(codec->subsystem_id)) {
  5144. pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
  5145. if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
  5146. get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
  5147. get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
  5148. /* It was changed in the BIOS to just satisfy MS DTM.
  5149. * Lets turn it back into slaved HP
  5150. */
  5151. pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
  5152. | (AC_JACK_HP_OUT <<
  5153. AC_DEFCFG_DEVICE_SHIFT);
  5154. pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
  5155. | AC_DEFCFG_SEQUENCE)))
  5156. | 0x1f;
  5157. snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
  5158. }
  5159. }
  5160. if (find_mute_led_cfg(codec, 1))
  5161. snd_printd("mute LED gpio %d polarity %d\n",
  5162. spec->gpio_led,
  5163. spec->gpio_led_polarity);
  5164. if (spec->gpio_led) {
  5165. if (!spec->vref_mute_led_nid) {
  5166. spec->gpio_mask |= spec->gpio_led;
  5167. spec->gpio_dir |= spec->gpio_led;
  5168. spec->gpio_data |= spec->gpio_led;
  5169. } else {
  5170. codec->patch_ops.set_power_state =
  5171. stac92xx_set_power_state;
  5172. }
  5173. }
  5174. spec->multiout.dac_nids = spec->dac_nids;
  5175. err = stac92xx_parse_auto_config(codec);
  5176. if (!err) {
  5177. if (spec->board_config < 0) {
  5178. printk(KERN_WARNING "hda_codec: No auto-config is "
  5179. "available, default to model=ref\n");
  5180. spec->board_config = STAC_92HD71BXX_REF;
  5181. goto again;
  5182. }
  5183. err = -EINVAL;
  5184. }
  5185. if (err < 0) {
  5186. stac92xx_free(codec);
  5187. return err;
  5188. }
  5189. /* enable bass on HP dv7 */
  5190. if (spec->board_config == STAC_HP_DV4 ||
  5191. spec->board_config == STAC_HP_DV5) {
  5192. unsigned int cap;
  5193. cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
  5194. cap &= AC_GPIO_IO_COUNT;
  5195. if (cap >= 6)
  5196. stac_add_hp_bass_switch(codec);
  5197. }
  5198. codec->proc_widget_hook = stac92hd7x_proc_hook;
  5199. return 0;
  5200. }
  5201. static int patch_stac922x(struct hda_codec *codec)
  5202. {
  5203. struct sigmatel_spec *spec;
  5204. int err;
  5205. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5206. if (spec == NULL)
  5207. return -ENOMEM;
  5208. codec->no_trigger_sense = 1;
  5209. codec->spec = spec;
  5210. spec->linear_tone_beep = 1;
  5211. spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
  5212. spec->pin_nids = stac922x_pin_nids;
  5213. spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
  5214. stac922x_models,
  5215. stac922x_cfg_tbl);
  5216. if (spec->board_config == STAC_INTEL_MAC_AUTO) {
  5217. spec->gpio_mask = spec->gpio_dir = 0x03;
  5218. spec->gpio_data = 0x03;
  5219. /* Intel Macs have all same PCI SSID, so we need to check
  5220. * codec SSID to distinguish the exact models
  5221. */
  5222. printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
  5223. switch (codec->subsystem_id) {
  5224. case 0x106b0800:
  5225. spec->board_config = STAC_INTEL_MAC_V1;
  5226. break;
  5227. case 0x106b0600:
  5228. case 0x106b0700:
  5229. spec->board_config = STAC_INTEL_MAC_V2;
  5230. break;
  5231. case 0x106b0e00:
  5232. case 0x106b0f00:
  5233. case 0x106b1600:
  5234. case 0x106b1700:
  5235. case 0x106b0200:
  5236. case 0x106b1e00:
  5237. spec->board_config = STAC_INTEL_MAC_V3;
  5238. break;
  5239. case 0x106b1a00:
  5240. case 0x00000100:
  5241. spec->board_config = STAC_INTEL_MAC_V4;
  5242. break;
  5243. case 0x106b0a00:
  5244. case 0x106b2200:
  5245. spec->board_config = STAC_INTEL_MAC_V5;
  5246. break;
  5247. default:
  5248. spec->board_config = STAC_INTEL_MAC_V3;
  5249. break;
  5250. }
  5251. }
  5252. again:
  5253. if (spec->board_config < 0)
  5254. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5255. codec->chip_name);
  5256. else
  5257. stac92xx_set_config_regs(codec,
  5258. stac922x_brd_tbl[spec->board_config]);
  5259. spec->adc_nids = stac922x_adc_nids;
  5260. spec->mux_nids = stac922x_mux_nids;
  5261. spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
  5262. spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
  5263. spec->num_dmics = 0;
  5264. spec->num_pwrs = 0;
  5265. spec->init = stac922x_core_init;
  5266. spec->num_caps = STAC922X_NUM_CAPS;
  5267. spec->capvols = stac922x_capvols;
  5268. spec->capsws = stac922x_capsws;
  5269. spec->multiout.dac_nids = spec->dac_nids;
  5270. err = stac92xx_parse_auto_config(codec);
  5271. if (!err) {
  5272. if (spec->board_config < 0) {
  5273. printk(KERN_WARNING "hda_codec: No auto-config is "
  5274. "available, default to model=ref\n");
  5275. spec->board_config = STAC_D945_REF;
  5276. goto again;
  5277. }
  5278. err = -EINVAL;
  5279. }
  5280. if (err < 0) {
  5281. stac92xx_free(codec);
  5282. return err;
  5283. }
  5284. codec->patch_ops = stac92xx_patch_ops;
  5285. /* Fix Mux capture level; max to 2 */
  5286. snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
  5287. (0 << AC_AMPCAP_OFFSET_SHIFT) |
  5288. (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  5289. (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  5290. (0 << AC_AMPCAP_MUTE_SHIFT));
  5291. return 0;
  5292. }
  5293. static int patch_stac927x(struct hda_codec *codec)
  5294. {
  5295. struct sigmatel_spec *spec;
  5296. int err;
  5297. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5298. if (spec == NULL)
  5299. return -ENOMEM;
  5300. codec->no_trigger_sense = 1;
  5301. codec->spec = spec;
  5302. spec->linear_tone_beep = 1;
  5303. codec->slave_dig_outs = stac927x_slave_dig_outs;
  5304. spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
  5305. spec->pin_nids = stac927x_pin_nids;
  5306. spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
  5307. stac927x_models,
  5308. stac927x_cfg_tbl);
  5309. again:
  5310. if (spec->board_config < 0)
  5311. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5312. codec->chip_name);
  5313. else
  5314. stac92xx_set_config_regs(codec,
  5315. stac927x_brd_tbl[spec->board_config]);
  5316. spec->digbeep_nid = 0x23;
  5317. spec->adc_nids = stac927x_adc_nids;
  5318. spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
  5319. spec->mux_nids = stac927x_mux_nids;
  5320. spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
  5321. spec->smux_nids = stac927x_smux_nids;
  5322. spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
  5323. spec->spdif_labels = stac927x_spdif_labels;
  5324. spec->dac_list = stac927x_dac_nids;
  5325. spec->multiout.dac_nids = spec->dac_nids;
  5326. if (spec->board_config != STAC_D965_REF) {
  5327. /* GPIO0 High = Enable EAPD */
  5328. spec->eapd_mask = spec->gpio_mask = 0x01;
  5329. spec->gpio_dir = spec->gpio_data = 0x01;
  5330. }
  5331. switch (spec->board_config) {
  5332. case STAC_D965_3ST:
  5333. case STAC_D965_5ST:
  5334. /* GPIO0 High = Enable EAPD */
  5335. spec->num_dmics = 0;
  5336. spec->init = d965_core_init;
  5337. break;
  5338. case STAC_DELL_BIOS:
  5339. switch (codec->subsystem_id) {
  5340. case 0x10280209:
  5341. case 0x1028022e:
  5342. /* correct the device field to SPDIF out */
  5343. snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
  5344. break;
  5345. }
  5346. /* configure the analog microphone on some laptops */
  5347. snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
  5348. /* correct the front output jack as a hp out */
  5349. snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
  5350. /* correct the front input jack as a mic */
  5351. snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
  5352. /* fallthru */
  5353. case STAC_DELL_3ST:
  5354. if (codec->subsystem_id != 0x1028022f) {
  5355. /* GPIO2 High = Enable EAPD */
  5356. spec->eapd_mask = spec->gpio_mask = 0x04;
  5357. spec->gpio_dir = spec->gpio_data = 0x04;
  5358. }
  5359. spec->dmic_nids = stac927x_dmic_nids;
  5360. spec->num_dmics = STAC927X_NUM_DMICS;
  5361. spec->init = dell_3st_core_init;
  5362. spec->dmux_nids = stac927x_dmux_nids;
  5363. spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
  5364. break;
  5365. case STAC_927X_VOLKNOB:
  5366. spec->num_dmics = 0;
  5367. spec->init = stac927x_volknob_core_init;
  5368. break;
  5369. default:
  5370. spec->num_dmics = 0;
  5371. spec->init = stac927x_core_init;
  5372. break;
  5373. }
  5374. spec->num_caps = STAC927X_NUM_CAPS;
  5375. spec->capvols = stac927x_capvols;
  5376. spec->capsws = stac927x_capsws;
  5377. spec->num_pwrs = 0;
  5378. spec->aloopback_ctl = stac927x_loopback;
  5379. spec->aloopback_mask = 0x40;
  5380. spec->aloopback_shift = 0;
  5381. spec->eapd_switch = 1;
  5382. err = stac92xx_parse_auto_config(codec);
  5383. if (!err) {
  5384. if (spec->board_config < 0) {
  5385. printk(KERN_WARNING "hda_codec: No auto-config is "
  5386. "available, default to model=ref\n");
  5387. spec->board_config = STAC_D965_REF;
  5388. goto again;
  5389. }
  5390. err = -EINVAL;
  5391. }
  5392. if (err < 0) {
  5393. stac92xx_free(codec);
  5394. return err;
  5395. }
  5396. codec->patch_ops = stac92xx_patch_ops;
  5397. codec->proc_widget_hook = stac927x_proc_hook;
  5398. /*
  5399. * !!FIXME!!
  5400. * The STAC927x seem to require fairly long delays for certain
  5401. * command sequences. With too short delays (even if the answer
  5402. * is set to RIRB properly), it results in the silence output
  5403. * on some hardwares like Dell.
  5404. *
  5405. * The below flag enables the longer delay (see get_response
  5406. * in hda_intel.c).
  5407. */
  5408. codec->bus->needs_damn_long_delay = 1;
  5409. /* no jack detecion for ref-no-jd model */
  5410. if (spec->board_config == STAC_D965_REF_NO_JD)
  5411. spec->hp_detect = 0;
  5412. return 0;
  5413. }
  5414. static int patch_stac9205(struct hda_codec *codec)
  5415. {
  5416. struct sigmatel_spec *spec;
  5417. int err;
  5418. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5419. if (spec == NULL)
  5420. return -ENOMEM;
  5421. codec->no_trigger_sense = 1;
  5422. codec->spec = spec;
  5423. spec->linear_tone_beep = 1;
  5424. spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
  5425. spec->pin_nids = stac9205_pin_nids;
  5426. spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
  5427. stac9205_models,
  5428. stac9205_cfg_tbl);
  5429. again:
  5430. if (spec->board_config < 0)
  5431. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5432. codec->chip_name);
  5433. else
  5434. stac92xx_set_config_regs(codec,
  5435. stac9205_brd_tbl[spec->board_config]);
  5436. spec->digbeep_nid = 0x23;
  5437. spec->adc_nids = stac9205_adc_nids;
  5438. spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
  5439. spec->mux_nids = stac9205_mux_nids;
  5440. spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
  5441. spec->smux_nids = stac9205_smux_nids;
  5442. spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
  5443. spec->dmic_nids = stac9205_dmic_nids;
  5444. spec->num_dmics = STAC9205_NUM_DMICS;
  5445. spec->dmux_nids = stac9205_dmux_nids;
  5446. spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
  5447. spec->num_pwrs = 0;
  5448. spec->init = stac9205_core_init;
  5449. spec->aloopback_ctl = stac9205_loopback;
  5450. spec->num_caps = STAC9205_NUM_CAPS;
  5451. spec->capvols = stac9205_capvols;
  5452. spec->capsws = stac9205_capsws;
  5453. spec->aloopback_mask = 0x40;
  5454. spec->aloopback_shift = 0;
  5455. /* Turn on/off EAPD per HP plugging */
  5456. if (spec->board_config != STAC_9205_EAPD)
  5457. spec->eapd_switch = 1;
  5458. spec->multiout.dac_nids = spec->dac_nids;
  5459. switch (spec->board_config){
  5460. case STAC_9205_DELL_M43:
  5461. /* Enable SPDIF in/out */
  5462. snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
  5463. snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
  5464. /* Enable unsol response for GPIO4/Dock HP connection */
  5465. err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
  5466. if (err < 0)
  5467. return err;
  5468. snd_hda_codec_write_cache(codec, codec->afg, 0,
  5469. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
  5470. snd_hda_jack_detect_enable(codec, codec->afg, 0);
  5471. spec->gpio_dir = 0x0b;
  5472. spec->eapd_mask = 0x01;
  5473. spec->gpio_mask = 0x1b;
  5474. spec->gpio_mute = 0x10;
  5475. /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
  5476. * GPIO3 Low = DRM
  5477. */
  5478. spec->gpio_data = 0x01;
  5479. break;
  5480. case STAC_9205_REF:
  5481. /* SPDIF-In enabled */
  5482. break;
  5483. default:
  5484. /* GPIO0 High = EAPD */
  5485. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  5486. spec->gpio_data = 0x01;
  5487. break;
  5488. }
  5489. err = stac92xx_parse_auto_config(codec);
  5490. if (!err) {
  5491. if (spec->board_config < 0) {
  5492. printk(KERN_WARNING "hda_codec: No auto-config is "
  5493. "available, default to model=ref\n");
  5494. spec->board_config = STAC_9205_REF;
  5495. goto again;
  5496. }
  5497. err = -EINVAL;
  5498. }
  5499. if (err < 0) {
  5500. stac92xx_free(codec);
  5501. return err;
  5502. }
  5503. codec->patch_ops = stac92xx_patch_ops;
  5504. codec->proc_widget_hook = stac9205_proc_hook;
  5505. return 0;
  5506. }
  5507. /*
  5508. * STAC9872 hack
  5509. */
  5510. static const struct hda_verb stac9872_core_init[] = {
  5511. {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
  5512. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  5513. {}
  5514. };
  5515. static const hda_nid_t stac9872_pin_nids[] = {
  5516. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  5517. 0x11, 0x13, 0x14,
  5518. };
  5519. static const hda_nid_t stac9872_adc_nids[] = {
  5520. 0x8 /*,0x6*/
  5521. };
  5522. static const hda_nid_t stac9872_mux_nids[] = {
  5523. 0x15
  5524. };
  5525. static const unsigned long stac9872_capvols[] = {
  5526. HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
  5527. };
  5528. #define stac9872_capsws stac9872_capvols
  5529. static const unsigned int stac9872_vaio_pin_configs[9] = {
  5530. 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
  5531. 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
  5532. 0x90a7013e
  5533. };
  5534. static const char * const stac9872_models[STAC_9872_MODELS] = {
  5535. [STAC_9872_AUTO] = "auto",
  5536. [STAC_9872_VAIO] = "vaio",
  5537. };
  5538. static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
  5539. [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
  5540. };
  5541. static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
  5542. SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
  5543. "Sony VAIO F/S", STAC_9872_VAIO),
  5544. {} /* terminator */
  5545. };
  5546. static int patch_stac9872(struct hda_codec *codec)
  5547. {
  5548. struct sigmatel_spec *spec;
  5549. int err;
  5550. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5551. if (spec == NULL)
  5552. return -ENOMEM;
  5553. codec->no_trigger_sense = 1;
  5554. codec->spec = spec;
  5555. spec->linear_tone_beep = 1;
  5556. spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
  5557. spec->pin_nids = stac9872_pin_nids;
  5558. spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
  5559. stac9872_models,
  5560. stac9872_cfg_tbl);
  5561. if (spec->board_config < 0)
  5562. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5563. codec->chip_name);
  5564. else
  5565. stac92xx_set_config_regs(codec,
  5566. stac9872_brd_tbl[spec->board_config]);
  5567. spec->multiout.dac_nids = spec->dac_nids;
  5568. spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
  5569. spec->adc_nids = stac9872_adc_nids;
  5570. spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
  5571. spec->mux_nids = stac9872_mux_nids;
  5572. spec->init = stac9872_core_init;
  5573. spec->num_caps = 1;
  5574. spec->capvols = stac9872_capvols;
  5575. spec->capsws = stac9872_capsws;
  5576. err = stac92xx_parse_auto_config(codec);
  5577. if (err < 0) {
  5578. stac92xx_free(codec);
  5579. return -EINVAL;
  5580. }
  5581. spec->input_mux = &spec->private_imux;
  5582. codec->patch_ops = stac92xx_patch_ops;
  5583. return 0;
  5584. }
  5585. /*
  5586. * patch entries
  5587. */
  5588. static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  5589. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  5590. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  5591. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  5592. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  5593. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  5594. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  5595. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  5596. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  5597. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  5598. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  5599. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  5600. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  5601. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  5602. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  5603. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  5604. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  5605. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  5606. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  5607. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  5608. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  5609. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  5610. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  5611. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  5612. { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
  5613. { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
  5614. { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
  5615. { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
  5616. { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
  5617. { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
  5618. { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
  5619. { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
  5620. /* The following does not take into account .id=0x83847661 when subsys =
  5621. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  5622. * currently not fully supported.
  5623. */
  5624. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  5625. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  5626. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  5627. { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
  5628. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  5629. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  5630. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  5631. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  5632. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  5633. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  5634. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  5635. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  5636. { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
  5637. { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
  5638. { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
  5639. { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
  5640. { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
  5641. { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
  5642. { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
  5643. { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
  5644. { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
  5645. { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
  5646. { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
  5647. { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
  5648. { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
  5649. { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
  5650. { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
  5651. { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  5652. { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  5653. { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  5654. { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  5655. { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  5656. { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  5657. { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  5658. { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  5659. { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
  5660. { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
  5661. { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
  5662. { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
  5663. { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
  5664. { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
  5665. { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
  5666. { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
  5667. { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
  5668. { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
  5669. { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
  5670. { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
  5671. { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
  5672. { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
  5673. { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
  5674. { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
  5675. { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
  5676. { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
  5677. { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
  5678. { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
  5679. { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
  5680. { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
  5681. { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
  5682. { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
  5683. { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
  5684. { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
  5685. { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
  5686. { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
  5687. { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
  5688. { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
  5689. { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
  5690. { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
  5691. {} /* terminator */
  5692. };
  5693. MODULE_ALIAS("snd-hda-codec-id:8384*");
  5694. MODULE_ALIAS("snd-hda-codec-id:111d*");
  5695. MODULE_LICENSE("GPL");
  5696. MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
  5697. static struct hda_codec_preset_list sigmatel_list = {
  5698. .preset = snd_hda_preset_sigmatel,
  5699. .owner = THIS_MODULE,
  5700. };
  5701. static int __init patch_sigmatel_init(void)
  5702. {
  5703. return snd_hda_add_codec_preset(&sigmatel_list);
  5704. }
  5705. static void __exit patch_sigmatel_exit(void)
  5706. {
  5707. snd_hda_delete_codec_preset(&sigmatel_list);
  5708. }
  5709. module_init(patch_sigmatel_init)
  5710. module_exit(patch_sigmatel_exit)