patch_sigmatel.c 200 KB

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