patch_sigmatel.c 183 KB

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