patch_sigmatel.c 193 KB

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