patch_sigmatel.c 198 KB

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