patch_sigmatel.c 182 KB

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