patch_sigmatel.c 196 KB

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