kona.c 171 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <soc/snd_event.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <soc/swr-common.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include "asoc/msm-cdc-pinctrl.h"
  30. #include "asoc/wcd-mbhc-v2.h"
  31. #include "codecs/wcd938x/wcd938x-mbhc.h"
  32. #include "codecs/wsa881x.h"
  33. #include "codecs/wcd938x/wcd938x.h"
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include <dt-bindings/sound/audio-codec-port-types.h>
  36. #include "codecs/bolero/wsa-macro.h"
  37. #include "sm8250-port-config.h"
  38. #define DRV_NAME "kona-asoc-snd"
  39. #define __CHIPSET__ "KONA "
  40. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  41. #define SAMPLING_RATE_8KHZ 8000
  42. #define SAMPLING_RATE_11P025KHZ 11025
  43. #define SAMPLING_RATE_16KHZ 16000
  44. #define SAMPLING_RATE_22P05KHZ 22050
  45. #define SAMPLING_RATE_32KHZ 32000
  46. #define SAMPLING_RATE_44P1KHZ 44100
  47. #define SAMPLING_RATE_48KHZ 48000
  48. #define SAMPLING_RATE_88P2KHZ 88200
  49. #define SAMPLING_RATE_96KHZ 96000
  50. #define SAMPLING_RATE_176P4KHZ 176400
  51. #define SAMPLING_RATE_192KHZ 192000
  52. #define SAMPLING_RATE_352P8KHZ 352800
  53. #define SAMPLING_RATE_384KHZ 384000
  54. #define WCD9XXX_MBHC_DEF_RLOADS 5
  55. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  56. #define CODEC_EXT_CLK_RATE 9600000
  57. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  58. #define DEV_NAME_STR_LEN 32
  59. #define WCD_MBHC_HS_V_MAX 1600
  60. #define TDM_CHANNEL_MAX 8
  61. #define DEV_NAME_STR_LEN 32
  62. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  63. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  64. #define WSA8810_NAME_1 "wsa881x.20170211"
  65. #define WSA8810_NAME_2 "wsa881x.20170212"
  66. #define WCN_CDC_SLIM_RX_CH_MAX 2
  67. #define WCN_CDC_SLIM_TX_CH_MAX 2
  68. enum {
  69. TDM_0 = 0,
  70. TDM_1,
  71. TDM_2,
  72. TDM_3,
  73. TDM_4,
  74. TDM_5,
  75. TDM_6,
  76. TDM_7,
  77. TDM_PORT_MAX,
  78. };
  79. enum {
  80. TDM_PRI = 0,
  81. TDM_SEC,
  82. TDM_TERT,
  83. TDM_INTERFACE_MAX,
  84. };
  85. enum {
  86. PRIM_AUX_PCM = 0,
  87. SEC_AUX_PCM,
  88. TERT_AUX_PCM,
  89. AUX_PCM_MAX,
  90. };
  91. enum {
  92. PRIM_MI2S = 0,
  93. SEC_MI2S,
  94. TERT_MI2S,
  95. MI2S_MAX,
  96. };
  97. enum {
  98. WSA_CDC_DMA_RX_0 = 0,
  99. WSA_CDC_DMA_RX_1,
  100. RX_CDC_DMA_RX_0,
  101. RX_CDC_DMA_RX_1,
  102. RX_CDC_DMA_RX_2,
  103. RX_CDC_DMA_RX_3,
  104. RX_CDC_DMA_RX_5,
  105. CDC_DMA_RX_MAX,
  106. };
  107. enum {
  108. WSA_CDC_DMA_TX_0 = 0,
  109. WSA_CDC_DMA_TX_1,
  110. WSA_CDC_DMA_TX_2,
  111. TX_CDC_DMA_TX_0,
  112. TX_CDC_DMA_TX_3,
  113. TX_CDC_DMA_TX_4,
  114. VA_CDC_DMA_TX_0,
  115. VA_CDC_DMA_TX_1,
  116. VA_CDC_DMA_TX_2,
  117. CDC_DMA_TX_MAX,
  118. };
  119. struct msm_asoc_mach_data {
  120. struct snd_info_entry *codec_root;
  121. int usbc_en2_gpio; /* used by gpio driver API */
  122. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  123. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  124. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  125. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  126. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  127. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  128. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  129. bool is_afe_config_done;
  130. struct device_node *fsa_handle;
  131. };
  132. struct tdm_port {
  133. u32 mode;
  134. u32 channel;
  135. };
  136. enum {
  137. EXT_DISP_RX_IDX_DP = 0,
  138. EXT_DISP_RX_IDX_MAX,
  139. };
  140. struct msm_wsa881x_dev_info {
  141. struct device_node *of_node;
  142. u32 index;
  143. };
  144. struct aux_codec_dev_info {
  145. struct device_node *of_node;
  146. u32 index;
  147. };
  148. struct dev_config {
  149. u32 sample_rate;
  150. u32 bit_format;
  151. u32 channels;
  152. };
  153. /* Default configuration of external display BE */
  154. static struct dev_config ext_disp_rx_cfg[] = {
  155. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  156. };
  157. static struct dev_config usb_rx_cfg = {
  158. .sample_rate = SAMPLING_RATE_48KHZ,
  159. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  160. .channels = 2,
  161. };
  162. static struct dev_config usb_tx_cfg = {
  163. .sample_rate = SAMPLING_RATE_48KHZ,
  164. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  165. .channels = 1,
  166. };
  167. static struct dev_config proxy_rx_cfg = {
  168. .sample_rate = SAMPLING_RATE_48KHZ,
  169. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  170. .channels = 2,
  171. };
  172. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  173. {
  174. AFE_API_VERSION_I2S_CONFIG,
  175. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  176. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  177. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  178. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  179. 0,
  180. },
  181. {
  182. AFE_API_VERSION_I2S_CONFIG,
  183. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  184. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  185. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  186. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  187. 0,
  188. },
  189. {
  190. AFE_API_VERSION_I2S_CONFIG,
  191. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  192. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  193. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  194. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  195. 0,
  196. },
  197. };
  198. struct mi2s_conf {
  199. struct mutex lock;
  200. u32 ref_cnt;
  201. u32 msm_is_mi2s_master;
  202. };
  203. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  204. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  205. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  206. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  207. };
  208. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  209. /* Default configuration of TDM channels */
  210. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  211. { /* PRI TDM */
  212. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  213. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  220. },
  221. { /* SEC TDM */
  222. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  223. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  230. },
  231. { /* TERT TDM */
  232. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  233. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  240. },
  241. };
  242. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  243. { /* PRI TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  252. },
  253. { /* SEC TDM */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  262. },
  263. { /* TERT TDM */
  264. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  265. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  266. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  272. },
  273. };
  274. /* Default configuration of AUX PCM channels */
  275. static struct dev_config aux_pcm_rx_cfg[] = {
  276. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  277. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  278. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  279. };
  280. static struct dev_config aux_pcm_tx_cfg[] = {
  281. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  282. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  283. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  284. };
  285. /* Default configuration of MI2S channels */
  286. static struct dev_config mi2s_rx_cfg[] = {
  287. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  288. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  289. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  290. };
  291. static struct dev_config mi2s_tx_cfg[] = {
  292. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  293. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  294. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  295. };
  296. /* Default configuration of Codec DMA Interface RX */
  297. static struct dev_config cdc_dma_rx_cfg[] = {
  298. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  299. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  300. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  301. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  302. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  303. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  304. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  305. };
  306. /* Default configuration of Codec DMA Interface TX */
  307. static struct dev_config cdc_dma_tx_cfg[] = {
  308. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  309. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  310. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  311. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  312. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  313. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  314. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  315. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  316. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  317. };
  318. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  319. "S32_LE"};
  320. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  321. "Six", "Seven", "Eight"};
  322. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  323. "KHZ_16", "KHZ_22P05",
  324. "KHZ_32", "KHZ_44P1", "KHZ_48",
  325. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  326. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  327. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  328. "Five", "Six", "Seven",
  329. "Eight"};
  330. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  331. "KHZ_48", "KHZ_176P4",
  332. "KHZ_352P8"};
  333. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  334. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  335. "Five", "Six", "Seven", "Eight"};
  336. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  337. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  338. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  339. "KHZ_48", "KHZ_96", "KHZ_192"};
  340. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  341. "Five", "Six", "Seven",
  342. "Eight"};
  343. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  344. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  345. "Five", "Six", "Seven",
  346. "Eight"};
  347. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  348. "KHZ_16", "KHZ_22P05",
  349. "KHZ_32", "KHZ_44P1", "KHZ_48",
  350. "KHZ_88P2", "KHZ_96",
  351. "KHZ_176P4", "KHZ_192",
  352. "KHZ_352P8", "KHZ_384"};
  353. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  354. "S24_3LE"};
  355. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  356. "KHZ_192", "KHZ_32", "KHZ_44P1",
  357. "KHZ_88P2", "KHZ_176P4"};
  358. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  359. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  360. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  361. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  362. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  363. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  364. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  365. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  366. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  367. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  368. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  369. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  370. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  371. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  372. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  373. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  374. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  375. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  376. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  377. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  378. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  379. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  380. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  381. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  382. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  383. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  384. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  385. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  386. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  387. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  388. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  389. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  390. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  391. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  392. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  393. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  394. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  395. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  396. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  397. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  398. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  399. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  400. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  401. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  402. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  403. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  404. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  405. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  406. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  407. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  408. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  409. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  410. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  411. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  412. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  413. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  414. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  415. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  416. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  417. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  418. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  419. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  420. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  421. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  422. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  423. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  424. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  425. cdc_dma_sample_rate_text);
  426. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  427. cdc_dma_sample_rate_text);
  428. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  429. cdc_dma_sample_rate_text);
  430. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  431. cdc_dma_sample_rate_text);
  432. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  433. cdc_dma_sample_rate_text);
  434. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  435. cdc_dma_sample_rate_text);
  436. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  437. cdc_dma_sample_rate_text);
  438. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  439. cdc_dma_sample_rate_text);
  440. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  441. cdc_dma_sample_rate_text);
  442. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  443. cdc_dma_sample_rate_text);
  444. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  445. cdc_dma_sample_rate_text);
  446. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  447. cdc_dma_sample_rate_text);
  448. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  449. cdc_dma_sample_rate_text);
  450. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  451. cdc_dma_sample_rate_text);
  452. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  453. cdc_dma_sample_rate_text);
  454. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  455. cdc_dma_sample_rate_text);
  456. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  457. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  459. ext_disp_sample_rate_text);
  460. static bool is_initial_boot;
  461. static bool codec_reg_done;
  462. static struct snd_soc_aux_dev *msm_aux_dev;
  463. static struct snd_soc_codec_conf *msm_codec_conf;
  464. static struct snd_soc_card snd_soc_card_kona_msm;
  465. static int dmic_0_1_gpio_cnt;
  466. static int dmic_2_3_gpio_cnt;
  467. static int dmic_4_5_gpio_cnt;
  468. static int msm_vi_feed_tx_ch = 2;
  469. static void *def_wcd_mbhc_cal(void);
  470. /*
  471. * Need to report LINEIN
  472. * if R/L channel impedance is larger than 5K ohm
  473. */
  474. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  475. .read_fw_bin = false,
  476. .calibration = NULL,
  477. .detect_extn_cable = true,
  478. .mono_stero_detection = false,
  479. .swap_gnd_mic = NULL,
  480. .hs_ext_micbias = true,
  481. .key_code[0] = KEY_MEDIA,
  482. .key_code[1] = KEY_VOICECOMMAND,
  483. .key_code[2] = KEY_VOLUMEUP,
  484. .key_code[3] = KEY_VOLUMEDOWN,
  485. .key_code[4] = 0,
  486. .key_code[5] = 0,
  487. .key_code[6] = 0,
  488. .key_code[7] = 0,
  489. .linein_th = 5000,
  490. .moisture_en = true,
  491. .mbhc_micbias = MIC_BIAS_2,
  492. .anc_micbias = MIC_BIAS_2,
  493. .enable_anc_mic_detect = false,
  494. };
  495. static inline int param_is_mask(int p)
  496. {
  497. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  498. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  499. }
  500. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  501. int n)
  502. {
  503. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  504. }
  505. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  506. unsigned int bit)
  507. {
  508. if (bit >= SNDRV_MASK_MAX)
  509. return;
  510. if (param_is_mask(n)) {
  511. struct snd_mask *m = param_to_mask(p, n);
  512. m->bits[0] = 0;
  513. m->bits[1] = 0;
  514. m->bits[bit >> 5] |= (1 << (bit & 31));
  515. }
  516. }
  517. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. int sample_rate_val = 0;
  521. switch (usb_rx_cfg.sample_rate) {
  522. case SAMPLING_RATE_384KHZ:
  523. sample_rate_val = 12;
  524. break;
  525. case SAMPLING_RATE_352P8KHZ:
  526. sample_rate_val = 11;
  527. break;
  528. case SAMPLING_RATE_192KHZ:
  529. sample_rate_val = 10;
  530. break;
  531. case SAMPLING_RATE_176P4KHZ:
  532. sample_rate_val = 9;
  533. break;
  534. case SAMPLING_RATE_96KHZ:
  535. sample_rate_val = 8;
  536. break;
  537. case SAMPLING_RATE_88P2KHZ:
  538. sample_rate_val = 7;
  539. break;
  540. case SAMPLING_RATE_48KHZ:
  541. sample_rate_val = 6;
  542. break;
  543. case SAMPLING_RATE_44P1KHZ:
  544. sample_rate_val = 5;
  545. break;
  546. case SAMPLING_RATE_32KHZ:
  547. sample_rate_val = 4;
  548. break;
  549. case SAMPLING_RATE_22P05KHZ:
  550. sample_rate_val = 3;
  551. break;
  552. case SAMPLING_RATE_16KHZ:
  553. sample_rate_val = 2;
  554. break;
  555. case SAMPLING_RATE_11P025KHZ:
  556. sample_rate_val = 1;
  557. break;
  558. case SAMPLING_RATE_8KHZ:
  559. default:
  560. sample_rate_val = 0;
  561. break;
  562. }
  563. ucontrol->value.integer.value[0] = sample_rate_val;
  564. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  565. usb_rx_cfg.sample_rate);
  566. return 0;
  567. }
  568. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  569. struct snd_ctl_elem_value *ucontrol)
  570. {
  571. switch (ucontrol->value.integer.value[0]) {
  572. case 12:
  573. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  574. break;
  575. case 11:
  576. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  577. break;
  578. case 10:
  579. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  580. break;
  581. case 9:
  582. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  583. break;
  584. case 8:
  585. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  586. break;
  587. case 7:
  588. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  589. break;
  590. case 6:
  591. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  592. break;
  593. case 5:
  594. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  595. break;
  596. case 4:
  597. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  598. break;
  599. case 3:
  600. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  601. break;
  602. case 2:
  603. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  604. break;
  605. case 1:
  606. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  607. break;
  608. case 0:
  609. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  610. break;
  611. default:
  612. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  613. break;
  614. }
  615. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  616. __func__, ucontrol->value.integer.value[0],
  617. usb_rx_cfg.sample_rate);
  618. return 0;
  619. }
  620. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  621. struct snd_ctl_elem_value *ucontrol)
  622. {
  623. int sample_rate_val = 0;
  624. switch (usb_tx_cfg.sample_rate) {
  625. case SAMPLING_RATE_384KHZ:
  626. sample_rate_val = 12;
  627. break;
  628. case SAMPLING_RATE_352P8KHZ:
  629. sample_rate_val = 11;
  630. break;
  631. case SAMPLING_RATE_192KHZ:
  632. sample_rate_val = 10;
  633. break;
  634. case SAMPLING_RATE_176P4KHZ:
  635. sample_rate_val = 9;
  636. break;
  637. case SAMPLING_RATE_96KHZ:
  638. sample_rate_val = 8;
  639. break;
  640. case SAMPLING_RATE_88P2KHZ:
  641. sample_rate_val = 7;
  642. break;
  643. case SAMPLING_RATE_48KHZ:
  644. sample_rate_val = 6;
  645. break;
  646. case SAMPLING_RATE_44P1KHZ:
  647. sample_rate_val = 5;
  648. break;
  649. case SAMPLING_RATE_32KHZ:
  650. sample_rate_val = 4;
  651. break;
  652. case SAMPLING_RATE_22P05KHZ:
  653. sample_rate_val = 3;
  654. break;
  655. case SAMPLING_RATE_16KHZ:
  656. sample_rate_val = 2;
  657. break;
  658. case SAMPLING_RATE_11P025KHZ:
  659. sample_rate_val = 1;
  660. break;
  661. case SAMPLING_RATE_8KHZ:
  662. sample_rate_val = 0;
  663. break;
  664. default:
  665. sample_rate_val = 6;
  666. break;
  667. }
  668. ucontrol->value.integer.value[0] = sample_rate_val;
  669. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  670. usb_tx_cfg.sample_rate);
  671. return 0;
  672. }
  673. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  674. struct snd_ctl_elem_value *ucontrol)
  675. {
  676. switch (ucontrol->value.integer.value[0]) {
  677. case 12:
  678. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  679. break;
  680. case 11:
  681. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  682. break;
  683. case 10:
  684. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  685. break;
  686. case 9:
  687. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  688. break;
  689. case 8:
  690. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  691. break;
  692. case 7:
  693. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  694. break;
  695. case 6:
  696. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  697. break;
  698. case 5:
  699. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  700. break;
  701. case 4:
  702. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  703. break;
  704. case 3:
  705. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  706. break;
  707. case 2:
  708. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  709. break;
  710. case 1:
  711. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  712. break;
  713. case 0:
  714. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  715. break;
  716. default:
  717. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  718. break;
  719. }
  720. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  721. __func__, ucontrol->value.integer.value[0],
  722. usb_tx_cfg.sample_rate);
  723. return 0;
  724. }
  725. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  726. struct snd_ctl_elem_value *ucontrol)
  727. {
  728. switch (usb_rx_cfg.bit_format) {
  729. case SNDRV_PCM_FORMAT_S32_LE:
  730. ucontrol->value.integer.value[0] = 3;
  731. break;
  732. case SNDRV_PCM_FORMAT_S24_3LE:
  733. ucontrol->value.integer.value[0] = 2;
  734. break;
  735. case SNDRV_PCM_FORMAT_S24_LE:
  736. ucontrol->value.integer.value[0] = 1;
  737. break;
  738. case SNDRV_PCM_FORMAT_S16_LE:
  739. default:
  740. ucontrol->value.integer.value[0] = 0;
  741. break;
  742. }
  743. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  744. __func__, usb_rx_cfg.bit_format,
  745. ucontrol->value.integer.value[0]);
  746. return 0;
  747. }
  748. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  749. struct snd_ctl_elem_value *ucontrol)
  750. {
  751. int rc = 0;
  752. switch (ucontrol->value.integer.value[0]) {
  753. case 3:
  754. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  755. break;
  756. case 2:
  757. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  758. break;
  759. case 1:
  760. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  761. break;
  762. case 0:
  763. default:
  764. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  765. break;
  766. }
  767. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  768. __func__, usb_rx_cfg.bit_format,
  769. ucontrol->value.integer.value[0]);
  770. return rc;
  771. }
  772. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  773. struct snd_ctl_elem_value *ucontrol)
  774. {
  775. switch (usb_tx_cfg.bit_format) {
  776. case SNDRV_PCM_FORMAT_S32_LE:
  777. ucontrol->value.integer.value[0] = 3;
  778. break;
  779. case SNDRV_PCM_FORMAT_S24_3LE:
  780. ucontrol->value.integer.value[0] = 2;
  781. break;
  782. case SNDRV_PCM_FORMAT_S24_LE:
  783. ucontrol->value.integer.value[0] = 1;
  784. break;
  785. case SNDRV_PCM_FORMAT_S16_LE:
  786. default:
  787. ucontrol->value.integer.value[0] = 0;
  788. break;
  789. }
  790. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  791. __func__, usb_tx_cfg.bit_format,
  792. ucontrol->value.integer.value[0]);
  793. return 0;
  794. }
  795. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  796. struct snd_ctl_elem_value *ucontrol)
  797. {
  798. int rc = 0;
  799. switch (ucontrol->value.integer.value[0]) {
  800. case 3:
  801. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  802. break;
  803. case 2:
  804. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  805. break;
  806. case 1:
  807. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  808. break;
  809. case 0:
  810. default:
  811. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  812. break;
  813. }
  814. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  815. __func__, usb_tx_cfg.bit_format,
  816. ucontrol->value.integer.value[0]);
  817. return rc;
  818. }
  819. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  820. struct snd_ctl_elem_value *ucontrol)
  821. {
  822. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  823. usb_rx_cfg.channels);
  824. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  825. return 0;
  826. }
  827. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  828. struct snd_ctl_elem_value *ucontrol)
  829. {
  830. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  831. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  832. return 1;
  833. }
  834. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  835. struct snd_ctl_elem_value *ucontrol)
  836. {
  837. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  838. usb_tx_cfg.channels);
  839. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  840. return 0;
  841. }
  842. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  843. struct snd_ctl_elem_value *ucontrol)
  844. {
  845. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  846. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  847. return 1;
  848. }
  849. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  850. {
  851. int idx = 0;
  852. if (strnstr(kcontrol->id.name, "Display Port RX",
  853. sizeof("Display Port RX"))) {
  854. idx = EXT_DISP_RX_IDX_DP;
  855. } else {
  856. pr_err("%s: unsupported BE: %s\n",
  857. __func__, kcontrol->id.name);
  858. idx = -EINVAL;
  859. }
  860. return idx;
  861. }
  862. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  863. struct snd_ctl_elem_value *ucontrol)
  864. {
  865. int idx = ext_disp_get_port_idx(kcontrol);
  866. if (idx < 0)
  867. return idx;
  868. switch (ext_disp_rx_cfg[idx].bit_format) {
  869. case SNDRV_PCM_FORMAT_S24_3LE:
  870. ucontrol->value.integer.value[0] = 2;
  871. break;
  872. case SNDRV_PCM_FORMAT_S24_LE:
  873. ucontrol->value.integer.value[0] = 1;
  874. break;
  875. case SNDRV_PCM_FORMAT_S16_LE:
  876. default:
  877. ucontrol->value.integer.value[0] = 0;
  878. break;
  879. }
  880. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  881. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  882. ucontrol->value.integer.value[0]);
  883. return 0;
  884. }
  885. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  886. struct snd_ctl_elem_value *ucontrol)
  887. {
  888. int idx = ext_disp_get_port_idx(kcontrol);
  889. if (idx < 0)
  890. return idx;
  891. switch (ucontrol->value.integer.value[0]) {
  892. case 2:
  893. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  894. break;
  895. case 1:
  896. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  897. break;
  898. case 0:
  899. default:
  900. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  901. break;
  902. }
  903. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  904. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  905. ucontrol->value.integer.value[0]);
  906. return 0;
  907. }
  908. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. int idx = ext_disp_get_port_idx(kcontrol);
  912. if (idx < 0)
  913. return idx;
  914. ucontrol->value.integer.value[0] =
  915. ext_disp_rx_cfg[idx].channels - 2;
  916. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  917. idx, ext_disp_rx_cfg[idx].channels);
  918. return 0;
  919. }
  920. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  921. struct snd_ctl_elem_value *ucontrol)
  922. {
  923. int idx = ext_disp_get_port_idx(kcontrol);
  924. if (idx < 0)
  925. return idx;
  926. ext_disp_rx_cfg[idx].channels =
  927. ucontrol->value.integer.value[0] + 2;
  928. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  929. idx, ext_disp_rx_cfg[idx].channels);
  930. return 1;
  931. }
  932. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  933. struct snd_ctl_elem_value *ucontrol)
  934. {
  935. int sample_rate_val;
  936. int idx = ext_disp_get_port_idx(kcontrol);
  937. if (idx < 0)
  938. return idx;
  939. switch (ext_disp_rx_cfg[idx].sample_rate) {
  940. case SAMPLING_RATE_176P4KHZ:
  941. sample_rate_val = 6;
  942. break;
  943. case SAMPLING_RATE_88P2KHZ:
  944. sample_rate_val = 5;
  945. break;
  946. case SAMPLING_RATE_44P1KHZ:
  947. sample_rate_val = 4;
  948. break;
  949. case SAMPLING_RATE_32KHZ:
  950. sample_rate_val = 3;
  951. break;
  952. case SAMPLING_RATE_192KHZ:
  953. sample_rate_val = 2;
  954. break;
  955. case SAMPLING_RATE_96KHZ:
  956. sample_rate_val = 1;
  957. break;
  958. case SAMPLING_RATE_48KHZ:
  959. default:
  960. sample_rate_val = 0;
  961. break;
  962. }
  963. ucontrol->value.integer.value[0] = sample_rate_val;
  964. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  965. idx, ext_disp_rx_cfg[idx].sample_rate);
  966. return 0;
  967. }
  968. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  969. struct snd_ctl_elem_value *ucontrol)
  970. {
  971. int idx = ext_disp_get_port_idx(kcontrol);
  972. if (idx < 0)
  973. return idx;
  974. switch (ucontrol->value.integer.value[0]) {
  975. case 6:
  976. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  977. break;
  978. case 5:
  979. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  980. break;
  981. case 4:
  982. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  983. break;
  984. case 3:
  985. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  986. break;
  987. case 2:
  988. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  989. break;
  990. case 1:
  991. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  992. break;
  993. case 0:
  994. default:
  995. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  996. break;
  997. }
  998. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  999. __func__, ucontrol->value.integer.value[0], idx,
  1000. ext_disp_rx_cfg[idx].sample_rate);
  1001. return 0;
  1002. }
  1003. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1004. struct snd_ctl_elem_value *ucontrol)
  1005. {
  1006. pr_debug("%s: proxy_rx channels = %d\n",
  1007. __func__, proxy_rx_cfg.channels);
  1008. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1009. return 0;
  1010. }
  1011. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1012. struct snd_ctl_elem_value *ucontrol)
  1013. {
  1014. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1015. pr_debug("%s: proxy_rx channels = %d\n",
  1016. __func__, proxy_rx_cfg.channels);
  1017. return 1;
  1018. }
  1019. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1020. struct tdm_port *port)
  1021. {
  1022. if (port) {
  1023. if (strnstr(kcontrol->id.name, "PRI",
  1024. sizeof(kcontrol->id.name))) {
  1025. port->mode = TDM_PRI;
  1026. } else if (strnstr(kcontrol->id.name, "SEC",
  1027. sizeof(kcontrol->id.name))) {
  1028. port->mode = TDM_SEC;
  1029. } else if (strnstr(kcontrol->id.name, "TERT",
  1030. sizeof(kcontrol->id.name))) {
  1031. port->mode = TDM_TERT;
  1032. } else {
  1033. pr_err("%s: unsupported mode in: %s\n",
  1034. __func__, kcontrol->id.name);
  1035. return -EINVAL;
  1036. }
  1037. if (strnstr(kcontrol->id.name, "RX_0",
  1038. sizeof(kcontrol->id.name)) ||
  1039. strnstr(kcontrol->id.name, "TX_0",
  1040. sizeof(kcontrol->id.name))) {
  1041. port->channel = TDM_0;
  1042. } else if (strnstr(kcontrol->id.name, "RX_1",
  1043. sizeof(kcontrol->id.name)) ||
  1044. strnstr(kcontrol->id.name, "TX_1",
  1045. sizeof(kcontrol->id.name))) {
  1046. port->channel = TDM_1;
  1047. } else if (strnstr(kcontrol->id.name, "RX_2",
  1048. sizeof(kcontrol->id.name)) ||
  1049. strnstr(kcontrol->id.name, "TX_2",
  1050. sizeof(kcontrol->id.name))) {
  1051. port->channel = TDM_2;
  1052. } else if (strnstr(kcontrol->id.name, "RX_3",
  1053. sizeof(kcontrol->id.name)) ||
  1054. strnstr(kcontrol->id.name, "TX_3",
  1055. sizeof(kcontrol->id.name))) {
  1056. port->channel = TDM_3;
  1057. } else if (strnstr(kcontrol->id.name, "RX_4",
  1058. sizeof(kcontrol->id.name)) ||
  1059. strnstr(kcontrol->id.name, "TX_4",
  1060. sizeof(kcontrol->id.name))) {
  1061. port->channel = TDM_4;
  1062. } else if (strnstr(kcontrol->id.name, "RX_5",
  1063. sizeof(kcontrol->id.name)) ||
  1064. strnstr(kcontrol->id.name, "TX_5",
  1065. sizeof(kcontrol->id.name))) {
  1066. port->channel = TDM_5;
  1067. } else if (strnstr(kcontrol->id.name, "RX_6",
  1068. sizeof(kcontrol->id.name)) ||
  1069. strnstr(kcontrol->id.name, "TX_6",
  1070. sizeof(kcontrol->id.name))) {
  1071. port->channel = TDM_6;
  1072. } else if (strnstr(kcontrol->id.name, "RX_7",
  1073. sizeof(kcontrol->id.name)) ||
  1074. strnstr(kcontrol->id.name, "TX_7",
  1075. sizeof(kcontrol->id.name))) {
  1076. port->channel = TDM_7;
  1077. } else {
  1078. pr_err("%s: unsupported channel in: %s\n",
  1079. __func__, kcontrol->id.name);
  1080. return -EINVAL;
  1081. }
  1082. } else {
  1083. return -EINVAL;
  1084. }
  1085. return 0;
  1086. }
  1087. static int tdm_get_sample_rate(int value)
  1088. {
  1089. int sample_rate = 0;
  1090. switch (value) {
  1091. case 0:
  1092. sample_rate = SAMPLING_RATE_8KHZ;
  1093. break;
  1094. case 1:
  1095. sample_rate = SAMPLING_RATE_16KHZ;
  1096. break;
  1097. case 2:
  1098. sample_rate = SAMPLING_RATE_32KHZ;
  1099. break;
  1100. case 3:
  1101. sample_rate = SAMPLING_RATE_48KHZ;
  1102. break;
  1103. case 4:
  1104. sample_rate = SAMPLING_RATE_176P4KHZ;
  1105. break;
  1106. case 5:
  1107. sample_rate = SAMPLING_RATE_352P8KHZ;
  1108. break;
  1109. default:
  1110. sample_rate = SAMPLING_RATE_48KHZ;
  1111. break;
  1112. }
  1113. return sample_rate;
  1114. }
  1115. static int tdm_get_sample_rate_val(int sample_rate)
  1116. {
  1117. int sample_rate_val = 0;
  1118. switch (sample_rate) {
  1119. case SAMPLING_RATE_8KHZ:
  1120. sample_rate_val = 0;
  1121. break;
  1122. case SAMPLING_RATE_16KHZ:
  1123. sample_rate_val = 1;
  1124. break;
  1125. case SAMPLING_RATE_32KHZ:
  1126. sample_rate_val = 2;
  1127. break;
  1128. case SAMPLING_RATE_48KHZ:
  1129. sample_rate_val = 3;
  1130. break;
  1131. case SAMPLING_RATE_176P4KHZ:
  1132. sample_rate_val = 4;
  1133. break;
  1134. case SAMPLING_RATE_352P8KHZ:
  1135. sample_rate_val = 5;
  1136. break;
  1137. default:
  1138. sample_rate_val = 3;
  1139. break;
  1140. }
  1141. return sample_rate_val;
  1142. }
  1143. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1144. struct snd_ctl_elem_value *ucontrol)
  1145. {
  1146. struct tdm_port port;
  1147. int ret = tdm_get_port_idx(kcontrol, &port);
  1148. if (ret) {
  1149. pr_err("%s: unsupported control: %s\n",
  1150. __func__, kcontrol->id.name);
  1151. } else {
  1152. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1153. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1154. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1155. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1156. ucontrol->value.enumerated.item[0]);
  1157. }
  1158. return ret;
  1159. }
  1160. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1161. struct snd_ctl_elem_value *ucontrol)
  1162. {
  1163. struct tdm_port port;
  1164. int ret = tdm_get_port_idx(kcontrol, &port);
  1165. if (ret) {
  1166. pr_err("%s: unsupported control: %s\n",
  1167. __func__, kcontrol->id.name);
  1168. } else {
  1169. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1170. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1171. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1172. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1173. ucontrol->value.enumerated.item[0]);
  1174. }
  1175. return ret;
  1176. }
  1177. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1178. struct snd_ctl_elem_value *ucontrol)
  1179. {
  1180. struct tdm_port port;
  1181. int ret = tdm_get_port_idx(kcontrol, &port);
  1182. if (ret) {
  1183. pr_err("%s: unsupported control: %s\n",
  1184. __func__, kcontrol->id.name);
  1185. } else {
  1186. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1187. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1188. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1189. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1190. ucontrol->value.enumerated.item[0]);
  1191. }
  1192. return ret;
  1193. }
  1194. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1195. struct snd_ctl_elem_value *ucontrol)
  1196. {
  1197. struct tdm_port port;
  1198. int ret = tdm_get_port_idx(kcontrol, &port);
  1199. if (ret) {
  1200. pr_err("%s: unsupported control: %s\n",
  1201. __func__, kcontrol->id.name);
  1202. } else {
  1203. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1204. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1205. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1206. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1207. ucontrol->value.enumerated.item[0]);
  1208. }
  1209. return ret;
  1210. }
  1211. static int tdm_get_format(int value)
  1212. {
  1213. int format = 0;
  1214. switch (value) {
  1215. case 0:
  1216. format = SNDRV_PCM_FORMAT_S16_LE;
  1217. break;
  1218. case 1:
  1219. format = SNDRV_PCM_FORMAT_S24_LE;
  1220. break;
  1221. case 2:
  1222. format = SNDRV_PCM_FORMAT_S32_LE;
  1223. break;
  1224. default:
  1225. format = SNDRV_PCM_FORMAT_S16_LE;
  1226. break;
  1227. }
  1228. return format;
  1229. }
  1230. static int tdm_get_format_val(int format)
  1231. {
  1232. int value = 0;
  1233. switch (format) {
  1234. case SNDRV_PCM_FORMAT_S16_LE:
  1235. value = 0;
  1236. break;
  1237. case SNDRV_PCM_FORMAT_S24_LE:
  1238. value = 1;
  1239. break;
  1240. case SNDRV_PCM_FORMAT_S32_LE:
  1241. value = 2;
  1242. break;
  1243. default:
  1244. value = 0;
  1245. break;
  1246. }
  1247. return value;
  1248. }
  1249. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1250. struct snd_ctl_elem_value *ucontrol)
  1251. {
  1252. struct tdm_port port;
  1253. int ret = tdm_get_port_idx(kcontrol, &port);
  1254. if (ret) {
  1255. pr_err("%s: unsupported control: %s\n",
  1256. __func__, kcontrol->id.name);
  1257. } else {
  1258. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1259. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1260. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1261. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1262. ucontrol->value.enumerated.item[0]);
  1263. }
  1264. return ret;
  1265. }
  1266. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1267. struct snd_ctl_elem_value *ucontrol)
  1268. {
  1269. struct tdm_port port;
  1270. int ret = tdm_get_port_idx(kcontrol, &port);
  1271. if (ret) {
  1272. pr_err("%s: unsupported control: %s\n",
  1273. __func__, kcontrol->id.name);
  1274. } else {
  1275. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1276. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1277. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1278. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1279. ucontrol->value.enumerated.item[0]);
  1280. }
  1281. return ret;
  1282. }
  1283. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1284. struct snd_ctl_elem_value *ucontrol)
  1285. {
  1286. struct tdm_port port;
  1287. int ret = tdm_get_port_idx(kcontrol, &port);
  1288. if (ret) {
  1289. pr_err("%s: unsupported control: %s\n",
  1290. __func__, kcontrol->id.name);
  1291. } else {
  1292. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1293. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1294. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1295. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1296. ucontrol->value.enumerated.item[0]);
  1297. }
  1298. return ret;
  1299. }
  1300. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1301. struct snd_ctl_elem_value *ucontrol)
  1302. {
  1303. struct tdm_port port;
  1304. int ret = tdm_get_port_idx(kcontrol, &port);
  1305. if (ret) {
  1306. pr_err("%s: unsupported control: %s\n",
  1307. __func__, kcontrol->id.name);
  1308. } else {
  1309. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1310. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1311. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1312. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1313. ucontrol->value.enumerated.item[0]);
  1314. }
  1315. return ret;
  1316. }
  1317. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1318. struct snd_ctl_elem_value *ucontrol)
  1319. {
  1320. struct tdm_port port;
  1321. int ret = tdm_get_port_idx(kcontrol, &port);
  1322. if (ret) {
  1323. pr_err("%s: unsupported control: %s\n",
  1324. __func__, kcontrol->id.name);
  1325. } else {
  1326. ucontrol->value.enumerated.item[0] =
  1327. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1328. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1329. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1330. ucontrol->value.enumerated.item[0]);
  1331. }
  1332. return ret;
  1333. }
  1334. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1335. struct snd_ctl_elem_value *ucontrol)
  1336. {
  1337. struct tdm_port port;
  1338. int ret = tdm_get_port_idx(kcontrol, &port);
  1339. if (ret) {
  1340. pr_err("%s: unsupported control: %s\n",
  1341. __func__, kcontrol->id.name);
  1342. } else {
  1343. tdm_rx_cfg[port.mode][port.channel].channels =
  1344. ucontrol->value.enumerated.item[0] + 1;
  1345. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1346. tdm_rx_cfg[port.mode][port.channel].channels,
  1347. ucontrol->value.enumerated.item[0] + 1);
  1348. }
  1349. return ret;
  1350. }
  1351. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1352. struct snd_ctl_elem_value *ucontrol)
  1353. {
  1354. struct tdm_port port;
  1355. int ret = tdm_get_port_idx(kcontrol, &port);
  1356. if (ret) {
  1357. pr_err("%s: unsupported control: %s\n",
  1358. __func__, kcontrol->id.name);
  1359. } else {
  1360. ucontrol->value.enumerated.item[0] =
  1361. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1362. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1363. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1364. ucontrol->value.enumerated.item[0]);
  1365. }
  1366. return ret;
  1367. }
  1368. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1369. struct snd_ctl_elem_value *ucontrol)
  1370. {
  1371. struct tdm_port port;
  1372. int ret = tdm_get_port_idx(kcontrol, &port);
  1373. if (ret) {
  1374. pr_err("%s: unsupported control: %s\n",
  1375. __func__, kcontrol->id.name);
  1376. } else {
  1377. tdm_tx_cfg[port.mode][port.channel].channels =
  1378. ucontrol->value.enumerated.item[0] + 1;
  1379. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1380. tdm_tx_cfg[port.mode][port.channel].channels,
  1381. ucontrol->value.enumerated.item[0] + 1);
  1382. }
  1383. return ret;
  1384. }
  1385. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1386. {
  1387. int idx = 0;
  1388. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1389. sizeof("PRIM_AUX_PCM"))) {
  1390. idx = PRIM_AUX_PCM;
  1391. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1392. sizeof("SEC_AUX_PCM"))) {
  1393. idx = SEC_AUX_PCM;
  1394. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1395. sizeof("TERT_AUX_PCM"))) {
  1396. idx = TERT_AUX_PCM;
  1397. } else {
  1398. pr_err("%s: unsupported port: %s\n",
  1399. __func__, kcontrol->id.name);
  1400. idx = -EINVAL;
  1401. }
  1402. return idx;
  1403. }
  1404. static int aux_pcm_get_sample_rate(int value)
  1405. {
  1406. int sample_rate = 0;
  1407. switch (value) {
  1408. case 1:
  1409. sample_rate = SAMPLING_RATE_16KHZ;
  1410. break;
  1411. case 0:
  1412. default:
  1413. sample_rate = SAMPLING_RATE_8KHZ;
  1414. break;
  1415. }
  1416. return sample_rate;
  1417. }
  1418. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1419. {
  1420. int sample_rate_val = 0;
  1421. switch (sample_rate) {
  1422. case SAMPLING_RATE_16KHZ:
  1423. sample_rate_val = 1;
  1424. break;
  1425. case SAMPLING_RATE_8KHZ:
  1426. default:
  1427. sample_rate_val = 0;
  1428. break;
  1429. }
  1430. return sample_rate_val;
  1431. }
  1432. static int mi2s_auxpcm_get_format(int value)
  1433. {
  1434. int format = 0;
  1435. switch (value) {
  1436. case 0:
  1437. format = SNDRV_PCM_FORMAT_S16_LE;
  1438. break;
  1439. case 1:
  1440. format = SNDRV_PCM_FORMAT_S24_LE;
  1441. break;
  1442. case 2:
  1443. format = SNDRV_PCM_FORMAT_S24_3LE;
  1444. break;
  1445. case 3:
  1446. format = SNDRV_PCM_FORMAT_S32_LE;
  1447. break;
  1448. default:
  1449. format = SNDRV_PCM_FORMAT_S16_LE;
  1450. break;
  1451. }
  1452. return format;
  1453. }
  1454. static int mi2s_auxpcm_get_format_value(int format)
  1455. {
  1456. int value = 0;
  1457. switch (format) {
  1458. case SNDRV_PCM_FORMAT_S16_LE:
  1459. value = 0;
  1460. break;
  1461. case SNDRV_PCM_FORMAT_S24_LE:
  1462. value = 1;
  1463. break;
  1464. case SNDRV_PCM_FORMAT_S24_3LE:
  1465. value = 2;
  1466. break;
  1467. case SNDRV_PCM_FORMAT_S32_LE:
  1468. value = 3;
  1469. break;
  1470. default:
  1471. value = 0;
  1472. break;
  1473. }
  1474. return value;
  1475. }
  1476. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1477. struct snd_ctl_elem_value *ucontrol)
  1478. {
  1479. int idx = aux_pcm_get_port_idx(kcontrol);
  1480. if (idx < 0)
  1481. return idx;
  1482. ucontrol->value.enumerated.item[0] =
  1483. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1484. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1485. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1486. ucontrol->value.enumerated.item[0]);
  1487. return 0;
  1488. }
  1489. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1490. struct snd_ctl_elem_value *ucontrol)
  1491. {
  1492. int idx = aux_pcm_get_port_idx(kcontrol);
  1493. if (idx < 0)
  1494. return idx;
  1495. aux_pcm_rx_cfg[idx].sample_rate =
  1496. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1497. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1498. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1499. ucontrol->value.enumerated.item[0]);
  1500. return 0;
  1501. }
  1502. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1503. struct snd_ctl_elem_value *ucontrol)
  1504. {
  1505. int idx = aux_pcm_get_port_idx(kcontrol);
  1506. if (idx < 0)
  1507. return idx;
  1508. ucontrol->value.enumerated.item[0] =
  1509. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1510. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1511. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1512. ucontrol->value.enumerated.item[0]);
  1513. return 0;
  1514. }
  1515. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1516. struct snd_ctl_elem_value *ucontrol)
  1517. {
  1518. int idx = aux_pcm_get_port_idx(kcontrol);
  1519. if (idx < 0)
  1520. return idx;
  1521. aux_pcm_tx_cfg[idx].sample_rate =
  1522. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1523. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1524. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1525. ucontrol->value.enumerated.item[0]);
  1526. return 0;
  1527. }
  1528. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1529. struct snd_ctl_elem_value *ucontrol)
  1530. {
  1531. int idx = aux_pcm_get_port_idx(kcontrol);
  1532. if (idx < 0)
  1533. return idx;
  1534. ucontrol->value.enumerated.item[0] =
  1535. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1536. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1537. idx, aux_pcm_rx_cfg[idx].bit_format,
  1538. ucontrol->value.enumerated.item[0]);
  1539. return 0;
  1540. }
  1541. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1542. struct snd_ctl_elem_value *ucontrol)
  1543. {
  1544. int idx = aux_pcm_get_port_idx(kcontrol);
  1545. if (idx < 0)
  1546. return idx;
  1547. aux_pcm_rx_cfg[idx].bit_format =
  1548. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1549. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1550. idx, aux_pcm_rx_cfg[idx].bit_format,
  1551. ucontrol->value.enumerated.item[0]);
  1552. return 0;
  1553. }
  1554. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1555. struct snd_ctl_elem_value *ucontrol)
  1556. {
  1557. int idx = aux_pcm_get_port_idx(kcontrol);
  1558. if (idx < 0)
  1559. return idx;
  1560. ucontrol->value.enumerated.item[0] =
  1561. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1562. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1563. idx, aux_pcm_tx_cfg[idx].bit_format,
  1564. ucontrol->value.enumerated.item[0]);
  1565. return 0;
  1566. }
  1567. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  1568. struct snd_ctl_elem_value *ucontrol)
  1569. {
  1570. int idx = aux_pcm_get_port_idx(kcontrol);
  1571. if (idx < 0)
  1572. return idx;
  1573. aux_pcm_tx_cfg[idx].bit_format =
  1574. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1575. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1576. idx, aux_pcm_tx_cfg[idx].bit_format,
  1577. ucontrol->value.enumerated.item[0]);
  1578. return 0;
  1579. }
  1580. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  1581. {
  1582. int idx = 0;
  1583. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  1584. sizeof("PRIM_MI2S_RX"))) {
  1585. idx = PRIM_MI2S;
  1586. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  1587. sizeof("SEC_MI2S_RX"))) {
  1588. idx = SEC_MI2S;
  1589. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  1590. sizeof("TERT_MI2S_RX"))) {
  1591. idx = TERT_MI2S;
  1592. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  1593. sizeof("PRIM_MI2S_TX"))) {
  1594. idx = PRIM_MI2S;
  1595. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  1596. sizeof("SEC_MI2S_TX"))) {
  1597. idx = SEC_MI2S;
  1598. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  1599. sizeof("TERT_MI2S_TX"))) {
  1600. idx = TERT_MI2S;
  1601. } else {
  1602. pr_err("%s: unsupported channel: %s\n",
  1603. __func__, kcontrol->id.name);
  1604. idx = -EINVAL;
  1605. }
  1606. return idx;
  1607. }
  1608. static int mi2s_get_sample_rate(int value)
  1609. {
  1610. int sample_rate = 0;
  1611. switch (value) {
  1612. case 0:
  1613. sample_rate = SAMPLING_RATE_8KHZ;
  1614. break;
  1615. case 1:
  1616. sample_rate = SAMPLING_RATE_11P025KHZ;
  1617. break;
  1618. case 2:
  1619. sample_rate = SAMPLING_RATE_16KHZ;
  1620. break;
  1621. case 3:
  1622. sample_rate = SAMPLING_RATE_22P05KHZ;
  1623. break;
  1624. case 4:
  1625. sample_rate = SAMPLING_RATE_32KHZ;
  1626. break;
  1627. case 5:
  1628. sample_rate = SAMPLING_RATE_44P1KHZ;
  1629. break;
  1630. case 6:
  1631. sample_rate = SAMPLING_RATE_48KHZ;
  1632. break;
  1633. case 7:
  1634. sample_rate = SAMPLING_RATE_96KHZ;
  1635. break;
  1636. case 8:
  1637. sample_rate = SAMPLING_RATE_192KHZ;
  1638. break;
  1639. default:
  1640. sample_rate = SAMPLING_RATE_48KHZ;
  1641. break;
  1642. }
  1643. return sample_rate;
  1644. }
  1645. static int mi2s_get_sample_rate_val(int sample_rate)
  1646. {
  1647. int sample_rate_val = 0;
  1648. switch (sample_rate) {
  1649. case SAMPLING_RATE_8KHZ:
  1650. sample_rate_val = 0;
  1651. break;
  1652. case SAMPLING_RATE_11P025KHZ:
  1653. sample_rate_val = 1;
  1654. break;
  1655. case SAMPLING_RATE_16KHZ:
  1656. sample_rate_val = 2;
  1657. break;
  1658. case SAMPLING_RATE_22P05KHZ:
  1659. sample_rate_val = 3;
  1660. break;
  1661. case SAMPLING_RATE_32KHZ:
  1662. sample_rate_val = 4;
  1663. break;
  1664. case SAMPLING_RATE_44P1KHZ:
  1665. sample_rate_val = 5;
  1666. break;
  1667. case SAMPLING_RATE_48KHZ:
  1668. sample_rate_val = 6;
  1669. break;
  1670. case SAMPLING_RATE_96KHZ:
  1671. sample_rate_val = 7;
  1672. break;
  1673. case SAMPLING_RATE_192KHZ:
  1674. sample_rate_val = 8;
  1675. break;
  1676. default:
  1677. sample_rate_val = 6;
  1678. break;
  1679. }
  1680. return sample_rate_val;
  1681. }
  1682. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1683. struct snd_ctl_elem_value *ucontrol)
  1684. {
  1685. int idx = mi2s_get_port_idx(kcontrol);
  1686. if (idx < 0)
  1687. return idx;
  1688. ucontrol->value.enumerated.item[0] =
  1689. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  1690. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1691. idx, mi2s_rx_cfg[idx].sample_rate,
  1692. ucontrol->value.enumerated.item[0]);
  1693. return 0;
  1694. }
  1695. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1696. struct snd_ctl_elem_value *ucontrol)
  1697. {
  1698. int idx = mi2s_get_port_idx(kcontrol);
  1699. if (idx < 0)
  1700. return idx;
  1701. mi2s_rx_cfg[idx].sample_rate =
  1702. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1703. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1704. idx, mi2s_rx_cfg[idx].sample_rate,
  1705. ucontrol->value.enumerated.item[0]);
  1706. return 0;
  1707. }
  1708. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1709. struct snd_ctl_elem_value *ucontrol)
  1710. {
  1711. int idx = mi2s_get_port_idx(kcontrol);
  1712. if (idx < 0)
  1713. return idx;
  1714. ucontrol->value.enumerated.item[0] =
  1715. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  1716. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1717. idx, mi2s_tx_cfg[idx].sample_rate,
  1718. ucontrol->value.enumerated.item[0]);
  1719. return 0;
  1720. }
  1721. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1722. struct snd_ctl_elem_value *ucontrol)
  1723. {
  1724. int idx = mi2s_get_port_idx(kcontrol);
  1725. if (idx < 0)
  1726. return idx;
  1727. mi2s_tx_cfg[idx].sample_rate =
  1728. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1729. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1730. idx, mi2s_tx_cfg[idx].sample_rate,
  1731. ucontrol->value.enumerated.item[0]);
  1732. return 0;
  1733. }
  1734. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  1735. struct snd_ctl_elem_value *ucontrol)
  1736. {
  1737. int idx = mi2s_get_port_idx(kcontrol);
  1738. if (idx < 0)
  1739. return idx;
  1740. ucontrol->value.enumerated.item[0] =
  1741. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  1742. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1743. idx, mi2s_rx_cfg[idx].bit_format,
  1744. ucontrol->value.enumerated.item[0]);
  1745. return 0;
  1746. }
  1747. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  1748. struct snd_ctl_elem_value *ucontrol)
  1749. {
  1750. int idx = mi2s_get_port_idx(kcontrol);
  1751. if (idx < 0)
  1752. return idx;
  1753. mi2s_rx_cfg[idx].bit_format =
  1754. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1755. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1756. idx, mi2s_rx_cfg[idx].bit_format,
  1757. ucontrol->value.enumerated.item[0]);
  1758. return 0;
  1759. }
  1760. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  1761. struct snd_ctl_elem_value *ucontrol)
  1762. {
  1763. int idx = mi2s_get_port_idx(kcontrol);
  1764. if (idx < 0)
  1765. return idx;
  1766. ucontrol->value.enumerated.item[0] =
  1767. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  1768. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1769. idx, mi2s_tx_cfg[idx].bit_format,
  1770. ucontrol->value.enumerated.item[0]);
  1771. return 0;
  1772. }
  1773. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  1774. struct snd_ctl_elem_value *ucontrol)
  1775. {
  1776. int idx = mi2s_get_port_idx(kcontrol);
  1777. if (idx < 0)
  1778. return idx;
  1779. mi2s_tx_cfg[idx].bit_format =
  1780. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1781. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1782. idx, mi2s_tx_cfg[idx].bit_format,
  1783. ucontrol->value.enumerated.item[0]);
  1784. return 0;
  1785. }
  1786. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  1787. struct snd_ctl_elem_value *ucontrol)
  1788. {
  1789. int idx = mi2s_get_port_idx(kcontrol);
  1790. if (idx < 0)
  1791. return idx;
  1792. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1793. idx, mi2s_rx_cfg[idx].channels);
  1794. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  1795. return 0;
  1796. }
  1797. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  1798. struct snd_ctl_elem_value *ucontrol)
  1799. {
  1800. int idx = mi2s_get_port_idx(kcontrol);
  1801. if (idx < 0)
  1802. return idx;
  1803. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1804. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1805. idx, mi2s_rx_cfg[idx].channels);
  1806. return 1;
  1807. }
  1808. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. int idx = mi2s_get_port_idx(kcontrol);
  1812. if (idx < 0)
  1813. return idx;
  1814. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1815. idx, mi2s_tx_cfg[idx].channels);
  1816. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  1817. return 0;
  1818. }
  1819. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  1820. struct snd_ctl_elem_value *ucontrol)
  1821. {
  1822. int idx = mi2s_get_port_idx(kcontrol);
  1823. if (idx < 0)
  1824. return idx;
  1825. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1826. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1827. idx, mi2s_tx_cfg[idx].channels);
  1828. return 1;
  1829. }
  1830. static int msm_get_port_id(int be_id)
  1831. {
  1832. int afe_port_id = 0;
  1833. switch (be_id) {
  1834. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  1835. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  1836. break;
  1837. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  1838. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  1839. break;
  1840. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  1841. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  1842. break;
  1843. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  1844. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  1845. break;
  1846. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  1847. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  1848. break;
  1849. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  1850. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  1851. break;
  1852. default:
  1853. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  1854. afe_port_id = -EINVAL;
  1855. }
  1856. return afe_port_id;
  1857. }
  1858. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  1859. {
  1860. u32 bit_per_sample = 0;
  1861. switch (bit_format) {
  1862. case SNDRV_PCM_FORMAT_S32_LE:
  1863. case SNDRV_PCM_FORMAT_S24_3LE:
  1864. case SNDRV_PCM_FORMAT_S24_LE:
  1865. bit_per_sample = 32;
  1866. break;
  1867. case SNDRV_PCM_FORMAT_S16_LE:
  1868. default:
  1869. bit_per_sample = 16;
  1870. break;
  1871. }
  1872. return bit_per_sample;
  1873. }
  1874. static void update_mi2s_clk_val(int dai_id, int stream)
  1875. {
  1876. u32 bit_per_sample = 0;
  1877. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1878. bit_per_sample =
  1879. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  1880. mi2s_clk[dai_id].clk_freq_in_hz =
  1881. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1882. } else {
  1883. bit_per_sample =
  1884. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  1885. mi2s_clk[dai_id].clk_freq_in_hz =
  1886. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1887. }
  1888. }
  1889. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  1890. {
  1891. int ret = 0;
  1892. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1893. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1894. int port_id = 0;
  1895. int index = cpu_dai->id;
  1896. port_id = msm_get_port_id(rtd->dai_link->id);
  1897. if (port_id < 0) {
  1898. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  1899. ret = port_id;
  1900. goto err;
  1901. }
  1902. if (enable) {
  1903. update_mi2s_clk_val(index, substream->stream);
  1904. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  1905. mi2s_clk[index].clk_freq_in_hz);
  1906. }
  1907. mi2s_clk[index].enable = enable;
  1908. ret = afe_set_lpass_clock_v2(port_id,
  1909. &mi2s_clk[index]);
  1910. if (ret < 0) {
  1911. dev_err(rtd->card->dev,
  1912. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  1913. __func__, port_id, ret);
  1914. goto err;
  1915. }
  1916. err:
  1917. return ret;
  1918. }
  1919. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1920. {
  1921. int idx = 0;
  1922. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1923. sizeof("WSA_CDC_DMA_RX_0")))
  1924. idx = WSA_CDC_DMA_RX_0;
  1925. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1926. sizeof("WSA_CDC_DMA_RX_0")))
  1927. idx = WSA_CDC_DMA_RX_1;
  1928. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  1929. sizeof("RX_CDC_DMA_RX_0")))
  1930. idx = RX_CDC_DMA_RX_0;
  1931. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  1932. sizeof("RX_CDC_DMA_RX_1")))
  1933. idx = RX_CDC_DMA_RX_1;
  1934. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  1935. sizeof("RX_CDC_DMA_RX_2")))
  1936. idx = RX_CDC_DMA_RX_2;
  1937. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  1938. sizeof("RX_CDC_DMA_RX_3")))
  1939. idx = RX_CDC_DMA_RX_3;
  1940. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  1941. sizeof("RX_CDC_DMA_RX_5")))
  1942. idx = RX_CDC_DMA_RX_5;
  1943. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1944. sizeof("WSA_CDC_DMA_TX_0")))
  1945. idx = WSA_CDC_DMA_TX_0;
  1946. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1947. sizeof("WSA_CDC_DMA_TX_1")))
  1948. idx = WSA_CDC_DMA_TX_1;
  1949. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1950. sizeof("WSA_CDC_DMA_TX_2")))
  1951. idx = WSA_CDC_DMA_TX_2;
  1952. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  1953. sizeof("TX_CDC_DMA_TX_0")))
  1954. idx = TX_CDC_DMA_TX_0;
  1955. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  1956. sizeof("TX_CDC_DMA_TX_3")))
  1957. idx = TX_CDC_DMA_TX_3;
  1958. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  1959. sizeof("TX_CDC_DMA_TX_4")))
  1960. idx = TX_CDC_DMA_TX_4;
  1961. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  1962. sizeof("VA_CDC_DMA_TX_0")))
  1963. idx = VA_CDC_DMA_TX_0;
  1964. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  1965. sizeof("VA_CDC_DMA_TX_1")))
  1966. idx = VA_CDC_DMA_TX_1;
  1967. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  1968. sizeof("VA_CDC_DMA_TX_2")))
  1969. idx = VA_CDC_DMA_TX_2;
  1970. else {
  1971. pr_err("%s: unsupported channel: %s\n",
  1972. __func__, kcontrol->id.name);
  1973. return -EINVAL;
  1974. }
  1975. return idx;
  1976. }
  1977. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1978. struct snd_ctl_elem_value *ucontrol)
  1979. {
  1980. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1981. if (ch_num < 0) {
  1982. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1983. return ch_num;
  1984. }
  1985. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1986. cdc_dma_rx_cfg[ch_num].channels - 1);
  1987. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1988. return 0;
  1989. }
  1990. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1991. struct snd_ctl_elem_value *ucontrol)
  1992. {
  1993. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1994. if (ch_num < 0) {
  1995. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1996. return ch_num;
  1997. }
  1998. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1999. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2000. cdc_dma_rx_cfg[ch_num].channels);
  2001. return 1;
  2002. }
  2003. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2004. struct snd_ctl_elem_value *ucontrol)
  2005. {
  2006. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2007. if (ch_num < 0) {
  2008. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2009. return ch_num;
  2010. }
  2011. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2012. case SNDRV_PCM_FORMAT_S32_LE:
  2013. ucontrol->value.integer.value[0] = 3;
  2014. break;
  2015. case SNDRV_PCM_FORMAT_S24_3LE:
  2016. ucontrol->value.integer.value[0] = 2;
  2017. break;
  2018. case SNDRV_PCM_FORMAT_S24_LE:
  2019. ucontrol->value.integer.value[0] = 1;
  2020. break;
  2021. case SNDRV_PCM_FORMAT_S16_LE:
  2022. default:
  2023. ucontrol->value.integer.value[0] = 0;
  2024. break;
  2025. }
  2026. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2027. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2028. ucontrol->value.integer.value[0]);
  2029. return 0;
  2030. }
  2031. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2032. struct snd_ctl_elem_value *ucontrol)
  2033. {
  2034. int rc = 0;
  2035. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2036. if (ch_num < 0) {
  2037. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2038. return ch_num;
  2039. }
  2040. switch (ucontrol->value.integer.value[0]) {
  2041. case 3:
  2042. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2043. break;
  2044. case 2:
  2045. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2046. break;
  2047. case 1:
  2048. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2049. break;
  2050. case 0:
  2051. default:
  2052. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2053. break;
  2054. }
  2055. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2056. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2057. ucontrol->value.integer.value[0]);
  2058. return rc;
  2059. }
  2060. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2061. {
  2062. int sample_rate_val = 0;
  2063. switch (sample_rate) {
  2064. case SAMPLING_RATE_8KHZ:
  2065. sample_rate_val = 0;
  2066. break;
  2067. case SAMPLING_RATE_11P025KHZ:
  2068. sample_rate_val = 1;
  2069. break;
  2070. case SAMPLING_RATE_16KHZ:
  2071. sample_rate_val = 2;
  2072. break;
  2073. case SAMPLING_RATE_22P05KHZ:
  2074. sample_rate_val = 3;
  2075. break;
  2076. case SAMPLING_RATE_32KHZ:
  2077. sample_rate_val = 4;
  2078. break;
  2079. case SAMPLING_RATE_44P1KHZ:
  2080. sample_rate_val = 5;
  2081. break;
  2082. case SAMPLING_RATE_48KHZ:
  2083. sample_rate_val = 6;
  2084. break;
  2085. case SAMPLING_RATE_88P2KHZ:
  2086. sample_rate_val = 7;
  2087. break;
  2088. case SAMPLING_RATE_96KHZ:
  2089. sample_rate_val = 8;
  2090. break;
  2091. case SAMPLING_RATE_176P4KHZ:
  2092. sample_rate_val = 9;
  2093. break;
  2094. case SAMPLING_RATE_192KHZ:
  2095. sample_rate_val = 10;
  2096. break;
  2097. case SAMPLING_RATE_352P8KHZ:
  2098. sample_rate_val = 11;
  2099. break;
  2100. case SAMPLING_RATE_384KHZ:
  2101. sample_rate_val = 12;
  2102. break;
  2103. default:
  2104. sample_rate_val = 6;
  2105. break;
  2106. }
  2107. return sample_rate_val;
  2108. }
  2109. static int cdc_dma_get_sample_rate(int value)
  2110. {
  2111. int sample_rate = 0;
  2112. switch (value) {
  2113. case 0:
  2114. sample_rate = SAMPLING_RATE_8KHZ;
  2115. break;
  2116. case 1:
  2117. sample_rate = SAMPLING_RATE_11P025KHZ;
  2118. break;
  2119. case 2:
  2120. sample_rate = SAMPLING_RATE_16KHZ;
  2121. break;
  2122. case 3:
  2123. sample_rate = SAMPLING_RATE_22P05KHZ;
  2124. break;
  2125. case 4:
  2126. sample_rate = SAMPLING_RATE_32KHZ;
  2127. break;
  2128. case 5:
  2129. sample_rate = SAMPLING_RATE_44P1KHZ;
  2130. break;
  2131. case 6:
  2132. sample_rate = SAMPLING_RATE_48KHZ;
  2133. break;
  2134. case 7:
  2135. sample_rate = SAMPLING_RATE_88P2KHZ;
  2136. break;
  2137. case 8:
  2138. sample_rate = SAMPLING_RATE_96KHZ;
  2139. break;
  2140. case 9:
  2141. sample_rate = SAMPLING_RATE_176P4KHZ;
  2142. break;
  2143. case 10:
  2144. sample_rate = SAMPLING_RATE_192KHZ;
  2145. break;
  2146. case 11:
  2147. sample_rate = SAMPLING_RATE_352P8KHZ;
  2148. break;
  2149. case 12:
  2150. sample_rate = SAMPLING_RATE_384KHZ;
  2151. break;
  2152. default:
  2153. sample_rate = SAMPLING_RATE_48KHZ;
  2154. break;
  2155. }
  2156. return sample_rate;
  2157. }
  2158. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2162. if (ch_num < 0) {
  2163. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2164. return ch_num;
  2165. }
  2166. ucontrol->value.enumerated.item[0] =
  2167. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2168. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2169. cdc_dma_rx_cfg[ch_num].sample_rate);
  2170. return 0;
  2171. }
  2172. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2173. struct snd_ctl_elem_value *ucontrol)
  2174. {
  2175. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2176. if (ch_num < 0) {
  2177. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2178. return ch_num;
  2179. }
  2180. cdc_dma_rx_cfg[ch_num].sample_rate =
  2181. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2182. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2183. __func__, ucontrol->value.enumerated.item[0],
  2184. cdc_dma_rx_cfg[ch_num].sample_rate);
  2185. return 0;
  2186. }
  2187. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2188. struct snd_ctl_elem_value *ucontrol)
  2189. {
  2190. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2191. if (ch_num < 0) {
  2192. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2193. return ch_num;
  2194. }
  2195. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2196. cdc_dma_tx_cfg[ch_num].channels);
  2197. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2198. return 0;
  2199. }
  2200. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2201. struct snd_ctl_elem_value *ucontrol)
  2202. {
  2203. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2204. if (ch_num < 0) {
  2205. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2206. return ch_num;
  2207. }
  2208. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2209. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2210. cdc_dma_tx_cfg[ch_num].channels);
  2211. return 1;
  2212. }
  2213. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2214. struct snd_ctl_elem_value *ucontrol)
  2215. {
  2216. int sample_rate_val;
  2217. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2218. if (ch_num < 0) {
  2219. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2220. return ch_num;
  2221. }
  2222. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2223. case SAMPLING_RATE_384KHZ:
  2224. sample_rate_val = 12;
  2225. break;
  2226. case SAMPLING_RATE_352P8KHZ:
  2227. sample_rate_val = 11;
  2228. break;
  2229. case SAMPLING_RATE_192KHZ:
  2230. sample_rate_val = 10;
  2231. break;
  2232. case SAMPLING_RATE_176P4KHZ:
  2233. sample_rate_val = 9;
  2234. break;
  2235. case SAMPLING_RATE_96KHZ:
  2236. sample_rate_val = 8;
  2237. break;
  2238. case SAMPLING_RATE_88P2KHZ:
  2239. sample_rate_val = 7;
  2240. break;
  2241. case SAMPLING_RATE_48KHZ:
  2242. sample_rate_val = 6;
  2243. break;
  2244. case SAMPLING_RATE_44P1KHZ:
  2245. sample_rate_val = 5;
  2246. break;
  2247. case SAMPLING_RATE_32KHZ:
  2248. sample_rate_val = 4;
  2249. break;
  2250. case SAMPLING_RATE_22P05KHZ:
  2251. sample_rate_val = 3;
  2252. break;
  2253. case SAMPLING_RATE_16KHZ:
  2254. sample_rate_val = 2;
  2255. break;
  2256. case SAMPLING_RATE_11P025KHZ:
  2257. sample_rate_val = 1;
  2258. break;
  2259. case SAMPLING_RATE_8KHZ:
  2260. sample_rate_val = 0;
  2261. break;
  2262. default:
  2263. sample_rate_val = 6;
  2264. break;
  2265. }
  2266. ucontrol->value.integer.value[0] = sample_rate_val;
  2267. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2268. cdc_dma_tx_cfg[ch_num].sample_rate);
  2269. return 0;
  2270. }
  2271. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2272. struct snd_ctl_elem_value *ucontrol)
  2273. {
  2274. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2275. if (ch_num < 0) {
  2276. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2277. return ch_num;
  2278. }
  2279. switch (ucontrol->value.integer.value[0]) {
  2280. case 12:
  2281. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2282. break;
  2283. case 11:
  2284. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2285. break;
  2286. case 10:
  2287. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2288. break;
  2289. case 9:
  2290. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2291. break;
  2292. case 8:
  2293. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2294. break;
  2295. case 7:
  2296. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2297. break;
  2298. case 6:
  2299. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2300. break;
  2301. case 5:
  2302. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2303. break;
  2304. case 4:
  2305. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2306. break;
  2307. case 3:
  2308. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2309. break;
  2310. case 2:
  2311. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2312. break;
  2313. case 1:
  2314. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2315. break;
  2316. case 0:
  2317. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2318. break;
  2319. default:
  2320. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2321. break;
  2322. }
  2323. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2324. __func__, ucontrol->value.integer.value[0],
  2325. cdc_dma_tx_cfg[ch_num].sample_rate);
  2326. return 0;
  2327. }
  2328. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2329. struct snd_ctl_elem_value *ucontrol)
  2330. {
  2331. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2332. if (ch_num < 0) {
  2333. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2334. return ch_num;
  2335. }
  2336. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2337. case SNDRV_PCM_FORMAT_S32_LE:
  2338. ucontrol->value.integer.value[0] = 3;
  2339. break;
  2340. case SNDRV_PCM_FORMAT_S24_3LE:
  2341. ucontrol->value.integer.value[0] = 2;
  2342. break;
  2343. case SNDRV_PCM_FORMAT_S24_LE:
  2344. ucontrol->value.integer.value[0] = 1;
  2345. break;
  2346. case SNDRV_PCM_FORMAT_S16_LE:
  2347. default:
  2348. ucontrol->value.integer.value[0] = 0;
  2349. break;
  2350. }
  2351. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2352. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2353. ucontrol->value.integer.value[0]);
  2354. return 0;
  2355. }
  2356. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2357. struct snd_ctl_elem_value *ucontrol)
  2358. {
  2359. int rc = 0;
  2360. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2361. if (ch_num < 0) {
  2362. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2363. return ch_num;
  2364. }
  2365. switch (ucontrol->value.integer.value[0]) {
  2366. case 3:
  2367. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2368. break;
  2369. case 2:
  2370. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2371. break;
  2372. case 1:
  2373. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2374. break;
  2375. case 0:
  2376. default:
  2377. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2378. break;
  2379. }
  2380. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2381. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2382. ucontrol->value.integer.value[0]);
  2383. return rc;
  2384. }
  2385. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2386. {
  2387. int idx = 0;
  2388. switch (be_id) {
  2389. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2390. idx = WSA_CDC_DMA_RX_0;
  2391. break;
  2392. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2393. idx = WSA_CDC_DMA_TX_0;
  2394. break;
  2395. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2396. idx = WSA_CDC_DMA_RX_1;
  2397. break;
  2398. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2399. idx = WSA_CDC_DMA_TX_1;
  2400. break;
  2401. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2402. idx = WSA_CDC_DMA_TX_2;
  2403. break;
  2404. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2405. idx = RX_CDC_DMA_RX_0;
  2406. break;
  2407. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2408. idx = RX_CDC_DMA_RX_1;
  2409. break;
  2410. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2411. idx = RX_CDC_DMA_RX_2;
  2412. break;
  2413. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2414. idx = RX_CDC_DMA_RX_3;
  2415. break;
  2416. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2417. idx = RX_CDC_DMA_RX_5;
  2418. break;
  2419. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2420. idx = TX_CDC_DMA_TX_0;
  2421. break;
  2422. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2423. idx = TX_CDC_DMA_TX_3;
  2424. break;
  2425. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2426. idx = TX_CDC_DMA_TX_4;
  2427. break;
  2428. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2429. idx = VA_CDC_DMA_TX_0;
  2430. break;
  2431. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2432. idx = VA_CDC_DMA_TX_1;
  2433. break;
  2434. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2435. idx = VA_CDC_DMA_TX_2;
  2436. break;
  2437. default:
  2438. idx = RX_CDC_DMA_RX_0;
  2439. break;
  2440. }
  2441. return idx;
  2442. }
  2443. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  2444. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  2445. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2446. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  2447. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2448. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  2449. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2450. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  2451. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2452. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  2453. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2454. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  2455. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2456. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  2457. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2458. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  2459. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2460. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  2461. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2462. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  2463. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2464. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  2465. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2466. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  2467. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2468. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  2469. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2470. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  2471. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2472. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  2473. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2474. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  2475. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2476. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  2477. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2478. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  2479. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2480. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  2481. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2482. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  2483. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2484. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  2485. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2486. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  2487. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2488. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  2489. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2490. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  2491. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2492. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  2493. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2494. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  2495. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2496. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  2497. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2498. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  2499. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2500. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  2501. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2502. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  2503. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2504. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  2505. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2506. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  2507. wsa_cdc_dma_rx_0_sample_rate,
  2508. cdc_dma_rx_sample_rate_get,
  2509. cdc_dma_rx_sample_rate_put),
  2510. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  2511. wsa_cdc_dma_rx_1_sample_rate,
  2512. cdc_dma_rx_sample_rate_get,
  2513. cdc_dma_rx_sample_rate_put),
  2514. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  2515. rx_cdc_dma_rx_0_sample_rate,
  2516. cdc_dma_rx_sample_rate_get,
  2517. cdc_dma_rx_sample_rate_put),
  2518. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  2519. rx_cdc_dma_rx_1_sample_rate,
  2520. cdc_dma_rx_sample_rate_get,
  2521. cdc_dma_rx_sample_rate_put),
  2522. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  2523. rx_cdc_dma_rx_2_sample_rate,
  2524. cdc_dma_rx_sample_rate_get,
  2525. cdc_dma_rx_sample_rate_put),
  2526. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  2527. rx_cdc_dma_rx_3_sample_rate,
  2528. cdc_dma_rx_sample_rate_get,
  2529. cdc_dma_rx_sample_rate_put),
  2530. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  2531. rx_cdc_dma_rx_5_sample_rate,
  2532. cdc_dma_rx_sample_rate_get,
  2533. cdc_dma_rx_sample_rate_put),
  2534. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  2535. wsa_cdc_dma_tx_0_sample_rate,
  2536. cdc_dma_tx_sample_rate_get,
  2537. cdc_dma_tx_sample_rate_put),
  2538. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  2539. wsa_cdc_dma_tx_1_sample_rate,
  2540. cdc_dma_tx_sample_rate_get,
  2541. cdc_dma_tx_sample_rate_put),
  2542. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  2543. wsa_cdc_dma_tx_2_sample_rate,
  2544. cdc_dma_tx_sample_rate_get,
  2545. cdc_dma_tx_sample_rate_put),
  2546. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  2547. tx_cdc_dma_tx_0_sample_rate,
  2548. cdc_dma_tx_sample_rate_get,
  2549. cdc_dma_tx_sample_rate_put),
  2550. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  2551. tx_cdc_dma_tx_3_sample_rate,
  2552. cdc_dma_tx_sample_rate_get,
  2553. cdc_dma_tx_sample_rate_put),
  2554. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  2555. tx_cdc_dma_tx_4_sample_rate,
  2556. cdc_dma_tx_sample_rate_get,
  2557. cdc_dma_tx_sample_rate_put),
  2558. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  2559. va_cdc_dma_tx_0_sample_rate,
  2560. cdc_dma_tx_sample_rate_get,
  2561. cdc_dma_tx_sample_rate_put),
  2562. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  2563. va_cdc_dma_tx_1_sample_rate,
  2564. cdc_dma_tx_sample_rate_get,
  2565. cdc_dma_tx_sample_rate_put),
  2566. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  2567. va_cdc_dma_tx_2_sample_rate,
  2568. cdc_dma_tx_sample_rate_get,
  2569. cdc_dma_tx_sample_rate_put),
  2570. };
  2571. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  2572. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  2573. usb_audio_rx_sample_rate_get,
  2574. usb_audio_rx_sample_rate_put),
  2575. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  2576. usb_audio_tx_sample_rate_get,
  2577. usb_audio_tx_sample_rate_put),
  2578. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2579. tdm_rx_sample_rate_get,
  2580. tdm_rx_sample_rate_put),
  2581. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2582. tdm_rx_sample_rate_get,
  2583. tdm_rx_sample_rate_put),
  2584. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2585. tdm_rx_sample_rate_get,
  2586. tdm_rx_sample_rate_put),
  2587. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2588. tdm_tx_sample_rate_get,
  2589. tdm_tx_sample_rate_put),
  2590. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2591. tdm_tx_sample_rate_get,
  2592. tdm_tx_sample_rate_put),
  2593. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2594. tdm_tx_sample_rate_get,
  2595. tdm_tx_sample_rate_put),
  2596. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2597. aux_pcm_rx_sample_rate_get,
  2598. aux_pcm_rx_sample_rate_put),
  2599. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  2600. aux_pcm_rx_sample_rate_get,
  2601. aux_pcm_rx_sample_rate_put),
  2602. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  2603. aux_pcm_rx_sample_rate_get,
  2604. aux_pcm_rx_sample_rate_put),
  2605. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2606. aux_pcm_tx_sample_rate_get,
  2607. aux_pcm_tx_sample_rate_put),
  2608. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  2609. aux_pcm_tx_sample_rate_get,
  2610. aux_pcm_tx_sample_rate_put),
  2611. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  2612. aux_pcm_tx_sample_rate_get,
  2613. aux_pcm_tx_sample_rate_put),
  2614. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  2615. mi2s_rx_sample_rate_get,
  2616. mi2s_rx_sample_rate_put),
  2617. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  2618. mi2s_rx_sample_rate_get,
  2619. mi2s_rx_sample_rate_put),
  2620. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  2621. mi2s_rx_sample_rate_get,
  2622. mi2s_rx_sample_rate_put),
  2623. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  2624. mi2s_tx_sample_rate_get,
  2625. mi2s_tx_sample_rate_put),
  2626. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  2627. mi2s_tx_sample_rate_get,
  2628. mi2s_tx_sample_rate_put),
  2629. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  2630. mi2s_tx_sample_rate_get,
  2631. mi2s_tx_sample_rate_put),
  2632. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  2633. usb_audio_rx_format_get, usb_audio_rx_format_put),
  2634. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  2635. usb_audio_tx_format_get, usb_audio_tx_format_put),
  2636. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  2637. tdm_rx_format_get,
  2638. tdm_rx_format_put),
  2639. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  2640. tdm_rx_format_get,
  2641. tdm_rx_format_put),
  2642. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  2643. tdm_rx_format_get,
  2644. tdm_rx_format_put),
  2645. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  2646. tdm_tx_format_get,
  2647. tdm_tx_format_put),
  2648. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  2649. tdm_tx_format_get,
  2650. tdm_tx_format_put),
  2651. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  2652. tdm_tx_format_get,
  2653. tdm_tx_format_put),
  2654. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2655. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2656. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  2657. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2658. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2659. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2660. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2661. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2662. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  2663. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2664. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2665. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2666. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  2667. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2668. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  2669. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2670. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  2671. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2672. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  2673. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2674. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  2675. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2676. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  2677. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2678. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  2679. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  2680. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  2681. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  2682. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  2683. proxy_rx_ch_get, proxy_rx_ch_put),
  2684. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  2685. tdm_rx_ch_get,
  2686. tdm_rx_ch_put),
  2687. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  2688. tdm_rx_ch_get,
  2689. tdm_rx_ch_put),
  2690. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  2691. tdm_rx_ch_get,
  2692. tdm_rx_ch_put),
  2693. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  2694. tdm_tx_ch_get,
  2695. tdm_tx_ch_put),
  2696. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  2697. tdm_tx_ch_get,
  2698. tdm_tx_ch_put),
  2699. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  2700. tdm_tx_ch_get,
  2701. tdm_tx_ch_put),
  2702. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  2703. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2704. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  2705. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2706. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  2707. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2708. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  2709. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2710. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  2711. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2712. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  2713. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2714. };
  2715. static const struct snd_kcontrol_new msm_snd_controls[] = {
  2716. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  2717. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  2718. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2719. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2720. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2721. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2722. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  2723. ext_disp_rx_format_get, ext_disp_rx_format_put),
  2724. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2725. aux_pcm_rx_sample_rate_get,
  2726. aux_pcm_rx_sample_rate_put),
  2727. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2728. aux_pcm_tx_sample_rate_get,
  2729. aux_pcm_tx_sample_rate_put),
  2730. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  2731. ext_disp_rx_sample_rate_get,
  2732. ext_disp_rx_sample_rate_put),
  2733. };
  2734. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  2735. {
  2736. int idx;
  2737. switch (be_id) {
  2738. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2739. idx = EXT_DISP_RX_IDX_DP;
  2740. break;
  2741. default:
  2742. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  2743. idx = -EINVAL;
  2744. break;
  2745. }
  2746. return idx;
  2747. }
  2748. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  2749. struct snd_pcm_hw_params *params)
  2750. {
  2751. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  2752. struct snd_interval *rate = hw_param_interval(params,
  2753. SNDRV_PCM_HW_PARAM_RATE);
  2754. struct snd_interval *channels = hw_param_interval(params,
  2755. SNDRV_PCM_HW_PARAM_CHANNELS);
  2756. int idx, rc = 0;
  2757. pr_debug("%s: format = %d, rate = %d\n",
  2758. __func__, params_format(params), params_rate(params));
  2759. switch (dai_link->id) {
  2760. case MSM_BACKEND_DAI_USB_RX:
  2761. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2762. usb_rx_cfg.bit_format);
  2763. rate->min = rate->max = usb_rx_cfg.sample_rate;
  2764. channels->min = channels->max = usb_rx_cfg.channels;
  2765. break;
  2766. case MSM_BACKEND_DAI_USB_TX:
  2767. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2768. usb_tx_cfg.bit_format);
  2769. rate->min = rate->max = usb_tx_cfg.sample_rate;
  2770. channels->min = channels->max = usb_tx_cfg.channels;
  2771. break;
  2772. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2773. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  2774. if (idx < 0) {
  2775. pr_err("%s: Incorrect ext disp idx %d\n",
  2776. __func__, idx);
  2777. rc = idx;
  2778. goto done;
  2779. }
  2780. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2781. ext_disp_rx_cfg[idx].bit_format);
  2782. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  2783. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  2784. break;
  2785. case MSM_BACKEND_DAI_AFE_PCM_RX:
  2786. channels->min = channels->max = proxy_rx_cfg.channels;
  2787. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  2788. break;
  2789. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  2790. channels->min = channels->max =
  2791. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2792. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2793. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  2794. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  2795. break;
  2796. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  2797. channels->min = channels->max =
  2798. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  2799. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2800. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  2801. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  2802. break;
  2803. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  2804. channels->min = channels->max =
  2805. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2806. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2807. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  2808. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  2809. break;
  2810. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  2811. channels->min = channels->max =
  2812. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  2813. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2814. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  2815. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  2816. break;
  2817. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  2818. channels->min = channels->max =
  2819. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2820. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2821. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  2822. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  2823. break;
  2824. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  2825. channels->min = channels->max =
  2826. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  2827. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2828. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  2829. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  2830. break;
  2831. case MSM_BACKEND_DAI_AUXPCM_RX:
  2832. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2833. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  2834. rate->min = rate->max =
  2835. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  2836. channels->min = channels->max =
  2837. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  2838. break;
  2839. case MSM_BACKEND_DAI_AUXPCM_TX:
  2840. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2841. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  2842. rate->min = rate->max =
  2843. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  2844. channels->min = channels->max =
  2845. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  2846. break;
  2847. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  2848. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2849. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  2850. rate->min = rate->max =
  2851. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  2852. channels->min = channels->max =
  2853. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  2854. break;
  2855. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  2856. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2857. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  2858. rate->min = rate->max =
  2859. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  2860. channels->min = channels->max =
  2861. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  2862. break;
  2863. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  2864. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2865. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  2866. rate->min = rate->max =
  2867. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  2868. channels->min = channels->max =
  2869. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  2870. break;
  2871. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  2872. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2873. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  2874. rate->min = rate->max =
  2875. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  2876. channels->min = channels->max =
  2877. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  2878. break;
  2879. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2880. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2881. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  2882. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  2883. channels->min = channels->max =
  2884. mi2s_rx_cfg[PRIM_MI2S].channels;
  2885. break;
  2886. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2887. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2888. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  2889. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  2890. channels->min = channels->max =
  2891. mi2s_tx_cfg[PRIM_MI2S].channels;
  2892. break;
  2893. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2894. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2895. mi2s_rx_cfg[SEC_MI2S].bit_format);
  2896. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  2897. channels->min = channels->max =
  2898. mi2s_rx_cfg[SEC_MI2S].channels;
  2899. break;
  2900. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2901. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2902. mi2s_tx_cfg[SEC_MI2S].bit_format);
  2903. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  2904. channels->min = channels->max =
  2905. mi2s_tx_cfg[SEC_MI2S].channels;
  2906. break;
  2907. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2908. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2909. mi2s_rx_cfg[TERT_MI2S].bit_format);
  2910. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  2911. channels->min = channels->max =
  2912. mi2s_rx_cfg[TERT_MI2S].channels;
  2913. break;
  2914. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2915. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2916. mi2s_tx_cfg[TERT_MI2S].bit_format);
  2917. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  2918. channels->min = channels->max =
  2919. mi2s_tx_cfg[TERT_MI2S].channels;
  2920. break;
  2921. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2922. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2923. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2924. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  2925. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2926. cdc_dma_tx_cfg[idx].bit_format);
  2927. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  2928. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  2929. break;
  2930. default:
  2931. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  2932. break;
  2933. }
  2934. done:
  2935. return rc;
  2936. }
  2937. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2938. {
  2939. struct snd_soc_card *card = component->card;
  2940. struct msm_asoc_mach_data *pdata =
  2941. snd_soc_card_get_drvdata(card);
  2942. if (!pdata->fsa_handle)
  2943. return false;
  2944. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  2945. }
  2946. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2947. {
  2948. int value = 0;
  2949. bool ret = false;
  2950. struct snd_soc_card *card;
  2951. struct msm_asoc_mach_data *pdata;
  2952. if (!component) {
  2953. pr_err("%s component is NULL\n", __func__);
  2954. return false;
  2955. }
  2956. card = component->card;
  2957. pdata = snd_soc_card_get_drvdata(card);
  2958. if (!pdata)
  2959. return false;
  2960. if (wcd_mbhc_cfg.enable_usbc_analog)
  2961. return msm_usbc_swap_gnd_mic(component, active);
  2962. /* if usbc is not defined, swap using us_euro_gpio_p */
  2963. if (pdata->us_euro_gpio_p) {
  2964. value = msm_cdc_pinctrl_get_state(
  2965. pdata->us_euro_gpio_p);
  2966. if (value)
  2967. msm_cdc_pinctrl_select_sleep_state(
  2968. pdata->us_euro_gpio_p);
  2969. else
  2970. msm_cdc_pinctrl_select_active_state(
  2971. pdata->us_euro_gpio_p);
  2972. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  2973. __func__, value, !value);
  2974. ret = true;
  2975. }
  2976. return ret;
  2977. }
  2978. static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  2979. struct snd_pcm_hw_params *params)
  2980. {
  2981. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2982. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2983. int ret = 0;
  2984. int slot_width = 32;
  2985. int channels, slots;
  2986. unsigned int slot_mask, rate, clk_freq;
  2987. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  2988. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  2989. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  2990. switch (cpu_dai->id) {
  2991. case AFE_PORT_ID_PRIMARY_TDM_RX:
  2992. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2993. break;
  2994. case AFE_PORT_ID_SECONDARY_TDM_RX:
  2995. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2996. break;
  2997. case AFE_PORT_ID_TERTIARY_TDM_RX:
  2998. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2999. break;
  3000. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3001. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3002. break;
  3003. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3004. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3005. break;
  3006. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3007. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3008. break;
  3009. default:
  3010. pr_err("%s: dai id 0x%x not supported\n",
  3011. __func__, cpu_dai->id);
  3012. return -EINVAL;
  3013. }
  3014. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3015. /*2 slot config - bits 0 and 1 set for the first two slots */
  3016. slot_mask = 0x0000FFFF >> (16 - slots);
  3017. channels = slots;
  3018. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  3019. __func__, slot_width, slots);
  3020. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  3021. slots, slot_width);
  3022. if (ret < 0) {
  3023. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  3024. __func__, ret);
  3025. goto end;
  3026. }
  3027. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3028. 0, NULL, channels, slot_offset);
  3029. if (ret < 0) {
  3030. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  3031. __func__, ret);
  3032. goto end;
  3033. }
  3034. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  3035. /*2 slot config - bits 0 and 1 set for the first two slots */
  3036. slot_mask = 0x0000FFFF >> (16 - slots);
  3037. channels = slots;
  3038. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  3039. __func__, slot_width, slots);
  3040. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  3041. slots, slot_width);
  3042. if (ret < 0) {
  3043. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  3044. __func__, ret);
  3045. goto end;
  3046. }
  3047. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3048. channels, slot_offset, 0, NULL);
  3049. if (ret < 0) {
  3050. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  3051. __func__, ret);
  3052. goto end;
  3053. }
  3054. } else {
  3055. ret = -EINVAL;
  3056. pr_err("%s: invalid use case, err:%d\n",
  3057. __func__, ret);
  3058. goto end;
  3059. }
  3060. rate = params_rate(params);
  3061. clk_freq = rate * slot_width * slots;
  3062. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  3063. if (ret < 0)
  3064. pr_err("%s: failed to set tdm clk, err:%d\n",
  3065. __func__, ret);
  3066. end:
  3067. return ret;
  3068. }
  3069. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  3070. struct snd_pcm_hw_params *params)
  3071. {
  3072. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3073. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3074. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3075. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3076. int ret = 0;
  3077. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  3078. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3079. u32 user_set_tx_ch = 0;
  3080. u32 user_set_rx_ch = 0;
  3081. u32 ch_id;
  3082. ret = snd_soc_dai_get_channel_map(codec_dai,
  3083. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  3084. &rx_ch_cdc_dma);
  3085. if (ret < 0) {
  3086. pr_err("%s: failed to get codec chan map, err:%d\n",
  3087. __func__, ret);
  3088. goto err;
  3089. }
  3090. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3091. switch (dai_link->id) {
  3092. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3093. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3094. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3095. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3096. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3097. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3098. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  3099. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3100. {
  3101. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3102. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  3103. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  3104. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  3105. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3106. user_set_rx_ch, &rx_ch_cdc_dma);
  3107. if (ret < 0) {
  3108. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3109. __func__, ret);
  3110. goto err;
  3111. }
  3112. }
  3113. break;
  3114. }
  3115. } else {
  3116. switch (dai_link->id) {
  3117. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3118. {
  3119. user_set_tx_ch = msm_vi_feed_tx_ch;
  3120. }
  3121. break;
  3122. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3123. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3124. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3125. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3126. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3127. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3128. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3129. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3130. {
  3131. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3132. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  3133. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  3134. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  3135. }
  3136. break;
  3137. }
  3138. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  3139. &tx_ch_cdc_dma, 0, 0);
  3140. if (ret < 0) {
  3141. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3142. __func__, ret);
  3143. goto err;
  3144. }
  3145. }
  3146. err:
  3147. return ret;
  3148. }
  3149. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  3150. {
  3151. cpumask_t mask;
  3152. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  3153. pm_qos_remove_request(&substream->latency_pm_qos_req);
  3154. cpumask_clear(&mask);
  3155. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  3156. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  3157. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  3158. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  3159. pm_qos_add_request(&substream->latency_pm_qos_req,
  3160. PM_QOS_CPU_DMA_LATENCY,
  3161. MSM_LL_QOS_VALUE);
  3162. return 0;
  3163. }
  3164. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  3165. {
  3166. int ret = 0;
  3167. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3168. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3169. int index = cpu_dai->id;
  3170. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  3171. dev_dbg(rtd->card->dev,
  3172. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  3173. __func__, substream->name, substream->stream,
  3174. cpu_dai->name, cpu_dai->id);
  3175. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3176. ret = -EINVAL;
  3177. dev_err(rtd->card->dev,
  3178. "%s: CPU DAI id (%d) out of range\n",
  3179. __func__, cpu_dai->id);
  3180. goto err;
  3181. }
  3182. /*
  3183. * Mutex protection in case the same MI2S
  3184. * interface using for both TX and RX so
  3185. * that the same clock won't be enable twice.
  3186. */
  3187. mutex_lock(&mi2s_intf_conf[index].lock);
  3188. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  3189. /* Check if msm needs to provide the clock to the interface */
  3190. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  3191. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  3192. fmt = SND_SOC_DAIFMT_CBM_CFM;
  3193. }
  3194. ret = msm_mi2s_set_sclk(substream, true);
  3195. if (ret < 0) {
  3196. dev_err(rtd->card->dev,
  3197. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  3198. __func__, ret);
  3199. goto clean_up;
  3200. }
  3201. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  3202. if (ret < 0) {
  3203. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  3204. __func__, index, ret);
  3205. goto clk_off;
  3206. }
  3207. }
  3208. clk_off:
  3209. if (ret < 0)
  3210. msm_mi2s_set_sclk(substream, false);
  3211. clean_up:
  3212. if (ret < 0)
  3213. mi2s_intf_conf[index].ref_cnt--;
  3214. mutex_unlock(&mi2s_intf_conf[index].lock);
  3215. err:
  3216. return ret;
  3217. }
  3218. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  3219. {
  3220. int ret = 0;
  3221. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3222. int index = rtd->cpu_dai->id;
  3223. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  3224. substream->name, substream->stream);
  3225. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3226. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  3227. return;
  3228. }
  3229. mutex_lock(&mi2s_intf_conf[index].lock);
  3230. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  3231. ret = msm_mi2s_set_sclk(substream, false);
  3232. if (ret < 0)
  3233. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  3234. __func__, index, ret);
  3235. }
  3236. mutex_unlock(&mi2s_intf_conf[index].lock);
  3237. }
  3238. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  3239. struct snd_pcm_hw_params *params)
  3240. {
  3241. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3242. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3243. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3244. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3245. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  3246. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3247. int ret = 0;
  3248. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3249. codec_dai->name, codec_dai->id);
  3250. ret = snd_soc_dai_get_channel_map(codec_dai,
  3251. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3252. if (ret) {
  3253. dev_err(rtd->dev,
  3254. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3255. __func__, ret);
  3256. goto err;
  3257. }
  3258. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3259. __func__, tx_ch_cnt, dai_link->id);
  3260. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3261. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3262. if (ret)
  3263. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3264. __func__, ret);
  3265. err:
  3266. return ret;
  3267. }
  3268. static struct snd_soc_ops kona_tdm_be_ops = {
  3269. .hw_params = kona_tdm_snd_hw_params,
  3270. };
  3271. static struct snd_soc_ops msm_mi2s_be_ops = {
  3272. .startup = msm_mi2s_snd_startup,
  3273. .shutdown = msm_mi2s_snd_shutdown,
  3274. };
  3275. static struct snd_soc_ops msm_fe_qos_ops = {
  3276. .prepare = msm_fe_qos_prepare,
  3277. };
  3278. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  3279. .hw_params = msm_snd_cdc_dma_hw_params,
  3280. };
  3281. static struct snd_soc_ops msm_wcn_ops = {
  3282. .hw_params = msm_wcn_hw_params,
  3283. };
  3284. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3285. struct snd_kcontrol *kcontrol, int event)
  3286. {
  3287. struct msm_asoc_mach_data *pdata = NULL;
  3288. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  3289. int ret = 0;
  3290. u32 dmic_idx;
  3291. int *dmic_gpio_cnt;
  3292. struct device_node *dmic_gpio;
  3293. char *wname;
  3294. wname = strpbrk(w->name, "012345");
  3295. if (!wname) {
  3296. dev_err(component->dev, "%s: widget not found\n", __func__);
  3297. return -EINVAL;
  3298. }
  3299. ret = kstrtouint(wname, 10, &dmic_idx);
  3300. if (ret < 0) {
  3301. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3302. __func__);
  3303. return -EINVAL;
  3304. }
  3305. pdata = snd_soc_card_get_drvdata(component->card);
  3306. switch (dmic_idx) {
  3307. case 0:
  3308. case 1:
  3309. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  3310. dmic_gpio = pdata->dmic01_gpio_p;
  3311. break;
  3312. case 2:
  3313. case 3:
  3314. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  3315. dmic_gpio = pdata->dmic23_gpio_p;
  3316. break;
  3317. case 4:
  3318. case 5:
  3319. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  3320. dmic_gpio = pdata->dmic45_gpio_p;
  3321. break;
  3322. default:
  3323. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3324. __func__);
  3325. return -EINVAL;
  3326. }
  3327. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3328. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3329. switch (event) {
  3330. case SND_SOC_DAPM_PRE_PMU:
  3331. (*dmic_gpio_cnt)++;
  3332. if (*dmic_gpio_cnt == 1) {
  3333. ret = msm_cdc_pinctrl_select_active_state(
  3334. dmic_gpio);
  3335. if (ret < 0) {
  3336. pr_err("%s: gpio set cannot be activated %sd",
  3337. __func__, "dmic_gpio");
  3338. return ret;
  3339. }
  3340. }
  3341. break;
  3342. case SND_SOC_DAPM_POST_PMD:
  3343. (*dmic_gpio_cnt)--;
  3344. if (*dmic_gpio_cnt == 0) {
  3345. ret = msm_cdc_pinctrl_select_sleep_state(
  3346. dmic_gpio);
  3347. if (ret < 0) {
  3348. pr_err("%s: gpio set cannot be de-activated %sd",
  3349. __func__, "dmic_gpio");
  3350. return ret;
  3351. }
  3352. }
  3353. break;
  3354. default:
  3355. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  3356. return -EINVAL;
  3357. }
  3358. return 0;
  3359. }
  3360. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  3361. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  3362. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  3363. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3364. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3365. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3366. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3367. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3368. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3369. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3370. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3371. };
  3372. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  3373. {
  3374. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3375. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  3376. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3377. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3378. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3379. }
  3380. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  3381. {
  3382. int ret = -EINVAL;
  3383. struct snd_soc_component *component;
  3384. struct snd_soc_dapm_context *dapm;
  3385. struct snd_card *card;
  3386. struct snd_info_entry *entry;
  3387. struct snd_soc_component *aux_comp;
  3388. struct msm_asoc_mach_data *pdata =
  3389. snd_soc_card_get_drvdata(rtd->card);
  3390. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  3391. if (!component) {
  3392. pr_err("%s: could not find component for bolero_codec\n",
  3393. __func__);
  3394. return ret;
  3395. }
  3396. dapm = snd_soc_component_get_dapm(component);
  3397. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  3398. ARRAY_SIZE(msm_int_snd_controls));
  3399. if (ret < 0) {
  3400. pr_err("%s: add_component_controls failed: %d\n",
  3401. __func__, ret);
  3402. return ret;
  3403. }
  3404. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  3405. ARRAY_SIZE(msm_common_snd_controls));
  3406. if (ret < 0) {
  3407. pr_err("%s: add common snd controls failed: %d\n",
  3408. __func__, ret);
  3409. return ret;
  3410. }
  3411. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  3412. ARRAY_SIZE(msm_int_dapm_widgets));
  3413. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  3414. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  3415. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  3416. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  3417. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  3418. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  3419. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  3420. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  3421. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  3422. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  3423. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  3424. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  3425. snd_soc_dapm_sync(dapm);
  3426. /*
  3427. * Send speaker configuration only for WSA8810.
  3428. * Default configuration is for WSA8815.
  3429. */
  3430. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  3431. __func__, rtd->card->num_aux_devs);
  3432. if (rtd->card->num_aux_devs &&
  3433. !list_empty(&rtd->card->component_dev_list)) {
  3434. aux_comp = list_first_entry(
  3435. &rtd->card->component_dev_list,
  3436. struct snd_soc_component,
  3437. card_aux_list);
  3438. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3439. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3440. wsa_macro_set_spkr_mode(component,
  3441. WSA_MACRO_SPKR_MODE_1);
  3442. wsa_macro_set_spkr_gain_offset(component,
  3443. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  3444. }
  3445. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  3446. sm_port_map);
  3447. }
  3448. card = rtd->card->snd_card;
  3449. if (!pdata->codec_root) {
  3450. entry = snd_info_create_subdir(card->module, "codecs",
  3451. card->proc_root);
  3452. if (!entry) {
  3453. pr_debug("%s: Cannot create codecs module entry\n",
  3454. __func__);
  3455. ret = 0;
  3456. goto err;
  3457. }
  3458. pdata->codec_root = entry;
  3459. }
  3460. bolero_info_create_codec_entry(pdata->codec_root, component);
  3461. codec_reg_done = true;
  3462. return 0;
  3463. err:
  3464. return ret;
  3465. }
  3466. static void *def_wcd_mbhc_cal(void)
  3467. {
  3468. void *wcd_mbhc_cal;
  3469. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  3470. u16 *btn_high;
  3471. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  3472. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  3473. if (!wcd_mbhc_cal)
  3474. return NULL;
  3475. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  3476. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  3477. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  3478. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  3479. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  3480. btn_high[0] = 75;
  3481. btn_high[1] = 150;
  3482. btn_high[2] = 237;
  3483. btn_high[3] = 500;
  3484. btn_high[4] = 500;
  3485. btn_high[5] = 500;
  3486. btn_high[6] = 500;
  3487. btn_high[7] = 500;
  3488. return wcd_mbhc_cal;
  3489. }
  3490. /* Digital audio interface glue - connects codec <---> CPU */
  3491. static struct snd_soc_dai_link msm_common_dai_links[] = {
  3492. /* FrontEnd DAI Links */
  3493. {/* hw:x,0 */
  3494. .name = MSM_DAILINK_NAME(Media1),
  3495. .stream_name = "MultiMedia1",
  3496. .cpu_dai_name = "MultiMedia1",
  3497. .platform_name = "msm-pcm-dsp.0",
  3498. .dynamic = 1,
  3499. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3500. .dpcm_playback = 1,
  3501. .dpcm_capture = 1,
  3502. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3503. SND_SOC_DPCM_TRIGGER_POST},
  3504. .codec_dai_name = "snd-soc-dummy-dai",
  3505. .codec_name = "snd-soc-dummy",
  3506. .ignore_suspend = 1,
  3507. /* this dainlink has playback support */
  3508. .ignore_pmdown_time = 1,
  3509. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  3510. },
  3511. {/* hw:x,1 */
  3512. .name = MSM_DAILINK_NAME(Media2),
  3513. .stream_name = "MultiMedia2",
  3514. .cpu_dai_name = "MultiMedia2",
  3515. .platform_name = "msm-pcm-dsp.0",
  3516. .dynamic = 1,
  3517. .dpcm_playback = 1,
  3518. .dpcm_capture = 1,
  3519. .codec_dai_name = "snd-soc-dummy-dai",
  3520. .codec_name = "snd-soc-dummy",
  3521. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3522. SND_SOC_DPCM_TRIGGER_POST},
  3523. .ignore_suspend = 1,
  3524. /* this dainlink has playback support */
  3525. .ignore_pmdown_time = 1,
  3526. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  3527. },
  3528. {/* hw:x,2 */
  3529. .name = "VoiceMMode1",
  3530. .stream_name = "VoiceMMode1",
  3531. .cpu_dai_name = "VoiceMMode1",
  3532. .platform_name = "msm-pcm-voice",
  3533. .dynamic = 1,
  3534. .dpcm_playback = 1,
  3535. .dpcm_capture = 1,
  3536. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3537. SND_SOC_DPCM_TRIGGER_POST},
  3538. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3539. .ignore_suspend = 1,
  3540. .ignore_pmdown_time = 1,
  3541. .codec_dai_name = "snd-soc-dummy-dai",
  3542. .codec_name = "snd-soc-dummy",
  3543. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  3544. },
  3545. {/* hw:x,3 */
  3546. .name = "MSM VoIP",
  3547. .stream_name = "VoIP",
  3548. .cpu_dai_name = "VoIP",
  3549. .platform_name = "msm-voip-dsp",
  3550. .dynamic = 1,
  3551. .dpcm_playback = 1,
  3552. .dpcm_capture = 1,
  3553. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3554. SND_SOC_DPCM_TRIGGER_POST},
  3555. .codec_dai_name = "snd-soc-dummy-dai",
  3556. .codec_name = "snd-soc-dummy",
  3557. .ignore_suspend = 1,
  3558. /* this dainlink has playback support */
  3559. .ignore_pmdown_time = 1,
  3560. .id = MSM_FRONTEND_DAI_VOIP,
  3561. },
  3562. {/* hw:x,4 */
  3563. .name = MSM_DAILINK_NAME(ULL),
  3564. .stream_name = "MultiMedia3",
  3565. .cpu_dai_name = "MultiMedia3",
  3566. .platform_name = "msm-pcm-dsp.2",
  3567. .dynamic = 1,
  3568. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3569. .dpcm_playback = 1,
  3570. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3571. SND_SOC_DPCM_TRIGGER_POST},
  3572. .codec_dai_name = "snd-soc-dummy-dai",
  3573. .codec_name = "snd-soc-dummy",
  3574. .ignore_suspend = 1,
  3575. /* this dainlink has playback support */
  3576. .ignore_pmdown_time = 1,
  3577. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  3578. },
  3579. /* Hostless PCM purpose */
  3580. {/* hw:x,5 */
  3581. .name = "MSM AFE-PCM RX",
  3582. .stream_name = "AFE-PROXY RX",
  3583. .cpu_dai_name = "msm-dai-q6-dev.241",
  3584. .codec_name = "msm-stub-codec.1",
  3585. .codec_dai_name = "msm-stub-rx",
  3586. .platform_name = "msm-pcm-afe",
  3587. .dpcm_playback = 1,
  3588. .ignore_suspend = 1,
  3589. /* this dainlink has playback support */
  3590. .ignore_pmdown_time = 1,
  3591. },
  3592. {/* hw:x,6 */
  3593. .name = "MSM AFE-PCM TX",
  3594. .stream_name = "AFE-PROXY TX",
  3595. .cpu_dai_name = "msm-dai-q6-dev.240",
  3596. .codec_name = "msm-stub-codec.1",
  3597. .codec_dai_name = "msm-stub-tx",
  3598. .platform_name = "msm-pcm-afe",
  3599. .dpcm_capture = 1,
  3600. .ignore_suspend = 1,
  3601. },
  3602. {/* hw:x,7 */
  3603. .name = MSM_DAILINK_NAME(Compress1),
  3604. .stream_name = "Compress1",
  3605. .cpu_dai_name = "MultiMedia4",
  3606. .platform_name = "msm-compress-dsp",
  3607. .dynamic = 1,
  3608. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  3609. .dpcm_playback = 1,
  3610. .dpcm_capture = 1,
  3611. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3612. SND_SOC_DPCM_TRIGGER_POST},
  3613. .codec_dai_name = "snd-soc-dummy-dai",
  3614. .codec_name = "snd-soc-dummy",
  3615. .ignore_suspend = 1,
  3616. .ignore_pmdown_time = 1,
  3617. /* this dainlink has playback support */
  3618. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  3619. },
  3620. {/* hw:x,8 */
  3621. .name = "AUXPCM Hostless",
  3622. .stream_name = "AUXPCM Hostless",
  3623. .cpu_dai_name = "AUXPCM_HOSTLESS",
  3624. .platform_name = "msm-pcm-hostless",
  3625. .dynamic = 1,
  3626. .dpcm_playback = 1,
  3627. .dpcm_capture = 1,
  3628. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3629. SND_SOC_DPCM_TRIGGER_POST},
  3630. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3631. .ignore_suspend = 1,
  3632. /* this dainlink has playback support */
  3633. .ignore_pmdown_time = 1,
  3634. .codec_dai_name = "snd-soc-dummy-dai",
  3635. .codec_name = "snd-soc-dummy",
  3636. },
  3637. {/* hw:x,9 */
  3638. .name = MSM_DAILINK_NAME(LowLatency),
  3639. .stream_name = "MultiMedia5",
  3640. .cpu_dai_name = "MultiMedia5",
  3641. .platform_name = "msm-pcm-dsp.1",
  3642. .dynamic = 1,
  3643. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3644. .dpcm_playback = 1,
  3645. .dpcm_capture = 1,
  3646. .codec_dai_name = "snd-soc-dummy-dai",
  3647. .codec_name = "snd-soc-dummy",
  3648. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3649. SND_SOC_DPCM_TRIGGER_POST},
  3650. .ignore_suspend = 1,
  3651. /* this dainlink has playback support */
  3652. .ignore_pmdown_time = 1,
  3653. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  3654. .ops = &msm_fe_qos_ops,
  3655. },
  3656. {/* hw:x,10 */
  3657. .name = "Listen 1 Audio Service",
  3658. .stream_name = "Listen 1 Audio Service",
  3659. .cpu_dai_name = "LSM1",
  3660. .platform_name = "msm-lsm-client",
  3661. .dynamic = 1,
  3662. .dpcm_capture = 1,
  3663. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3664. SND_SOC_DPCM_TRIGGER_POST },
  3665. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3666. .ignore_suspend = 1,
  3667. .codec_dai_name = "snd-soc-dummy-dai",
  3668. .codec_name = "snd-soc-dummy",
  3669. .id = MSM_FRONTEND_DAI_LSM1,
  3670. },
  3671. /* Multiple Tunnel instances */
  3672. {/* hw:x,11 */
  3673. .name = MSM_DAILINK_NAME(Compress2),
  3674. .stream_name = "Compress2",
  3675. .cpu_dai_name = "MultiMedia7",
  3676. .platform_name = "msm-compress-dsp",
  3677. .dynamic = 1,
  3678. .dpcm_playback = 1,
  3679. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3680. SND_SOC_DPCM_TRIGGER_POST},
  3681. .codec_dai_name = "snd-soc-dummy-dai",
  3682. .codec_name = "snd-soc-dummy",
  3683. .ignore_suspend = 1,
  3684. .ignore_pmdown_time = 1,
  3685. /* this dainlink has playback support */
  3686. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  3687. },
  3688. {/* hw:x,12 */
  3689. .name = MSM_DAILINK_NAME(MultiMedia10),
  3690. .stream_name = "MultiMedia10",
  3691. .cpu_dai_name = "MultiMedia10",
  3692. .platform_name = "msm-pcm-dsp.1",
  3693. .dynamic = 1,
  3694. .dpcm_playback = 1,
  3695. .dpcm_capture = 1,
  3696. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3697. SND_SOC_DPCM_TRIGGER_POST},
  3698. .codec_dai_name = "snd-soc-dummy-dai",
  3699. .codec_name = "snd-soc-dummy",
  3700. .ignore_suspend = 1,
  3701. .ignore_pmdown_time = 1,
  3702. /* this dainlink has playback support */
  3703. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  3704. },
  3705. {/* hw:x,13 */
  3706. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  3707. .stream_name = "MM_NOIRQ",
  3708. .cpu_dai_name = "MultiMedia8",
  3709. .platform_name = "msm-pcm-dsp-noirq",
  3710. .dynamic = 1,
  3711. .dpcm_playback = 1,
  3712. .dpcm_capture = 1,
  3713. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3714. SND_SOC_DPCM_TRIGGER_POST},
  3715. .codec_dai_name = "snd-soc-dummy-dai",
  3716. .codec_name = "snd-soc-dummy",
  3717. .ignore_suspend = 1,
  3718. .ignore_pmdown_time = 1,
  3719. /* this dainlink has playback support */
  3720. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  3721. .ops = &msm_fe_qos_ops,
  3722. },
  3723. /* HDMI Hostless */
  3724. {/* hw:x,14 */
  3725. .name = "HDMI_RX_HOSTLESS",
  3726. .stream_name = "HDMI_RX_HOSTLESS",
  3727. .cpu_dai_name = "HDMI_HOSTLESS",
  3728. .platform_name = "msm-pcm-hostless",
  3729. .dynamic = 1,
  3730. .dpcm_playback = 1,
  3731. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3732. SND_SOC_DPCM_TRIGGER_POST},
  3733. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3734. .ignore_suspend = 1,
  3735. .ignore_pmdown_time = 1,
  3736. .codec_dai_name = "snd-soc-dummy-dai",
  3737. .codec_name = "snd-soc-dummy",
  3738. },
  3739. {/* hw:x,15 */
  3740. .name = "VoiceMMode2",
  3741. .stream_name = "VoiceMMode2",
  3742. .cpu_dai_name = "VoiceMMode2",
  3743. .platform_name = "msm-pcm-voice",
  3744. .dynamic = 1,
  3745. .dpcm_playback = 1,
  3746. .dpcm_capture = 1,
  3747. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3748. SND_SOC_DPCM_TRIGGER_POST},
  3749. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3750. .ignore_suspend = 1,
  3751. .ignore_pmdown_time = 1,
  3752. .codec_dai_name = "snd-soc-dummy-dai",
  3753. .codec_name = "snd-soc-dummy",
  3754. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  3755. },
  3756. /* LSM FE */
  3757. {/* hw:x,16 */
  3758. .name = "Listen 2 Audio Service",
  3759. .stream_name = "Listen 2 Audio Service",
  3760. .cpu_dai_name = "LSM2",
  3761. .platform_name = "msm-lsm-client",
  3762. .dynamic = 1,
  3763. .dpcm_capture = 1,
  3764. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3765. SND_SOC_DPCM_TRIGGER_POST },
  3766. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3767. .ignore_suspend = 1,
  3768. .codec_dai_name = "snd-soc-dummy-dai",
  3769. .codec_name = "snd-soc-dummy",
  3770. .id = MSM_FRONTEND_DAI_LSM2,
  3771. },
  3772. {/* hw:x,17 */
  3773. .name = "Listen 3 Audio Service",
  3774. .stream_name = "Listen 3 Audio Service",
  3775. .cpu_dai_name = "LSM3",
  3776. .platform_name = "msm-lsm-client",
  3777. .dynamic = 1,
  3778. .dpcm_capture = 1,
  3779. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3780. SND_SOC_DPCM_TRIGGER_POST },
  3781. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3782. .ignore_suspend = 1,
  3783. .codec_dai_name = "snd-soc-dummy-dai",
  3784. .codec_name = "snd-soc-dummy",
  3785. .id = MSM_FRONTEND_DAI_LSM3,
  3786. },
  3787. {/* hw:x,18 */
  3788. .name = "Listen 4 Audio Service",
  3789. .stream_name = "Listen 4 Audio Service",
  3790. .cpu_dai_name = "LSM4",
  3791. .platform_name = "msm-lsm-client",
  3792. .dynamic = 1,
  3793. .dpcm_capture = 1,
  3794. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3795. SND_SOC_DPCM_TRIGGER_POST },
  3796. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3797. .ignore_suspend = 1,
  3798. .codec_dai_name = "snd-soc-dummy-dai",
  3799. .codec_name = "snd-soc-dummy",
  3800. .id = MSM_FRONTEND_DAI_LSM4,
  3801. },
  3802. {/* hw:x,19 */
  3803. .name = "Listen 5 Audio Service",
  3804. .stream_name = "Listen 5 Audio Service",
  3805. .cpu_dai_name = "LSM5",
  3806. .platform_name = "msm-lsm-client",
  3807. .dynamic = 1,
  3808. .dpcm_capture = 1,
  3809. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3810. SND_SOC_DPCM_TRIGGER_POST },
  3811. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3812. .ignore_suspend = 1,
  3813. .codec_dai_name = "snd-soc-dummy-dai",
  3814. .codec_name = "snd-soc-dummy",
  3815. .id = MSM_FRONTEND_DAI_LSM5,
  3816. },
  3817. {/* hw:x,20 */
  3818. .name = "Listen 6 Audio Service",
  3819. .stream_name = "Listen 6 Audio Service",
  3820. .cpu_dai_name = "LSM6",
  3821. .platform_name = "msm-lsm-client",
  3822. .dynamic = 1,
  3823. .dpcm_capture = 1,
  3824. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3825. SND_SOC_DPCM_TRIGGER_POST },
  3826. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3827. .ignore_suspend = 1,
  3828. .codec_dai_name = "snd-soc-dummy-dai",
  3829. .codec_name = "snd-soc-dummy",
  3830. .id = MSM_FRONTEND_DAI_LSM6,
  3831. },
  3832. {/* hw:x,21 */
  3833. .name = "Listen 7 Audio Service",
  3834. .stream_name = "Listen 7 Audio Service",
  3835. .cpu_dai_name = "LSM7",
  3836. .platform_name = "msm-lsm-client",
  3837. .dynamic = 1,
  3838. .dpcm_capture = 1,
  3839. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3840. SND_SOC_DPCM_TRIGGER_POST },
  3841. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3842. .ignore_suspend = 1,
  3843. .codec_dai_name = "snd-soc-dummy-dai",
  3844. .codec_name = "snd-soc-dummy",
  3845. .id = MSM_FRONTEND_DAI_LSM7,
  3846. },
  3847. {/* hw:x,22 */
  3848. .name = "Listen 8 Audio Service",
  3849. .stream_name = "Listen 8 Audio Service",
  3850. .cpu_dai_name = "LSM8",
  3851. .platform_name = "msm-lsm-client",
  3852. .dynamic = 1,
  3853. .dpcm_capture = 1,
  3854. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3855. SND_SOC_DPCM_TRIGGER_POST },
  3856. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3857. .ignore_suspend = 1,
  3858. .codec_dai_name = "snd-soc-dummy-dai",
  3859. .codec_name = "snd-soc-dummy",
  3860. .id = MSM_FRONTEND_DAI_LSM8,
  3861. },
  3862. {/* hw:x,23 */
  3863. .name = MSM_DAILINK_NAME(Media9),
  3864. .stream_name = "MultiMedia9",
  3865. .cpu_dai_name = "MultiMedia9",
  3866. .platform_name = "msm-pcm-dsp.0",
  3867. .dynamic = 1,
  3868. .dpcm_playback = 1,
  3869. .dpcm_capture = 1,
  3870. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3871. SND_SOC_DPCM_TRIGGER_POST},
  3872. .codec_dai_name = "snd-soc-dummy-dai",
  3873. .codec_name = "snd-soc-dummy",
  3874. .ignore_suspend = 1,
  3875. /* this dainlink has playback support */
  3876. .ignore_pmdown_time = 1,
  3877. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  3878. },
  3879. {/* hw:x,24 */
  3880. .name = MSM_DAILINK_NAME(Compress4),
  3881. .stream_name = "Compress4",
  3882. .cpu_dai_name = "MultiMedia11",
  3883. .platform_name = "msm-compress-dsp",
  3884. .dynamic = 1,
  3885. .dpcm_playback = 1,
  3886. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3887. SND_SOC_DPCM_TRIGGER_POST},
  3888. .codec_dai_name = "snd-soc-dummy-dai",
  3889. .codec_name = "snd-soc-dummy",
  3890. .ignore_suspend = 1,
  3891. .ignore_pmdown_time = 1,
  3892. /* this dainlink has playback support */
  3893. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  3894. },
  3895. {/* hw:x,25 */
  3896. .name = MSM_DAILINK_NAME(Compress5),
  3897. .stream_name = "Compress5",
  3898. .cpu_dai_name = "MultiMedia12",
  3899. .platform_name = "msm-compress-dsp",
  3900. .dynamic = 1,
  3901. .dpcm_playback = 1,
  3902. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3903. SND_SOC_DPCM_TRIGGER_POST},
  3904. .codec_dai_name = "snd-soc-dummy-dai",
  3905. .codec_name = "snd-soc-dummy",
  3906. .ignore_suspend = 1,
  3907. .ignore_pmdown_time = 1,
  3908. /* this dainlink has playback support */
  3909. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  3910. },
  3911. {/* hw:x,26 */
  3912. .name = MSM_DAILINK_NAME(Compress6),
  3913. .stream_name = "Compress6",
  3914. .cpu_dai_name = "MultiMedia13",
  3915. .platform_name = "msm-compress-dsp",
  3916. .dynamic = 1,
  3917. .dpcm_playback = 1,
  3918. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3919. SND_SOC_DPCM_TRIGGER_POST},
  3920. .codec_dai_name = "snd-soc-dummy-dai",
  3921. .codec_name = "snd-soc-dummy",
  3922. .ignore_suspend = 1,
  3923. .ignore_pmdown_time = 1,
  3924. /* this dainlink has playback support */
  3925. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  3926. },
  3927. {/* hw:x,27 */
  3928. .name = MSM_DAILINK_NAME(Compress7),
  3929. .stream_name = "Compress7",
  3930. .cpu_dai_name = "MultiMedia14",
  3931. .platform_name = "msm-compress-dsp",
  3932. .dynamic = 1,
  3933. .dpcm_playback = 1,
  3934. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3935. SND_SOC_DPCM_TRIGGER_POST},
  3936. .codec_dai_name = "snd-soc-dummy-dai",
  3937. .codec_name = "snd-soc-dummy",
  3938. .ignore_suspend = 1,
  3939. .ignore_pmdown_time = 1,
  3940. /* this dainlink has playback support */
  3941. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  3942. },
  3943. {/* hw:x,28 */
  3944. .name = MSM_DAILINK_NAME(Compress8),
  3945. .stream_name = "Compress8",
  3946. .cpu_dai_name = "MultiMedia15",
  3947. .platform_name = "msm-compress-dsp",
  3948. .dynamic = 1,
  3949. .dpcm_playback = 1,
  3950. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3951. SND_SOC_DPCM_TRIGGER_POST},
  3952. .codec_dai_name = "snd-soc-dummy-dai",
  3953. .codec_name = "snd-soc-dummy",
  3954. .ignore_suspend = 1,
  3955. .ignore_pmdown_time = 1,
  3956. /* this dainlink has playback support */
  3957. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  3958. },
  3959. {/* hw:x,29 */
  3960. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  3961. .stream_name = "MM_NOIRQ_2",
  3962. .cpu_dai_name = "MultiMedia16",
  3963. .platform_name = "msm-pcm-dsp-noirq",
  3964. .dynamic = 1,
  3965. .dpcm_playback = 1,
  3966. .dpcm_capture = 1,
  3967. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3968. SND_SOC_DPCM_TRIGGER_POST},
  3969. .codec_dai_name = "snd-soc-dummy-dai",
  3970. .codec_name = "snd-soc-dummy",
  3971. .ignore_suspend = 1,
  3972. .ignore_pmdown_time = 1,
  3973. /* this dainlink has playback support */
  3974. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  3975. },
  3976. {/* hw:x,30 */
  3977. .name = "CDC_DMA Hostless",
  3978. .stream_name = "CDC_DMA Hostless",
  3979. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  3980. .platform_name = "msm-pcm-hostless",
  3981. .dynamic = 1,
  3982. .dpcm_playback = 1,
  3983. .dpcm_capture = 1,
  3984. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3985. SND_SOC_DPCM_TRIGGER_POST},
  3986. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3987. .ignore_suspend = 1,
  3988. /* this dailink has playback support */
  3989. .ignore_pmdown_time = 1,
  3990. .codec_dai_name = "snd-soc-dummy-dai",
  3991. .codec_name = "snd-soc-dummy",
  3992. },
  3993. {/* hw:x,31 */
  3994. .name = "TX3_CDC_DMA Hostless",
  3995. .stream_name = "TX3_CDC_DMA Hostless",
  3996. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  3997. .platform_name = "msm-pcm-hostless",
  3998. .dynamic = 1,
  3999. .dpcm_capture = 1,
  4000. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4001. SND_SOC_DPCM_TRIGGER_POST},
  4002. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4003. .ignore_suspend = 1,
  4004. .codec_dai_name = "snd-soc-dummy-dai",
  4005. .codec_name = "snd-soc-dummy",
  4006. },
  4007. };
  4008. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  4009. {/* hw:x,37 */
  4010. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  4011. .stream_name = "WSA CDC DMA0 Capture",
  4012. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  4013. .platform_name = "msm-pcm-hostless",
  4014. .codec_name = "bolero_codec",
  4015. .codec_dai_name = "wsa_macro_vifeedback",
  4016. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  4017. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4018. .ignore_suspend = 1,
  4019. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4020. .ops = &msm_cdc_dma_be_ops,
  4021. },
  4022. };
  4023. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  4024. {
  4025. .name = MSM_DAILINK_NAME(ASM Loopback),
  4026. .stream_name = "MultiMedia6",
  4027. .cpu_dai_name = "MultiMedia6",
  4028. .platform_name = "msm-pcm-loopback",
  4029. .dynamic = 1,
  4030. .dpcm_playback = 1,
  4031. .dpcm_capture = 1,
  4032. .codec_dai_name = "snd-soc-dummy-dai",
  4033. .codec_name = "snd-soc-dummy",
  4034. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4035. SND_SOC_DPCM_TRIGGER_POST},
  4036. .ignore_suspend = 1,
  4037. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4038. .ignore_pmdown_time = 1,
  4039. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  4040. },
  4041. {
  4042. .name = "USB Audio Hostless",
  4043. .stream_name = "USB Audio Hostless",
  4044. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  4045. .platform_name = "msm-pcm-hostless",
  4046. .dynamic = 1,
  4047. .dpcm_playback = 1,
  4048. .dpcm_capture = 1,
  4049. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4050. SND_SOC_DPCM_TRIGGER_POST},
  4051. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4052. .ignore_suspend = 1,
  4053. .ignore_pmdown_time = 1,
  4054. .codec_dai_name = "snd-soc-dummy-dai",
  4055. .codec_name = "snd-soc-dummy",
  4056. },
  4057. {
  4058. .name = "SLIMBUS_7 Hostless",
  4059. .stream_name = "SLIMBUS_7 Hostless",
  4060. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  4061. .platform_name = "msm-pcm-hostless",
  4062. .dynamic = 1,
  4063. .dpcm_capture = 1,
  4064. .dpcm_playback = 1,
  4065. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4066. SND_SOC_DPCM_TRIGGER_POST},
  4067. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4068. .ignore_suspend = 1,
  4069. .ignore_pmdown_time = 1,
  4070. .codec_dai_name = "snd-soc-dummy-dai",
  4071. .codec_name = "snd-soc-dummy",
  4072. },
  4073. {
  4074. .name = "Compress Capture",
  4075. .stream_name = "Compress9",
  4076. .cpu_dai_name = "MultiMedia17",
  4077. .platform_name = "msm-compress-dsp",
  4078. .dynamic = 1,
  4079. .dpcm_capture = 1,
  4080. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4081. SND_SOC_DPCM_TRIGGER_POST},
  4082. .codec_dai_name = "snd-soc-dummy-dai",
  4083. .codec_name = "snd-soc-dummy",
  4084. .ignore_suspend = 1,
  4085. .ignore_pmdown_time = 1,
  4086. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  4087. },
  4088. };
  4089. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  4090. /* Backend AFE DAI Links */
  4091. {
  4092. .name = LPASS_BE_AFE_PCM_RX,
  4093. .stream_name = "AFE Playback",
  4094. .cpu_dai_name = "msm-dai-q6-dev.224",
  4095. .platform_name = "msm-pcm-routing",
  4096. .codec_name = "msm-stub-codec.1",
  4097. .codec_dai_name = "msm-stub-rx",
  4098. .no_pcm = 1,
  4099. .dpcm_playback = 1,
  4100. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  4101. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4102. /* this dainlink has playback support */
  4103. .ignore_pmdown_time = 1,
  4104. .ignore_suspend = 1,
  4105. },
  4106. {
  4107. .name = LPASS_BE_AFE_PCM_TX,
  4108. .stream_name = "AFE Capture",
  4109. .cpu_dai_name = "msm-dai-q6-dev.225",
  4110. .platform_name = "msm-pcm-routing",
  4111. .codec_name = "msm-stub-codec.1",
  4112. .codec_dai_name = "msm-stub-tx",
  4113. .no_pcm = 1,
  4114. .dpcm_capture = 1,
  4115. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  4116. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4117. .ignore_suspend = 1,
  4118. },
  4119. /* Incall Record Uplink BACK END DAI Link */
  4120. {
  4121. .name = LPASS_BE_INCALL_RECORD_TX,
  4122. .stream_name = "Voice Uplink Capture",
  4123. .cpu_dai_name = "msm-dai-q6-dev.32772",
  4124. .platform_name = "msm-pcm-routing",
  4125. .codec_name = "msm-stub-codec.1",
  4126. .codec_dai_name = "msm-stub-tx",
  4127. .no_pcm = 1,
  4128. .dpcm_capture = 1,
  4129. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  4130. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4131. .ignore_suspend = 1,
  4132. },
  4133. /* Incall Record Downlink BACK END DAI Link */
  4134. {
  4135. .name = LPASS_BE_INCALL_RECORD_RX,
  4136. .stream_name = "Voice Downlink Capture",
  4137. .cpu_dai_name = "msm-dai-q6-dev.32771",
  4138. .platform_name = "msm-pcm-routing",
  4139. .codec_name = "msm-stub-codec.1",
  4140. .codec_dai_name = "msm-stub-tx",
  4141. .no_pcm = 1,
  4142. .dpcm_capture = 1,
  4143. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  4144. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4145. .ignore_suspend = 1,
  4146. },
  4147. /* Incall Music BACK END DAI Link */
  4148. {
  4149. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  4150. .stream_name = "Voice Farend Playback",
  4151. .cpu_dai_name = "msm-dai-q6-dev.32773",
  4152. .platform_name = "msm-pcm-routing",
  4153. .codec_name = "msm-stub-codec.1",
  4154. .codec_dai_name = "msm-stub-rx",
  4155. .no_pcm = 1,
  4156. .dpcm_playback = 1,
  4157. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  4158. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4159. .ignore_suspend = 1,
  4160. .ignore_pmdown_time = 1,
  4161. },
  4162. /* Incall Music 2 BACK END DAI Link */
  4163. {
  4164. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  4165. .stream_name = "Voice2 Farend Playback",
  4166. .cpu_dai_name = "msm-dai-q6-dev.32770",
  4167. .platform_name = "msm-pcm-routing",
  4168. .codec_name = "msm-stub-codec.1",
  4169. .codec_dai_name = "msm-stub-rx",
  4170. .no_pcm = 1,
  4171. .dpcm_playback = 1,
  4172. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  4173. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4174. .ignore_suspend = 1,
  4175. .ignore_pmdown_time = 1,
  4176. },
  4177. {
  4178. .name = LPASS_BE_USB_AUDIO_RX,
  4179. .stream_name = "USB Audio Playback",
  4180. .cpu_dai_name = "msm-dai-q6-dev.28672",
  4181. .platform_name = "msm-pcm-routing",
  4182. .codec_name = "msm-stub-codec.1",
  4183. .codec_dai_name = "msm-stub-rx",
  4184. .no_pcm = 1,
  4185. .dpcm_playback = 1,
  4186. .id = MSM_BACKEND_DAI_USB_RX,
  4187. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4188. .ignore_pmdown_time = 1,
  4189. .ignore_suspend = 1,
  4190. },
  4191. {
  4192. .name = LPASS_BE_USB_AUDIO_TX,
  4193. .stream_name = "USB Audio Capture",
  4194. .cpu_dai_name = "msm-dai-q6-dev.28673",
  4195. .platform_name = "msm-pcm-routing",
  4196. .codec_name = "msm-stub-codec.1",
  4197. .codec_dai_name = "msm-stub-tx",
  4198. .no_pcm = 1,
  4199. .dpcm_capture = 1,
  4200. .id = MSM_BACKEND_DAI_USB_TX,
  4201. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4202. .ignore_suspend = 1,
  4203. },
  4204. {
  4205. .name = LPASS_BE_PRI_TDM_RX_0,
  4206. .stream_name = "Primary TDM0 Playback",
  4207. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  4208. .platform_name = "msm-pcm-routing",
  4209. .codec_name = "msm-stub-codec.1",
  4210. .codec_dai_name = "msm-stub-rx",
  4211. .no_pcm = 1,
  4212. .dpcm_playback = 1,
  4213. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  4214. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4215. .ops = &kona_tdm_be_ops,
  4216. .ignore_suspend = 1,
  4217. .ignore_pmdown_time = 1,
  4218. },
  4219. {
  4220. .name = LPASS_BE_PRI_TDM_TX_0,
  4221. .stream_name = "Primary TDM0 Capture",
  4222. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  4223. .platform_name = "msm-pcm-routing",
  4224. .codec_name = "msm-stub-codec.1",
  4225. .codec_dai_name = "msm-stub-tx",
  4226. .no_pcm = 1,
  4227. .dpcm_capture = 1,
  4228. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  4229. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4230. .ops = &kona_tdm_be_ops,
  4231. .ignore_suspend = 1,
  4232. },
  4233. {
  4234. .name = LPASS_BE_SEC_TDM_RX_0,
  4235. .stream_name = "Secondary TDM0 Playback",
  4236. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  4237. .platform_name = "msm-pcm-routing",
  4238. .codec_name = "msm-stub-codec.1",
  4239. .codec_dai_name = "msm-stub-rx",
  4240. .no_pcm = 1,
  4241. .dpcm_playback = 1,
  4242. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  4243. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4244. .ops = &kona_tdm_be_ops,
  4245. .ignore_suspend = 1,
  4246. .ignore_pmdown_time = 1,
  4247. },
  4248. {
  4249. .name = LPASS_BE_SEC_TDM_TX_0,
  4250. .stream_name = "Secondary TDM0 Capture",
  4251. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  4252. .platform_name = "msm-pcm-routing",
  4253. .codec_name = "msm-stub-codec.1",
  4254. .codec_dai_name = "msm-stub-tx",
  4255. .no_pcm = 1,
  4256. .dpcm_capture = 1,
  4257. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  4258. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4259. .ops = &kona_tdm_be_ops,
  4260. .ignore_suspend = 1,
  4261. },
  4262. {
  4263. .name = LPASS_BE_TERT_TDM_RX_0,
  4264. .stream_name = "Tertiary TDM0 Playback",
  4265. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  4266. .platform_name = "msm-pcm-routing",
  4267. .codec_name = "msm-stub-codec.1",
  4268. .codec_dai_name = "msm-stub-rx",
  4269. .no_pcm = 1,
  4270. .dpcm_playback = 1,
  4271. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  4272. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4273. .ops = &kona_tdm_be_ops,
  4274. .ignore_suspend = 1,
  4275. .ignore_pmdown_time = 1,
  4276. },
  4277. {
  4278. .name = LPASS_BE_TERT_TDM_TX_0,
  4279. .stream_name = "Tertiary TDM0 Capture",
  4280. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  4281. .platform_name = "msm-pcm-routing",
  4282. .codec_name = "msm-stub-codec.1",
  4283. .codec_dai_name = "msm-stub-tx",
  4284. .no_pcm = 1,
  4285. .dpcm_capture = 1,
  4286. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  4287. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4288. .ops = &kona_tdm_be_ops,
  4289. .ignore_suspend = 1,
  4290. },
  4291. };
  4292. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  4293. {
  4294. .name = LPASS_BE_SLIMBUS_7_RX,
  4295. .stream_name = "Slimbus7 Playback",
  4296. .cpu_dai_name = "msm-dai-q6-dev.16398",
  4297. .platform_name = "msm-pcm-routing",
  4298. .codec_name = "btfmslim_slave",
  4299. /* BT codec driver determines capabilities based on
  4300. * dai name, bt codecdai name should always contains
  4301. * supported usecase information
  4302. */
  4303. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  4304. .no_pcm = 1,
  4305. .dpcm_playback = 1,
  4306. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  4307. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4308. .init = &msm_wcn_init,
  4309. .ops = &msm_wcn_ops,
  4310. /* dai link has playback support */
  4311. .ignore_pmdown_time = 1,
  4312. .ignore_suspend = 1,
  4313. },
  4314. {
  4315. .name = LPASS_BE_SLIMBUS_7_TX,
  4316. .stream_name = "Slimbus7 Capture",
  4317. .cpu_dai_name = "msm-dai-q6-dev.16399",
  4318. .platform_name = "msm-pcm-routing",
  4319. .codec_name = "btfmslim_slave",
  4320. .codec_dai_name = "btfm_bt_sco_slim_tx",
  4321. .no_pcm = 1,
  4322. .dpcm_capture = 1,
  4323. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  4324. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4325. .ops = &msm_wcn_ops,
  4326. .ignore_suspend = 1,
  4327. },
  4328. };
  4329. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  4330. /* DISP PORT BACK END DAI Link */
  4331. {
  4332. .name = LPASS_BE_DISPLAY_PORT,
  4333. .stream_name = "Display Port Playback",
  4334. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4335. .platform_name = "msm-pcm-routing",
  4336. .codec_name = "msm-ext-disp-audio-codec-rx",
  4337. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  4338. .no_pcm = 1,
  4339. .dpcm_playback = 1,
  4340. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  4341. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4342. .ignore_pmdown_time = 1,
  4343. .ignore_suspend = 1,
  4344. },
  4345. /* DISP PORT 1 BACK END DAI Link */
  4346. {
  4347. .name = LPASS_BE_DISPLAY_PORT1,
  4348. .stream_name = "Display Port1 Playback",
  4349. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4350. .platform_name = "msm-pcm-routing",
  4351. .codec_name = "msm-ext-disp-audio-codec-rx",
  4352. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  4353. .no_pcm = 1,
  4354. .dpcm_playback = 1,
  4355. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  4356. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4357. .ignore_pmdown_time = 1,
  4358. .ignore_suspend = 1,
  4359. },
  4360. };
  4361. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  4362. {
  4363. .name = LPASS_BE_PRI_MI2S_RX,
  4364. .stream_name = "Primary MI2S Playback",
  4365. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4366. .platform_name = "msm-pcm-routing",
  4367. .codec_name = "msm-stub-codec.1",
  4368. .codec_dai_name = "msm-stub-rx",
  4369. .no_pcm = 1,
  4370. .dpcm_playback = 1,
  4371. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  4372. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4373. .ops = &msm_mi2s_be_ops,
  4374. .ignore_suspend = 1,
  4375. .ignore_pmdown_time = 1,
  4376. },
  4377. {
  4378. .name = LPASS_BE_PRI_MI2S_TX,
  4379. .stream_name = "Primary MI2S Capture",
  4380. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4381. .platform_name = "msm-pcm-routing",
  4382. .codec_name = "msm-stub-codec.1",
  4383. .codec_dai_name = "msm-stub-tx",
  4384. .no_pcm = 1,
  4385. .dpcm_capture = 1,
  4386. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  4387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4388. .ops = &msm_mi2s_be_ops,
  4389. .ignore_suspend = 1,
  4390. },
  4391. {
  4392. .name = LPASS_BE_SEC_MI2S_RX,
  4393. .stream_name = "Secondary MI2S Playback",
  4394. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4395. .platform_name = "msm-pcm-routing",
  4396. .codec_name = "msm-stub-codec.1",
  4397. .codec_dai_name = "msm-stub-rx",
  4398. .no_pcm = 1,
  4399. .dpcm_playback = 1,
  4400. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  4401. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4402. .ops = &msm_mi2s_be_ops,
  4403. .ignore_suspend = 1,
  4404. .ignore_pmdown_time = 1,
  4405. },
  4406. {
  4407. .name = LPASS_BE_SEC_MI2S_TX,
  4408. .stream_name = "Secondary MI2S Capture",
  4409. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4410. .platform_name = "msm-pcm-routing",
  4411. .codec_name = "msm-stub-codec.1",
  4412. .codec_dai_name = "msm-stub-tx",
  4413. .no_pcm = 1,
  4414. .dpcm_capture = 1,
  4415. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  4416. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4417. .ops = &msm_mi2s_be_ops,
  4418. .ignore_suspend = 1,
  4419. },
  4420. {
  4421. .name = LPASS_BE_TERT_MI2S_RX,
  4422. .stream_name = "Tertiary MI2S Playback",
  4423. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4424. .platform_name = "msm-pcm-routing",
  4425. .codec_name = "msm-stub-codec.1",
  4426. .codec_dai_name = "msm-stub-rx",
  4427. .no_pcm = 1,
  4428. .dpcm_playback = 1,
  4429. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  4430. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4431. .ops = &msm_mi2s_be_ops,
  4432. .ignore_suspend = 1,
  4433. .ignore_pmdown_time = 1,
  4434. },
  4435. {
  4436. .name = LPASS_BE_TERT_MI2S_TX,
  4437. .stream_name = "Tertiary MI2S Capture",
  4438. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4439. .platform_name = "msm-pcm-routing",
  4440. .codec_name = "msm-stub-codec.1",
  4441. .codec_dai_name = "msm-stub-tx",
  4442. .no_pcm = 1,
  4443. .dpcm_capture = 1,
  4444. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  4445. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4446. .ops = &msm_mi2s_be_ops,
  4447. .ignore_suspend = 1,
  4448. },
  4449. };
  4450. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  4451. /* Primary AUX PCM Backend DAI Links */
  4452. {
  4453. .name = LPASS_BE_AUXPCM_RX,
  4454. .stream_name = "AUX PCM Playback",
  4455. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4456. .platform_name = "msm-pcm-routing",
  4457. .codec_name = "msm-stub-codec.1",
  4458. .codec_dai_name = "msm-stub-rx",
  4459. .no_pcm = 1,
  4460. .dpcm_playback = 1,
  4461. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4462. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4463. .ignore_pmdown_time = 1,
  4464. .ignore_suspend = 1,
  4465. },
  4466. {
  4467. .name = LPASS_BE_AUXPCM_TX,
  4468. .stream_name = "AUX PCM Capture",
  4469. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4470. .platform_name = "msm-pcm-routing",
  4471. .codec_name = "msm-stub-codec.1",
  4472. .codec_dai_name = "msm-stub-tx",
  4473. .no_pcm = 1,
  4474. .dpcm_capture = 1,
  4475. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4476. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4477. .ignore_suspend = 1,
  4478. },
  4479. /* Secondary AUX PCM Backend DAI Links */
  4480. {
  4481. .name = LPASS_BE_SEC_AUXPCM_RX,
  4482. .stream_name = "Sec AUX PCM Playback",
  4483. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4484. .platform_name = "msm-pcm-routing",
  4485. .codec_name = "msm-stub-codec.1",
  4486. .codec_dai_name = "msm-stub-rx",
  4487. .no_pcm = 1,
  4488. .dpcm_playback = 1,
  4489. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  4490. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4491. .ignore_pmdown_time = 1,
  4492. .ignore_suspend = 1,
  4493. },
  4494. {
  4495. .name = LPASS_BE_SEC_AUXPCM_TX,
  4496. .stream_name = "Sec AUX PCM Capture",
  4497. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4498. .platform_name = "msm-pcm-routing",
  4499. .codec_name = "msm-stub-codec.1",
  4500. .codec_dai_name = "msm-stub-tx",
  4501. .no_pcm = 1,
  4502. .dpcm_capture = 1,
  4503. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  4504. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4505. .ignore_suspend = 1,
  4506. },
  4507. /* Tertiary AUX PCM Backend DAI Links */
  4508. {
  4509. .name = LPASS_BE_TERT_AUXPCM_RX,
  4510. .stream_name = "Tert AUX PCM Playback",
  4511. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4512. .platform_name = "msm-pcm-routing",
  4513. .codec_name = "msm-stub-codec.1",
  4514. .codec_dai_name = "msm-stub-rx",
  4515. .no_pcm = 1,
  4516. .dpcm_playback = 1,
  4517. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  4518. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4519. .ignore_suspend = 1,
  4520. },
  4521. {
  4522. .name = LPASS_BE_TERT_AUXPCM_TX,
  4523. .stream_name = "Tert AUX PCM Capture",
  4524. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4525. .platform_name = "msm-pcm-routing",
  4526. .codec_name = "msm-stub-codec.1",
  4527. .codec_dai_name = "msm-stub-tx",
  4528. .no_pcm = 1,
  4529. .dpcm_capture = 1,
  4530. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  4531. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4532. .ignore_suspend = 1,
  4533. },
  4534. };
  4535. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  4536. /* WSA CDC DMA Backend DAI Links */
  4537. {
  4538. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  4539. .stream_name = "WSA CDC DMA0 Playback",
  4540. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  4541. .platform_name = "msm-pcm-routing",
  4542. .codec_name = "bolero_codec",
  4543. .codec_dai_name = "wsa_macro_rx1",
  4544. .no_pcm = 1,
  4545. .dpcm_playback = 1,
  4546. .init = &msm_int_audrx_init,
  4547. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  4548. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4549. .ignore_pmdown_time = 1,
  4550. .ignore_suspend = 1,
  4551. .ops = &msm_cdc_dma_be_ops,
  4552. },
  4553. {
  4554. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  4555. .stream_name = "WSA CDC DMA1 Playback",
  4556. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  4557. .platform_name = "msm-pcm-routing",
  4558. .codec_name = "bolero_codec",
  4559. .codec_dai_name = "wsa_macro_rx_mix",
  4560. .no_pcm = 1,
  4561. .dpcm_playback = 1,
  4562. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  4563. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4564. .ignore_pmdown_time = 1,
  4565. .ignore_suspend = 1,
  4566. .ops = &msm_cdc_dma_be_ops,
  4567. },
  4568. {
  4569. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  4570. .stream_name = "WSA CDC DMA1 Capture",
  4571. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  4572. .platform_name = "msm-pcm-routing",
  4573. .codec_name = "bolero_codec",
  4574. .codec_dai_name = "wsa_macro_echo",
  4575. .no_pcm = 1,
  4576. .dpcm_capture = 1,
  4577. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  4578. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4579. .ignore_suspend = 1,
  4580. .ops = &msm_cdc_dma_be_ops,
  4581. },
  4582. };
  4583. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  4584. /* RX CDC DMA Backend DAI Links */
  4585. {
  4586. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  4587. .stream_name = "RX CDC DMA0 Playback",
  4588. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  4589. .platform_name = "msm-pcm-routing",
  4590. .codec_name = "bolero_codec",
  4591. .codec_dai_name = "rx_macro_rx1",
  4592. .no_pcm = 1,
  4593. .dpcm_playback = 1,
  4594. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  4595. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4596. .ignore_pmdown_time = 1,
  4597. .ignore_suspend = 1,
  4598. .ops = &msm_cdc_dma_be_ops,
  4599. },
  4600. {
  4601. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  4602. .stream_name = "RX CDC DMA1 Playback",
  4603. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  4604. .platform_name = "msm-pcm-routing",
  4605. .codec_name = "bolero_codec",
  4606. .codec_dai_name = "rx_macro_rx2",
  4607. .no_pcm = 1,
  4608. .dpcm_playback = 1,
  4609. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  4610. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4611. .ignore_pmdown_time = 1,
  4612. .ignore_suspend = 1,
  4613. .ops = &msm_cdc_dma_be_ops,
  4614. },
  4615. {
  4616. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  4617. .stream_name = "RX CDC DMA2 Playback",
  4618. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  4619. .platform_name = "msm-pcm-routing",
  4620. .codec_name = "bolero_codec",
  4621. .codec_dai_name = "rx_macro_rx3",
  4622. .no_pcm = 1,
  4623. .dpcm_playback = 1,
  4624. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  4625. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4626. .ignore_pmdown_time = 1,
  4627. .ignore_suspend = 1,
  4628. .ops = &msm_cdc_dma_be_ops,
  4629. },
  4630. {
  4631. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  4632. .stream_name = "RX CDC DMA3 Playback",
  4633. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  4634. .platform_name = "msm-pcm-routing",
  4635. .codec_name = "bolero_codec",
  4636. .codec_dai_name = "rx_macro_rx4",
  4637. .no_pcm = 1,
  4638. .dpcm_playback = 1,
  4639. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  4640. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4641. .ignore_pmdown_time = 1,
  4642. .ignore_suspend = 1,
  4643. .ops = &msm_cdc_dma_be_ops,
  4644. },
  4645. /* TX CDC DMA Backend DAI Links */
  4646. {
  4647. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  4648. .stream_name = "TX CDC DMA3 Capture",
  4649. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  4650. .platform_name = "msm-pcm-routing",
  4651. .codec_name = "bolero_codec",
  4652. .codec_dai_name = "tx_macro_tx1",
  4653. .no_pcm = 1,
  4654. .dpcm_capture = 1,
  4655. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  4656. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4657. .ignore_suspend = 1,
  4658. .ops = &msm_cdc_dma_be_ops,
  4659. },
  4660. {
  4661. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  4662. .stream_name = "TX CDC DMA4 Capture",
  4663. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  4664. .platform_name = "msm-pcm-routing",
  4665. .codec_name = "bolero_codec",
  4666. .codec_dai_name = "tx_macro_tx2",
  4667. .no_pcm = 1,
  4668. .dpcm_capture = 1,
  4669. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  4670. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4671. .ignore_suspend = 1,
  4672. .ops = &msm_cdc_dma_be_ops,
  4673. },
  4674. };
  4675. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  4676. {
  4677. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  4678. .stream_name = "VA CDC DMA0 Capture",
  4679. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  4680. .platform_name = "msm-pcm-routing",
  4681. .codec_name = "bolero_codec",
  4682. .codec_dai_name = "va_macro_tx1",
  4683. .no_pcm = 1,
  4684. .dpcm_capture = 1,
  4685. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  4686. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4687. .ignore_suspend = 1,
  4688. .ops = &msm_cdc_dma_be_ops,
  4689. },
  4690. {
  4691. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  4692. .stream_name = "VA CDC DMA1 Capture",
  4693. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  4694. .platform_name = "msm-pcm-routing",
  4695. .codec_name = "bolero_codec",
  4696. .codec_dai_name = "va_macro_tx2",
  4697. .no_pcm = 1,
  4698. .dpcm_capture = 1,
  4699. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  4700. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4701. .ignore_suspend = 1,
  4702. .ops = &msm_cdc_dma_be_ops,
  4703. },
  4704. {
  4705. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  4706. .stream_name = "VA CDC DMA2 Capture",
  4707. .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
  4708. .platform_name = "msm-pcm-routing",
  4709. .codec_name = "bolero_codec",
  4710. .codec_dai_name = "va_macro_tx3",
  4711. .no_pcm = 1,
  4712. .dpcm_capture = 1,
  4713. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  4714. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4715. .ignore_suspend = 1,
  4716. .ops = &msm_cdc_dma_be_ops,
  4717. },
  4718. };
  4719. static struct snd_soc_dai_link msm_kona_dai_links[
  4720. ARRAY_SIZE(msm_common_dai_links) +
  4721. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  4722. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  4723. ARRAY_SIZE(msm_common_be_dai_links) +
  4724. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  4725. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  4726. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  4727. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  4728. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  4729. ARRAY_SIZE(ext_disp_be_dai_link) +
  4730. ARRAY_SIZE(msm_wcn_be_dai_links)];
  4731. static int msm_populate_dai_link_component_of_node(
  4732. struct snd_soc_card *card)
  4733. {
  4734. int i, index, ret = 0;
  4735. struct device *cdev = card->dev;
  4736. struct snd_soc_dai_link *dai_link = card->dai_link;
  4737. struct device_node *np;
  4738. if (!cdev) {
  4739. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  4740. return -ENODEV;
  4741. }
  4742. for (i = 0; i < card->num_links; i++) {
  4743. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  4744. continue;
  4745. /* populate platform_of_node for snd card dai links */
  4746. if (dai_link[i].platform_name &&
  4747. !dai_link[i].platform_of_node) {
  4748. index = of_property_match_string(cdev->of_node,
  4749. "asoc-platform-names",
  4750. dai_link[i].platform_name);
  4751. if (index < 0) {
  4752. dev_err(cdev, "%s: No match found for platform name: %s\n",
  4753. __func__, dai_link[i].platform_name);
  4754. ret = index;
  4755. goto err;
  4756. }
  4757. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  4758. index);
  4759. if (!np) {
  4760. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  4761. __func__, dai_link[i].platform_name,
  4762. index);
  4763. ret = -ENODEV;
  4764. goto err;
  4765. }
  4766. dai_link[i].platform_of_node = np;
  4767. dai_link[i].platform_name = NULL;
  4768. }
  4769. /* populate cpu_of_node for snd card dai links */
  4770. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  4771. index = of_property_match_string(cdev->of_node,
  4772. "asoc-cpu-names",
  4773. dai_link[i].cpu_dai_name);
  4774. if (index >= 0) {
  4775. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  4776. index);
  4777. if (!np) {
  4778. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  4779. __func__,
  4780. dai_link[i].cpu_dai_name);
  4781. ret = -ENODEV;
  4782. goto err;
  4783. }
  4784. dai_link[i].cpu_of_node = np;
  4785. dai_link[i].cpu_dai_name = NULL;
  4786. }
  4787. }
  4788. /* populate codec_of_node for snd card dai links */
  4789. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  4790. index = of_property_match_string(cdev->of_node,
  4791. "asoc-codec-names",
  4792. dai_link[i].codec_name);
  4793. if (index < 0)
  4794. continue;
  4795. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  4796. index);
  4797. if (!np) {
  4798. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  4799. __func__, dai_link[i].codec_name);
  4800. ret = -ENODEV;
  4801. goto err;
  4802. }
  4803. dai_link[i].codec_of_node = np;
  4804. dai_link[i].codec_name = NULL;
  4805. }
  4806. }
  4807. err:
  4808. return ret;
  4809. }
  4810. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  4811. {
  4812. int ret = -EINVAL;
  4813. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  4814. if (!component) {
  4815. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  4816. return ret;
  4817. }
  4818. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  4819. ARRAY_SIZE(msm_snd_controls));
  4820. if (ret < 0) {
  4821. dev_err(component->dev,
  4822. "%s: add_codec_controls failed, err = %d\n",
  4823. __func__, ret);
  4824. return ret;
  4825. }
  4826. return ret;
  4827. }
  4828. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  4829. struct snd_pcm_hw_params *params)
  4830. {
  4831. return 0;
  4832. }
  4833. static struct snd_soc_ops msm_stub_be_ops = {
  4834. .hw_params = msm_snd_stub_hw_params,
  4835. };
  4836. struct snd_soc_card snd_soc_card_stub_msm = {
  4837. .name = "kona-stub-snd-card",
  4838. };
  4839. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  4840. /* FrontEnd DAI Links */
  4841. {
  4842. .name = "MSMSTUB Media1",
  4843. .stream_name = "MultiMedia1",
  4844. .cpu_dai_name = "MultiMedia1",
  4845. .platform_name = "msm-pcm-dsp.0",
  4846. .dynamic = 1,
  4847. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4848. .dpcm_playback = 1,
  4849. .dpcm_capture = 1,
  4850. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4851. SND_SOC_DPCM_TRIGGER_POST},
  4852. .codec_dai_name = "snd-soc-dummy-dai",
  4853. .codec_name = "snd-soc-dummy",
  4854. .ignore_suspend = 1,
  4855. /* this dainlink has playback support */
  4856. .ignore_pmdown_time = 1,
  4857. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  4858. },
  4859. };
  4860. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  4861. /* Backend DAI Links */
  4862. {
  4863. .name = LPASS_BE_AUXPCM_RX,
  4864. .stream_name = "AUX PCM Playback",
  4865. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4866. .platform_name = "msm-pcm-routing",
  4867. .codec_name = "msm-stub-codec.1",
  4868. .codec_dai_name = "msm-stub-rx",
  4869. .no_pcm = 1,
  4870. .dpcm_playback = 1,
  4871. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4872. .init = &msm_audrx_stub_init,
  4873. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4874. .ignore_pmdown_time = 1,
  4875. .ignore_suspend = 1,
  4876. .ops = &msm_stub_be_ops,
  4877. },
  4878. {
  4879. .name = LPASS_BE_AUXPCM_TX,
  4880. .stream_name = "AUX PCM Capture",
  4881. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4882. .platform_name = "msm-pcm-routing",
  4883. .codec_name = "msm-stub-codec.1",
  4884. .codec_dai_name = "msm-stub-tx",
  4885. .no_pcm = 1,
  4886. .dpcm_capture = 1,
  4887. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4888. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4889. .ignore_suspend = 1,
  4890. .ops = &msm_stub_be_ops,
  4891. },
  4892. };
  4893. static struct snd_soc_dai_link msm_stub_dai_links[
  4894. ARRAY_SIZE(msm_stub_fe_dai_links) +
  4895. ARRAY_SIZE(msm_stub_be_dai_links)];
  4896. static const struct of_device_id kona_asoc_machine_of_match[] = {
  4897. { .compatible = "qcom,kona-asoc-snd",
  4898. .data = "codec"},
  4899. { .compatible = "qcom,kona-asoc-snd-stub",
  4900. .data = "stub_codec"},
  4901. {},
  4902. };
  4903. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  4904. {
  4905. struct snd_soc_card *card = NULL;
  4906. struct snd_soc_dai_link *dailink = NULL;
  4907. int len_1 = 0;
  4908. int len_2 = 0;
  4909. int total_links = 0;
  4910. int rc = 0;
  4911. u32 mi2s_audio_intf = 0;
  4912. u32 auxpcm_audio_intf = 0;
  4913. u32 val = 0;
  4914. const struct of_device_id *match;
  4915. match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
  4916. if (!match) {
  4917. dev_err(dev, "%s: No DT match found for sound card\n",
  4918. __func__);
  4919. return NULL;
  4920. }
  4921. if (!strcmp(match->data, "codec")) {
  4922. card = &snd_soc_card_kona_msm;
  4923. memcpy(msm_kona_dai_links + total_links,
  4924. msm_common_dai_links,
  4925. sizeof(msm_common_dai_links));
  4926. total_links += ARRAY_SIZE(msm_common_dai_links);
  4927. memcpy(msm_kona_dai_links + total_links,
  4928. msm_bolero_fe_dai_links,
  4929. sizeof(msm_bolero_fe_dai_links));
  4930. total_links +=
  4931. ARRAY_SIZE(msm_bolero_fe_dai_links);
  4932. memcpy(msm_kona_dai_links + total_links,
  4933. msm_common_misc_fe_dai_links,
  4934. sizeof(msm_common_misc_fe_dai_links));
  4935. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  4936. memcpy(msm_kona_dai_links + total_links,
  4937. msm_common_be_dai_links,
  4938. sizeof(msm_common_be_dai_links));
  4939. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  4940. memcpy(msm_kona_dai_links + total_links,
  4941. msm_wsa_cdc_dma_be_dai_links,
  4942. sizeof(msm_wsa_cdc_dma_be_dai_links));
  4943. total_links +=
  4944. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  4945. memcpy(msm_kona_dai_links + total_links,
  4946. msm_rx_tx_cdc_dma_be_dai_links,
  4947. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  4948. total_links +=
  4949. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  4950. memcpy(msm_kona_dai_links + total_links,
  4951. msm_va_cdc_dma_be_dai_links,
  4952. sizeof(msm_va_cdc_dma_be_dai_links));
  4953. total_links +=
  4954. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  4955. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  4956. &mi2s_audio_intf);
  4957. if (rc) {
  4958. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  4959. __func__);
  4960. } else {
  4961. if (mi2s_audio_intf) {
  4962. memcpy(msm_kona_dai_links + total_links,
  4963. msm_mi2s_be_dai_links,
  4964. sizeof(msm_mi2s_be_dai_links));
  4965. total_links +=
  4966. ARRAY_SIZE(msm_mi2s_be_dai_links);
  4967. }
  4968. }
  4969. rc = of_property_read_u32(dev->of_node,
  4970. "qcom,auxpcm-audio-intf",
  4971. &auxpcm_audio_intf);
  4972. if (rc) {
  4973. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  4974. __func__);
  4975. } else {
  4976. if (auxpcm_audio_intf) {
  4977. memcpy(msm_kona_dai_links + total_links,
  4978. msm_auxpcm_be_dai_links,
  4979. sizeof(msm_auxpcm_be_dai_links));
  4980. total_links +=
  4981. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  4982. }
  4983. }
  4984. rc = of_property_read_u32(dev->of_node,
  4985. "qcom,ext-disp-audio-rx", &val);
  4986. if (!rc && val) {
  4987. dev_dbg(dev, "%s(): ext disp audio support present\n",
  4988. __func__);
  4989. memcpy(msm_kona_dai_links + total_links,
  4990. ext_disp_be_dai_link,
  4991. sizeof(ext_disp_be_dai_link));
  4992. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  4993. }
  4994. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  4995. if (!rc && val) {
  4996. dev_dbg(dev, "%s(): WCN BT support present\n",
  4997. __func__);
  4998. memcpy(msm_kona_dai_links + total_links,
  4999. msm_wcn_be_dai_links,
  5000. sizeof(msm_wcn_be_dai_links));
  5001. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  5002. }
  5003. dailink = msm_kona_dai_links;
  5004. } else if(!strcmp(match->data, "stub_codec")) {
  5005. card = &snd_soc_card_stub_msm;
  5006. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  5007. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  5008. memcpy(msm_stub_dai_links,
  5009. msm_stub_fe_dai_links,
  5010. sizeof(msm_stub_fe_dai_links));
  5011. memcpy(msm_stub_dai_links + len_1,
  5012. msm_stub_be_dai_links,
  5013. sizeof(msm_stub_be_dai_links));
  5014. dailink = msm_stub_dai_links;
  5015. total_links = len_2;
  5016. }
  5017. if (card) {
  5018. card->dai_link = dailink;
  5019. card->num_links = total_links;
  5020. }
  5021. return card;
  5022. }
  5023. static int msm_wsa881x_init(struct snd_soc_component *component)
  5024. {
  5025. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5026. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5027. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  5028. SPKR_L_BOOST, SPKR_L_VI};
  5029. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  5030. SPKR_R_BOOST, SPKR_R_VI};
  5031. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  5032. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  5033. struct msm_asoc_mach_data *pdata;
  5034. struct snd_soc_dapm_context *dapm;
  5035. struct snd_card *card;
  5036. struct snd_info_entry *entry;
  5037. int ret = 0;
  5038. if (!component) {
  5039. pr_err("%s component is NULL\n", __func__);
  5040. return -EINVAL;
  5041. }
  5042. card = component->card->snd_card;
  5043. dapm = snd_soc_component_get_dapm(component);
  5044. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  5045. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  5046. __func__, component->name);
  5047. wsa881x_set_channel_map(component, &spkleft_ports[0],
  5048. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5049. &ch_rate[0], &spkleft_port_types[0]);
  5050. if (dapm->component) {
  5051. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  5052. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  5053. }
  5054. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  5055. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  5056. __func__, component->name);
  5057. wsa881x_set_channel_map(component, &spkright_ports[0],
  5058. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5059. &ch_rate[0], &spkright_port_types[0]);
  5060. if (dapm->component) {
  5061. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  5062. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  5063. }
  5064. } else {
  5065. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  5066. component->name);
  5067. ret = -EINVAL;
  5068. goto err;
  5069. }
  5070. pdata = snd_soc_card_get_drvdata(component->card);
  5071. if (!pdata->codec_root) {
  5072. entry = snd_info_create_subdir(card->module, "codecs",
  5073. card->proc_root);
  5074. if (!entry) {
  5075. pr_err("%s: Cannot create codecs module entry\n",
  5076. __func__);
  5077. ret = 0;
  5078. goto err;
  5079. }
  5080. pdata->codec_root = entry;
  5081. }
  5082. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  5083. component);
  5084. err:
  5085. return ret;
  5086. }
  5087. static int msm_aux_codec_init(struct snd_soc_component *component)
  5088. {
  5089. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  5090. int ret = 0;
  5091. void *mbhc_calibration;
  5092. struct snd_info_entry *entry;
  5093. struct snd_card *card = component->card->snd_card;
  5094. struct msm_asoc_mach_data *pdata;
  5095. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  5096. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  5097. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  5098. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  5099. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  5100. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  5101. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  5102. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  5103. snd_soc_dapm_sync(dapm);
  5104. pdata = snd_soc_card_get_drvdata(component->card);
  5105. if (!pdata->codec_root) {
  5106. entry = snd_info_create_subdir(card->module, "codecs",
  5107. card->proc_root);
  5108. if (!entry) {
  5109. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  5110. __func__);
  5111. ret = 0;
  5112. goto mbhc_cfg_cal;
  5113. }
  5114. pdata->codec_root = entry;
  5115. }
  5116. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  5117. mbhc_cfg_cal:
  5118. mbhc_calibration = def_wcd_mbhc_cal();
  5119. if (!mbhc_calibration)
  5120. return -ENOMEM;
  5121. wcd_mbhc_cfg.calibration = mbhc_calibration;
  5122. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  5123. if (ret) {
  5124. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  5125. __func__, ret);
  5126. goto err_hs_detect;
  5127. }
  5128. return 0;
  5129. err_hs_detect:
  5130. kfree(mbhc_calibration);
  5131. return ret;
  5132. }
  5133. static int msm_init_aux_dev(struct platform_device *pdev,
  5134. struct snd_soc_card *card)
  5135. {
  5136. struct device_node *wsa_of_node;
  5137. struct device_node *aux_codec_of_node;
  5138. u32 wsa_max_devs;
  5139. u32 wsa_dev_cnt;
  5140. u32 codec_aux_dev_cnt = 0;
  5141. u32 bolero_codec = 0;
  5142. int i;
  5143. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  5144. struct aux_codec_dev_info *aux_cdc_dev_info;
  5145. const char *auxdev_name_prefix[1];
  5146. char *dev_name_str = NULL;
  5147. int found = 0;
  5148. int codecs_found = 0;
  5149. int ret = 0;
  5150. /* Get maximum WSA device count for this platform */
  5151. ret = of_property_read_u32(pdev->dev.of_node,
  5152. "qcom,wsa-max-devs", &wsa_max_devs);
  5153. if (ret) {
  5154. dev_info(&pdev->dev,
  5155. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  5156. __func__, pdev->dev.of_node->full_name, ret);
  5157. wsa_max_devs = 0;
  5158. goto codec_aux_dev;
  5159. }
  5160. if (wsa_max_devs == 0) {
  5161. dev_warn(&pdev->dev,
  5162. "%s: Max WSA devices is 0 for this target?\n",
  5163. __func__);
  5164. goto codec_aux_dev;
  5165. }
  5166. /* Get count of WSA device phandles for this platform */
  5167. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  5168. "qcom,wsa-devs", NULL);
  5169. if (wsa_dev_cnt == -ENOENT) {
  5170. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  5171. __func__);
  5172. goto err;
  5173. } else if (wsa_dev_cnt <= 0) {
  5174. dev_err(&pdev->dev,
  5175. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  5176. __func__, wsa_dev_cnt);
  5177. ret = -EINVAL;
  5178. goto err;
  5179. }
  5180. /*
  5181. * Expect total phandles count to be NOT less than maximum possible
  5182. * WSA count. However, if it is less, then assign same value to
  5183. * max count as well.
  5184. */
  5185. if (wsa_dev_cnt < wsa_max_devs) {
  5186. dev_dbg(&pdev->dev,
  5187. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  5188. __func__, wsa_max_devs, wsa_dev_cnt);
  5189. wsa_max_devs = wsa_dev_cnt;
  5190. }
  5191. /* Make sure prefix string passed for each WSA device */
  5192. ret = of_property_count_strings(pdev->dev.of_node,
  5193. "qcom,wsa-aux-dev-prefix");
  5194. if (ret != wsa_dev_cnt) {
  5195. dev_err(&pdev->dev,
  5196. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  5197. __func__, wsa_dev_cnt, ret);
  5198. ret = -EINVAL;
  5199. goto err;
  5200. }
  5201. /*
  5202. * Alloc mem to store phandle and index info of WSA device, if already
  5203. * registered with ALSA core
  5204. */
  5205. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  5206. sizeof(struct msm_wsa881x_dev_info),
  5207. GFP_KERNEL);
  5208. if (!wsa881x_dev_info) {
  5209. ret = -ENOMEM;
  5210. goto err;
  5211. }
  5212. /*
  5213. * search and check whether all WSA devices are already
  5214. * registered with ALSA core or not. If found a node, store
  5215. * the node and the index in a local array of struct for later
  5216. * use.
  5217. */
  5218. for (i = 0; i < wsa_dev_cnt; i++) {
  5219. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  5220. "qcom,wsa-devs", i);
  5221. if (unlikely(!wsa_of_node)) {
  5222. /* we should not be here */
  5223. dev_err(&pdev->dev,
  5224. "%s: wsa dev node is not present\n",
  5225. __func__);
  5226. ret = -EINVAL;
  5227. goto err;
  5228. }
  5229. if (soc_find_component(wsa_of_node, NULL)) {
  5230. /* WSA device registered with ALSA core */
  5231. wsa881x_dev_info[found].of_node = wsa_of_node;
  5232. wsa881x_dev_info[found].index = i;
  5233. found++;
  5234. if (found == wsa_max_devs)
  5235. break;
  5236. }
  5237. }
  5238. if (found < wsa_max_devs) {
  5239. dev_dbg(&pdev->dev,
  5240. "%s: failed to find %d components. Found only %d\n",
  5241. __func__, wsa_max_devs, found);
  5242. return -EPROBE_DEFER;
  5243. }
  5244. dev_info(&pdev->dev,
  5245. "%s: found %d wsa881x devices registered with ALSA core\n",
  5246. __func__, found);
  5247. codec_aux_dev:
  5248. ret = of_property_read_u32(pdev->dev.of_node, "qcom,bolero-codec", &bolero_codec);
  5249. if (ret)
  5250. dev_dbg(&pdev->dev, "%s: No DT match for bolero codec\n", __func__);
  5251. if (bolero_codec) {
  5252. /* Get count of aux codec device phandles for this platform */
  5253. codec_aux_dev_cnt = of_count_phandle_with_args(
  5254. pdev->dev.of_node,
  5255. "qcom,codec-aux-devs", NULL);
  5256. if (codec_aux_dev_cnt == -ENOENT) {
  5257. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  5258. __func__);
  5259. goto err;
  5260. } else if (codec_aux_dev_cnt <= 0) {
  5261. dev_err(&pdev->dev,
  5262. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  5263. __func__, codec_aux_dev_cnt);
  5264. ret = -EINVAL;
  5265. goto err;
  5266. }
  5267. /*
  5268. * Alloc mem to store phandle and index info of aux codec
  5269. * if already registered with ALSA core
  5270. */
  5271. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
  5272. sizeof(struct aux_codec_dev_info),
  5273. GFP_KERNEL);
  5274. if (!aux_cdc_dev_info) {
  5275. ret = -ENOMEM;
  5276. goto err;
  5277. }
  5278. /*
  5279. * search and check whether all aux codecs are already
  5280. * registered with ALSA core or not. If found a node, store
  5281. * the node and the index in a local array of struct for later
  5282. * use.
  5283. */
  5284. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5285. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  5286. "qcom,codec-aux-devs", i);
  5287. if (unlikely(!aux_codec_of_node)) {
  5288. /* we should not be here */
  5289. dev_err(&pdev->dev,
  5290. "%s: aux codec dev node is not present\n",
  5291. __func__);
  5292. ret = -EINVAL;
  5293. goto err;
  5294. }
  5295. if (soc_find_component(aux_codec_of_node, NULL)) {
  5296. /* AUX codec registered with ALSA core */
  5297. aux_cdc_dev_info[codecs_found].of_node =
  5298. aux_codec_of_node;
  5299. aux_cdc_dev_info[codecs_found].index = i;
  5300. codecs_found++;
  5301. }
  5302. }
  5303. if (codecs_found < codec_aux_dev_cnt) {
  5304. dev_dbg(&pdev->dev,
  5305. "%s: failed to find %d components. Found only %d\n",
  5306. __func__, codec_aux_dev_cnt, codecs_found);
  5307. return -EPROBE_DEFER;
  5308. }
  5309. dev_info(&pdev->dev,
  5310. "%s: found %d AUX codecs registered with ALSA core\n",
  5311. __func__, codecs_found);
  5312. }
  5313. card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
  5314. card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
  5315. /* Alloc array of AUX devs struct */
  5316. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  5317. sizeof(struct snd_soc_aux_dev),
  5318. GFP_KERNEL);
  5319. if (!msm_aux_dev) {
  5320. ret = -ENOMEM;
  5321. goto err;
  5322. }
  5323. /* Alloc array of codec conf struct */
  5324. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  5325. sizeof(struct snd_soc_codec_conf),
  5326. GFP_KERNEL);
  5327. if (!msm_codec_conf) {
  5328. ret = -ENOMEM;
  5329. goto err;
  5330. }
  5331. for (i = 0; i < wsa_max_devs; i++) {
  5332. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  5333. GFP_KERNEL);
  5334. if (!dev_name_str) {
  5335. ret = -ENOMEM;
  5336. goto err;
  5337. }
  5338. ret = of_property_read_string_index(pdev->dev.of_node,
  5339. "qcom,wsa-aux-dev-prefix",
  5340. wsa881x_dev_info[i].index,
  5341. auxdev_name_prefix);
  5342. if (ret) {
  5343. dev_err(&pdev->dev,
  5344. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  5345. __func__, ret);
  5346. ret = -EINVAL;
  5347. goto err;
  5348. }
  5349. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  5350. msm_aux_dev[i].name = dev_name_str;
  5351. msm_aux_dev[i].codec_name = NULL;
  5352. msm_aux_dev[i].codec_of_node =
  5353. wsa881x_dev_info[i].of_node;
  5354. msm_aux_dev[i].init = msm_wsa881x_init;
  5355. msm_codec_conf[i].dev_name = NULL;
  5356. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  5357. msm_codec_conf[i].of_node =
  5358. wsa881x_dev_info[i].of_node;
  5359. }
  5360. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5361. msm_aux_dev[wsa_max_devs + i].name = NULL;
  5362. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  5363. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  5364. aux_cdc_dev_info[i].of_node;
  5365. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  5366. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  5367. msm_codec_conf[wsa_max_devs + i].name_prefix =
  5368. NULL;
  5369. msm_codec_conf[wsa_max_devs + i].of_node =
  5370. aux_cdc_dev_info[i].of_node;
  5371. }
  5372. card->codec_conf = msm_codec_conf;
  5373. card->aux_dev = msm_aux_dev;
  5374. err:
  5375. return ret;
  5376. }
  5377. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  5378. {
  5379. int count = 0;
  5380. u32 mi2s_master_slave[MI2S_MAX];
  5381. int ret = 0;
  5382. for (count = 0; count < MI2S_MAX; count++) {
  5383. mutex_init(&mi2s_intf_conf[count].lock);
  5384. mi2s_intf_conf[count].ref_cnt = 0;
  5385. }
  5386. ret = of_property_read_u32_array(pdev->dev.of_node,
  5387. "qcom,msm-mi2s-master",
  5388. mi2s_master_slave, MI2S_MAX);
  5389. if (ret) {
  5390. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  5391. __func__);
  5392. } else {
  5393. for (count = 0; count < MI2S_MAX; count++) {
  5394. mi2s_intf_conf[count].msm_is_mi2s_master =
  5395. mi2s_master_slave[count];
  5396. }
  5397. }
  5398. }
  5399. static void msm_i2s_auxpcm_deinit(void)
  5400. {
  5401. int count = 0;
  5402. for (count = 0; count < MI2S_MAX; count++) {
  5403. mutex_destroy(&mi2s_intf_conf[count].lock);
  5404. mi2s_intf_conf[count].ref_cnt = 0;
  5405. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  5406. }
  5407. }
  5408. static int kona_ssr_enable(struct device *dev, void *data)
  5409. {
  5410. struct platform_device *pdev = to_platform_device(dev);
  5411. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5412. int ret = 0;
  5413. if (!card) {
  5414. dev_err(dev, "%s: card is NULL\n", __func__);
  5415. ret = -EINVAL;
  5416. goto err;
  5417. }
  5418. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5419. /* TODO */
  5420. dev_dbg(dev, "%s: TODO \n", __func__);
  5421. }
  5422. snd_soc_card_change_online_state(card, 1);
  5423. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  5424. err:
  5425. return ret;
  5426. }
  5427. static void kona_ssr_disable(struct device *dev, void *data)
  5428. {
  5429. struct platform_device *pdev = to_platform_device(dev);
  5430. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5431. if (!card) {
  5432. dev_err(dev, "%s: card is NULL\n", __func__);
  5433. return;
  5434. }
  5435. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  5436. snd_soc_card_change_online_state(card, 0);
  5437. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5438. /* TODO */
  5439. dev_dbg(dev, "%s: TODO \n", __func__);
  5440. }
  5441. }
  5442. static const struct snd_event_ops kona_ssr_ops = {
  5443. .enable = kona_ssr_enable,
  5444. .disable = kona_ssr_disable,
  5445. };
  5446. static int msm_audio_ssr_compare(struct device *dev, void *data)
  5447. {
  5448. struct device_node *node = data;
  5449. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  5450. __func__, dev->of_node, node);
  5451. return (dev->of_node && dev->of_node == node);
  5452. }
  5453. static int msm_audio_ssr_register(struct device *dev)
  5454. {
  5455. struct device_node *np = dev->of_node;
  5456. struct snd_event_clients *ssr_clients = NULL;
  5457. struct device_node *node = NULL;
  5458. int ret = 0;
  5459. int i = 0;
  5460. for (i = 0; ; i++) {
  5461. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  5462. if (!node)
  5463. break;
  5464. snd_event_mstr_add_client(&ssr_clients,
  5465. msm_audio_ssr_compare, node);
  5466. }
  5467. ret = snd_event_master_register(dev, &kona_ssr_ops,
  5468. ssr_clients, NULL);
  5469. if (!ret)
  5470. snd_event_notify(dev, SND_EVENT_UP);
  5471. return ret;
  5472. }
  5473. static int msm_asoc_machine_probe(struct platform_device *pdev)
  5474. {
  5475. struct snd_soc_card *card = NULL;
  5476. struct msm_asoc_mach_data *pdata = NULL;
  5477. const char *mbhc_audio_jack_type = NULL;
  5478. int ret = 0;
  5479. if (!pdev->dev.of_node) {
  5480. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  5481. return -EINVAL;
  5482. }
  5483. pdata = devm_kzalloc(&pdev->dev,
  5484. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  5485. if (!pdata)
  5486. return -ENOMEM;
  5487. card = populate_snd_card_dailinks(&pdev->dev);
  5488. if (!card) {
  5489. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  5490. ret = -EINVAL;
  5491. goto err;
  5492. }
  5493. card->dev = &pdev->dev;
  5494. platform_set_drvdata(pdev, card);
  5495. snd_soc_card_set_drvdata(card, pdata);
  5496. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  5497. if (ret) {
  5498. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  5499. __func__, ret);
  5500. goto err;
  5501. }
  5502. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  5503. if (ret) {
  5504. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  5505. __func__, ret);
  5506. goto err;
  5507. }
  5508. ret = msm_populate_dai_link_component_of_node(card);
  5509. if (ret) {
  5510. ret = -EPROBE_DEFER;
  5511. goto err;
  5512. }
  5513. ret = msm_init_aux_dev(pdev, card);
  5514. if (ret)
  5515. goto err;
  5516. ret = devm_snd_soc_register_card(&pdev->dev, card);
  5517. if (ret == -EPROBE_DEFER) {
  5518. if (codec_reg_done)
  5519. ret = -EINVAL;
  5520. goto err;
  5521. } else if (ret) {
  5522. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  5523. __func__, ret);
  5524. goto err;
  5525. }
  5526. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  5527. __func__, card->name);
  5528. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5529. "qcom,hph-en1-gpio", 0);
  5530. if (!pdata->hph_en1_gpio_p) {
  5531. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5532. __func__, "qcom,hph-en1-gpio",
  5533. pdev->dev.of_node->full_name);
  5534. }
  5535. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5536. "qcom,hph-en0-gpio", 0);
  5537. if (!pdata->hph_en0_gpio_p) {
  5538. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5539. __func__, "qcom,hph-en0-gpio",
  5540. pdev->dev.of_node->full_name);
  5541. }
  5542. ret = of_property_read_string(pdev->dev.of_node,
  5543. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  5544. if (ret) {
  5545. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  5546. __func__, "qcom,mbhc-audio-jack-type",
  5547. pdev->dev.of_node->full_name);
  5548. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  5549. } else {
  5550. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  5551. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5552. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  5553. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  5554. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5555. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  5556. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  5557. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5558. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  5559. } else {
  5560. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5561. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  5562. }
  5563. }
  5564. /*
  5565. * Parse US-Euro gpio info from DT. Report no error if us-euro
  5566. * entry is not found in DT file as some targets do not support
  5567. * US-Euro detection
  5568. */
  5569. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5570. "qcom,us-euro-gpios", 0);
  5571. if (!pdata->us_euro_gpio_p) {
  5572. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  5573. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  5574. } else {
  5575. dev_dbg(&pdev->dev, "%s detected\n",
  5576. "qcom,us-euro-gpios");
  5577. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  5578. }
  5579. msm_i2s_auxpcm_init(pdev);
  5580. if (strcmp(card->name, "kona-mtp-snd-card")) {
  5581. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5582. "qcom,cdc-dmic01-gpios",
  5583. 0);
  5584. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5585. "qcom,cdc-dmic23-gpios",
  5586. 0);
  5587. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5588. "qcom,cdc-dmic45-gpios",
  5589. 0);
  5590. }
  5591. ret = msm_audio_ssr_register(&pdev->dev);
  5592. if (ret)
  5593. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  5594. __func__, ret);
  5595. is_initial_boot = true;
  5596. return 0;
  5597. err:
  5598. devm_kfree(&pdev->dev, pdata);
  5599. return ret;
  5600. }
  5601. static int msm_asoc_machine_remove(struct platform_device *pdev)
  5602. {
  5603. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5604. snd_event_master_deregister(&pdev->dev);
  5605. snd_soc_unregister_card(card);
  5606. msm_i2s_auxpcm_deinit();
  5607. return 0;
  5608. }
  5609. static struct platform_driver kona_asoc_machine_driver = {
  5610. .driver = {
  5611. .name = DRV_NAME,
  5612. .owner = THIS_MODULE,
  5613. .pm = &snd_soc_pm_ops,
  5614. .of_match_table = kona_asoc_machine_of_match,
  5615. },
  5616. .probe = msm_asoc_machine_probe,
  5617. .remove = msm_asoc_machine_remove,
  5618. };
  5619. module_platform_driver(kona_asoc_machine_driver);
  5620. MODULE_DESCRIPTION("ALSA SoC msm");
  5621. MODULE_LICENSE("GPL v2");
  5622. MODULE_ALIAS("platform:" DRV_NAME);
  5623. MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);