kona.c 222 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792
  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 "kona-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. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  69. enum {
  70. TDM_0 = 0,
  71. TDM_1,
  72. TDM_2,
  73. TDM_3,
  74. TDM_4,
  75. TDM_5,
  76. TDM_6,
  77. TDM_7,
  78. TDM_PORT_MAX,
  79. };
  80. enum {
  81. TDM_PRI = 0,
  82. TDM_SEC,
  83. TDM_TERT,
  84. TDM_QUAT,
  85. TDM_QUIN,
  86. TDM_SEN,
  87. TDM_INTERFACE_MAX,
  88. };
  89. enum {
  90. PRIM_AUX_PCM = 0,
  91. SEC_AUX_PCM,
  92. TERT_AUX_PCM,
  93. QUAT_AUX_PCM,
  94. QUIN_AUX_PCM,
  95. SEN_AUX_PCM,
  96. AUX_PCM_MAX,
  97. };
  98. enum {
  99. PRIM_MI2S = 0,
  100. SEC_MI2S,
  101. TERT_MI2S,
  102. QUAT_MI2S,
  103. QUIN_MI2S,
  104. SEN_MI2S,
  105. MI2S_MAX,
  106. };
  107. enum {
  108. WSA_CDC_DMA_RX_0 = 0,
  109. WSA_CDC_DMA_RX_1,
  110. RX_CDC_DMA_RX_0,
  111. RX_CDC_DMA_RX_1,
  112. RX_CDC_DMA_RX_2,
  113. RX_CDC_DMA_RX_3,
  114. RX_CDC_DMA_RX_5,
  115. CDC_DMA_RX_MAX,
  116. };
  117. enum {
  118. WSA_CDC_DMA_TX_0 = 0,
  119. WSA_CDC_DMA_TX_1,
  120. WSA_CDC_DMA_TX_2,
  121. TX_CDC_DMA_TX_0,
  122. TX_CDC_DMA_TX_3,
  123. TX_CDC_DMA_TX_4,
  124. VA_CDC_DMA_TX_0,
  125. VA_CDC_DMA_TX_1,
  126. VA_CDC_DMA_TX_2,
  127. CDC_DMA_TX_MAX,
  128. };
  129. enum {
  130. SLIM_RX_7 = 0,
  131. SLIM_RX_MAX,
  132. };
  133. enum {
  134. SLIM_TX_7 = 0,
  135. SLIM_TX_8,
  136. SLIM_TX_MAX,
  137. };
  138. enum {
  139. AFE_LOOPBACK_TX_IDX = 0,
  140. AFE_LOOPBACK_TX_IDX_MAX,
  141. };
  142. struct msm_asoc_mach_data {
  143. struct snd_info_entry *codec_root;
  144. int usbc_en2_gpio; /* used by gpio driver API */
  145. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  146. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  147. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  148. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  149. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  150. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  151. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  152. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  153. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  154. bool is_afe_config_done;
  155. struct device_node *fsa_handle;
  156. };
  157. struct tdm_port {
  158. u32 mode;
  159. u32 channel;
  160. };
  161. enum {
  162. EXT_DISP_RX_IDX_DP = 0,
  163. EXT_DISP_RX_IDX_MAX,
  164. };
  165. struct msm_wsa881x_dev_info {
  166. struct device_node *of_node;
  167. u32 index;
  168. };
  169. struct aux_codec_dev_info {
  170. struct device_node *of_node;
  171. u32 index;
  172. };
  173. struct dev_config {
  174. u32 sample_rate;
  175. u32 bit_format;
  176. u32 channels;
  177. };
  178. /* Default configuration of slimbus channels */
  179. static struct dev_config slim_rx_cfg[] = {
  180. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  181. };
  182. static struct dev_config slim_tx_cfg[] = {
  183. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  184. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  185. };
  186. /* Default configuration of external display BE */
  187. static struct dev_config ext_disp_rx_cfg[] = {
  188. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  189. };
  190. static struct dev_config usb_rx_cfg = {
  191. .sample_rate = SAMPLING_RATE_48KHZ,
  192. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  193. .channels = 2,
  194. };
  195. static struct dev_config usb_tx_cfg = {
  196. .sample_rate = SAMPLING_RATE_48KHZ,
  197. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  198. .channels = 1,
  199. };
  200. static struct dev_config proxy_rx_cfg = {
  201. .sample_rate = SAMPLING_RATE_48KHZ,
  202. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  203. .channels = 2,
  204. };
  205. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  206. {
  207. AFE_API_VERSION_I2S_CONFIG,
  208. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  209. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  210. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  211. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  212. 0,
  213. },
  214. {
  215. AFE_API_VERSION_I2S_CONFIG,
  216. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  217. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  218. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  219. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  220. 0,
  221. },
  222. {
  223. AFE_API_VERSION_I2S_CONFIG,
  224. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  225. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  226. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  227. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  228. 0,
  229. },
  230. {
  231. AFE_API_VERSION_I2S_CONFIG,
  232. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  233. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  234. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  235. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  236. 0,
  237. },
  238. {
  239. AFE_API_VERSION_I2S_CONFIG,
  240. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  241. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  242. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  243. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  244. 0,
  245. },
  246. {
  247. AFE_API_VERSION_I2S_CONFIG,
  248. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  249. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  250. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  251. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  252. 0,
  253. },
  254. };
  255. struct mi2s_conf {
  256. struct mutex lock;
  257. u32 ref_cnt;
  258. u32 msm_is_mi2s_master;
  259. };
  260. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  261. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  262. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  263. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  264. };
  265. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  266. /* Default configuration of TDM channels */
  267. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  268. { /* PRI TDM */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  274. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  275. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  276. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  277. },
  278. { /* SEC TDM */
  279. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  280. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  281. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  282. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  284. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  285. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  286. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  287. },
  288. { /* TERT TDM */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  295. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  296. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  297. },
  298. { /* QUAT TDM */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  305. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  306. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  307. },
  308. { /* QUIN TDM */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  311. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  312. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  315. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  316. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  317. },
  318. { /* SEN TDM */
  319. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  320. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  321. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  322. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  323. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  324. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  325. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  326. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  327. },
  328. };
  329. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  330. { /* PRI TDM */
  331. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  332. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  333. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  334. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  335. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  336. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  337. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  338. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  339. },
  340. { /* SEC TDM */
  341. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  342. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  343. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  344. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  345. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  346. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  347. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  348. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  349. },
  350. { /* TERT TDM */
  351. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  352. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  353. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  354. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  355. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  356. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  357. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  358. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  359. },
  360. { /* QUAT TDM */
  361. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  362. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  363. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  364. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  365. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  366. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  367. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  368. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  369. },
  370. { /* QUIN TDM */
  371. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  372. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  373. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  374. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  375. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  376. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  377. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  378. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  379. },
  380. { /* SEN TDM */
  381. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  382. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  383. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  384. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  385. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  386. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  387. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  388. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  389. },
  390. };
  391. /* Default configuration of AUX PCM channels */
  392. static struct dev_config aux_pcm_rx_cfg[] = {
  393. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  394. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  395. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  396. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  397. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  398. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  399. };
  400. static struct dev_config aux_pcm_tx_cfg[] = {
  401. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  402. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  403. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  404. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  405. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  406. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  407. };
  408. /* Default configuration of MI2S channels */
  409. static struct dev_config mi2s_rx_cfg[] = {
  410. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  411. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  412. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  413. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  414. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  415. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  416. };
  417. static struct dev_config mi2s_tx_cfg[] = {
  418. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  419. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  420. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  421. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  422. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  423. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  424. };
  425. /* Default configuration of Codec DMA Interface RX */
  426. static struct dev_config cdc_dma_rx_cfg[] = {
  427. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  428. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  429. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  430. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  431. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  432. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  433. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  434. };
  435. /* Default configuration of Codec DMA Interface TX */
  436. static struct dev_config cdc_dma_tx_cfg[] = {
  437. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  438. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  439. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  440. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  441. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  442. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  443. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  444. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  445. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  446. };
  447. static struct dev_config afe_loopback_tx_cfg[] = {
  448. [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  449. };
  450. static int msm_vi_feed_tx_ch = 2;
  451. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  452. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  453. "S32_LE"};
  454. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  455. "Six", "Seven", "Eight"};
  456. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  457. "KHZ_16", "KHZ_22P05",
  458. "KHZ_32", "KHZ_44P1", "KHZ_48",
  459. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  460. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  461. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  462. "Five", "Six", "Seven",
  463. "Eight"};
  464. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  465. "KHZ_48", "KHZ_176P4",
  466. "KHZ_352P8"};
  467. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  468. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  469. "Five", "Six", "Seven", "Eight"};
  470. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  471. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  472. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  473. "KHZ_48", "KHZ_96", "KHZ_192"};
  474. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  475. "Five", "Six", "Seven",
  476. "Eight"};
  477. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  478. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  479. "Five", "Six", "Seven",
  480. "Eight"};
  481. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  482. "KHZ_16", "KHZ_22P05",
  483. "KHZ_32", "KHZ_44P1", "KHZ_48",
  484. "KHZ_88P2", "KHZ_96",
  485. "KHZ_176P4", "KHZ_192",
  486. "KHZ_352P8", "KHZ_384"};
  487. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  488. "S24_3LE"};
  489. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  490. "KHZ_192", "KHZ_32", "KHZ_44P1",
  491. "KHZ_88P2", "KHZ_176P4"};
  492. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  493. "KHZ_44P1", "KHZ_48",
  494. "KHZ_88P2", "KHZ_96"};
  495. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  496. "KHZ_44P1", "KHZ_48",
  497. "KHZ_88P2", "KHZ_96"};
  498. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  499. "KHZ_44P1", "KHZ_48",
  500. "KHZ_88P2", "KHZ_96"};
  501. static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
  502. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  503. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  504. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  505. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  506. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  507. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  508. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  509. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  510. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  511. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  512. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  513. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  514. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  515. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  516. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  517. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  518. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  519. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  520. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  521. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  522. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  523. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  524. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  525. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  526. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  527. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  528. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  529. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  530. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  531. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  532. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  533. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  534. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  535. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  536. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  537. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  538. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  539. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  540. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  541. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  542. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  543. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  544. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  545. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  546. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  547. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  548. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  549. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  550. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  551. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  552. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  553. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  554. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  555. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  556. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  557. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  558. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  559. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  560. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  561. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  562. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  563. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  564. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  565. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  566. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  567. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  568. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  569. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  570. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  571. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  572. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  573. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  574. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  575. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  576. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  577. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  578. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  579. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  580. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  581. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  582. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  583. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  584. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  585. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  586. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  587. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  588. cdc_dma_sample_rate_text);
  589. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  590. cdc_dma_sample_rate_text);
  591. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  592. cdc_dma_sample_rate_text);
  593. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  594. cdc_dma_sample_rate_text);
  595. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  596. cdc_dma_sample_rate_text);
  597. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  598. cdc_dma_sample_rate_text);
  599. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  600. cdc_dma_sample_rate_text);
  601. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  602. cdc_dma_sample_rate_text);
  603. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  604. cdc_dma_sample_rate_text);
  605. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  606. cdc_dma_sample_rate_text);
  607. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  608. cdc_dma_sample_rate_text);
  609. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  610. cdc_dma_sample_rate_text);
  611. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  612. cdc_dma_sample_rate_text);
  613. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  614. cdc_dma_sample_rate_text);
  615. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  616. cdc_dma_sample_rate_text);
  617. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  618. cdc_dma_sample_rate_text);
  619. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  620. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  621. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  622. ext_disp_sample_rate_text);
  623. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  624. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  625. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  626. static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
  627. static bool is_initial_boot;
  628. static bool codec_reg_done;
  629. static struct snd_soc_aux_dev *msm_aux_dev;
  630. static struct snd_soc_codec_conf *msm_codec_conf;
  631. static struct snd_soc_card snd_soc_card_kona_msm;
  632. static int dmic_0_1_gpio_cnt;
  633. static int dmic_2_3_gpio_cnt;
  634. static int dmic_4_5_gpio_cnt;
  635. static void *def_wcd_mbhc_cal(void);
  636. /*
  637. * Need to report LINEIN
  638. * if R/L channel impedance is larger than 5K ohm
  639. */
  640. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  641. .read_fw_bin = false,
  642. .calibration = NULL,
  643. .detect_extn_cable = true,
  644. .mono_stero_detection = false,
  645. .swap_gnd_mic = NULL,
  646. .hs_ext_micbias = true,
  647. .key_code[0] = KEY_MEDIA,
  648. .key_code[1] = KEY_VOICECOMMAND,
  649. .key_code[2] = KEY_VOLUMEUP,
  650. .key_code[3] = KEY_VOLUMEDOWN,
  651. .key_code[4] = 0,
  652. .key_code[5] = 0,
  653. .key_code[6] = 0,
  654. .key_code[7] = 0,
  655. .linein_th = 5000,
  656. .moisture_en = false,
  657. .mbhc_micbias = MIC_BIAS_2,
  658. .anc_micbias = MIC_BIAS_2,
  659. .enable_anc_mic_detect = false,
  660. .moisture_duty_cycle_en = true,
  661. };
  662. static inline int param_is_mask(int p)
  663. {
  664. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  665. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  666. }
  667. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  668. int n)
  669. {
  670. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  671. }
  672. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  673. unsigned int bit)
  674. {
  675. if (bit >= SNDRV_MASK_MAX)
  676. return;
  677. if (param_is_mask(n)) {
  678. struct snd_mask *m = param_to_mask(p, n);
  679. m->bits[0] = 0;
  680. m->bits[1] = 0;
  681. m->bits[bit >> 5] |= (1 << (bit & 31));
  682. }
  683. }
  684. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  685. struct snd_ctl_elem_value *ucontrol)
  686. {
  687. int sample_rate_val = 0;
  688. switch (usb_rx_cfg.sample_rate) {
  689. case SAMPLING_RATE_384KHZ:
  690. sample_rate_val = 12;
  691. break;
  692. case SAMPLING_RATE_352P8KHZ:
  693. sample_rate_val = 11;
  694. break;
  695. case SAMPLING_RATE_192KHZ:
  696. sample_rate_val = 10;
  697. break;
  698. case SAMPLING_RATE_176P4KHZ:
  699. sample_rate_val = 9;
  700. break;
  701. case SAMPLING_RATE_96KHZ:
  702. sample_rate_val = 8;
  703. break;
  704. case SAMPLING_RATE_88P2KHZ:
  705. sample_rate_val = 7;
  706. break;
  707. case SAMPLING_RATE_48KHZ:
  708. sample_rate_val = 6;
  709. break;
  710. case SAMPLING_RATE_44P1KHZ:
  711. sample_rate_val = 5;
  712. break;
  713. case SAMPLING_RATE_32KHZ:
  714. sample_rate_val = 4;
  715. break;
  716. case SAMPLING_RATE_22P05KHZ:
  717. sample_rate_val = 3;
  718. break;
  719. case SAMPLING_RATE_16KHZ:
  720. sample_rate_val = 2;
  721. break;
  722. case SAMPLING_RATE_11P025KHZ:
  723. sample_rate_val = 1;
  724. break;
  725. case SAMPLING_RATE_8KHZ:
  726. default:
  727. sample_rate_val = 0;
  728. break;
  729. }
  730. ucontrol->value.integer.value[0] = sample_rate_val;
  731. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  732. usb_rx_cfg.sample_rate);
  733. return 0;
  734. }
  735. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  736. struct snd_ctl_elem_value *ucontrol)
  737. {
  738. switch (ucontrol->value.integer.value[0]) {
  739. case 12:
  740. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  741. break;
  742. case 11:
  743. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  744. break;
  745. case 10:
  746. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  747. break;
  748. case 9:
  749. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  750. break;
  751. case 8:
  752. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  753. break;
  754. case 7:
  755. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  756. break;
  757. case 6:
  758. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  759. break;
  760. case 5:
  761. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  762. break;
  763. case 4:
  764. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  765. break;
  766. case 3:
  767. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  768. break;
  769. case 2:
  770. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  771. break;
  772. case 1:
  773. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  774. break;
  775. case 0:
  776. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  777. break;
  778. default:
  779. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  780. break;
  781. }
  782. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  783. __func__, ucontrol->value.integer.value[0],
  784. usb_rx_cfg.sample_rate);
  785. return 0;
  786. }
  787. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  788. struct snd_ctl_elem_value *ucontrol)
  789. {
  790. int sample_rate_val = 0;
  791. switch (usb_tx_cfg.sample_rate) {
  792. case SAMPLING_RATE_384KHZ:
  793. sample_rate_val = 12;
  794. break;
  795. case SAMPLING_RATE_352P8KHZ:
  796. sample_rate_val = 11;
  797. break;
  798. case SAMPLING_RATE_192KHZ:
  799. sample_rate_val = 10;
  800. break;
  801. case SAMPLING_RATE_176P4KHZ:
  802. sample_rate_val = 9;
  803. break;
  804. case SAMPLING_RATE_96KHZ:
  805. sample_rate_val = 8;
  806. break;
  807. case SAMPLING_RATE_88P2KHZ:
  808. sample_rate_val = 7;
  809. break;
  810. case SAMPLING_RATE_48KHZ:
  811. sample_rate_val = 6;
  812. break;
  813. case SAMPLING_RATE_44P1KHZ:
  814. sample_rate_val = 5;
  815. break;
  816. case SAMPLING_RATE_32KHZ:
  817. sample_rate_val = 4;
  818. break;
  819. case SAMPLING_RATE_22P05KHZ:
  820. sample_rate_val = 3;
  821. break;
  822. case SAMPLING_RATE_16KHZ:
  823. sample_rate_val = 2;
  824. break;
  825. case SAMPLING_RATE_11P025KHZ:
  826. sample_rate_val = 1;
  827. break;
  828. case SAMPLING_RATE_8KHZ:
  829. sample_rate_val = 0;
  830. break;
  831. default:
  832. sample_rate_val = 6;
  833. break;
  834. }
  835. ucontrol->value.integer.value[0] = sample_rate_val;
  836. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  837. usb_tx_cfg.sample_rate);
  838. return 0;
  839. }
  840. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  841. struct snd_ctl_elem_value *ucontrol)
  842. {
  843. switch (ucontrol->value.integer.value[0]) {
  844. case 12:
  845. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  846. break;
  847. case 11:
  848. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  849. break;
  850. case 10:
  851. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  852. break;
  853. case 9:
  854. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  855. break;
  856. case 8:
  857. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  858. break;
  859. case 7:
  860. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  861. break;
  862. case 6:
  863. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  864. break;
  865. case 5:
  866. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  867. break;
  868. case 4:
  869. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  870. break;
  871. case 3:
  872. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  873. break;
  874. case 2:
  875. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  876. break;
  877. case 1:
  878. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  879. break;
  880. case 0:
  881. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  882. break;
  883. default:
  884. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  885. break;
  886. }
  887. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  888. __func__, ucontrol->value.integer.value[0],
  889. usb_tx_cfg.sample_rate);
  890. return 0;
  891. }
  892. static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
  893. struct snd_ctl_elem_value *ucontrol)
  894. {
  895. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  896. afe_loopback_tx_cfg[0].channels);
  897. ucontrol->value.enumerated.item[0] =
  898. afe_loopback_tx_cfg[0].channels - 1;
  899. return 0;
  900. }
  901. static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
  902. struct snd_ctl_elem_value *ucontrol)
  903. {
  904. afe_loopback_tx_cfg[0].channels =
  905. ucontrol->value.enumerated.item[0] + 1;
  906. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  907. afe_loopback_tx_cfg[0].channels);
  908. return 1;
  909. }
  910. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  911. struct snd_ctl_elem_value *ucontrol)
  912. {
  913. switch (usb_rx_cfg.bit_format) {
  914. case SNDRV_PCM_FORMAT_S32_LE:
  915. ucontrol->value.integer.value[0] = 3;
  916. break;
  917. case SNDRV_PCM_FORMAT_S24_3LE:
  918. ucontrol->value.integer.value[0] = 2;
  919. break;
  920. case SNDRV_PCM_FORMAT_S24_LE:
  921. ucontrol->value.integer.value[0] = 1;
  922. break;
  923. case SNDRV_PCM_FORMAT_S16_LE:
  924. default:
  925. ucontrol->value.integer.value[0] = 0;
  926. break;
  927. }
  928. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  929. __func__, usb_rx_cfg.bit_format,
  930. ucontrol->value.integer.value[0]);
  931. return 0;
  932. }
  933. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  934. struct snd_ctl_elem_value *ucontrol)
  935. {
  936. int rc = 0;
  937. switch (ucontrol->value.integer.value[0]) {
  938. case 3:
  939. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  940. break;
  941. case 2:
  942. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  943. break;
  944. case 1:
  945. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  946. break;
  947. case 0:
  948. default:
  949. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  950. break;
  951. }
  952. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  953. __func__, usb_rx_cfg.bit_format,
  954. ucontrol->value.integer.value[0]);
  955. return rc;
  956. }
  957. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  958. struct snd_ctl_elem_value *ucontrol)
  959. {
  960. switch (usb_tx_cfg.bit_format) {
  961. case SNDRV_PCM_FORMAT_S32_LE:
  962. ucontrol->value.integer.value[0] = 3;
  963. break;
  964. case SNDRV_PCM_FORMAT_S24_3LE:
  965. ucontrol->value.integer.value[0] = 2;
  966. break;
  967. case SNDRV_PCM_FORMAT_S24_LE:
  968. ucontrol->value.integer.value[0] = 1;
  969. break;
  970. case SNDRV_PCM_FORMAT_S16_LE:
  971. default:
  972. ucontrol->value.integer.value[0] = 0;
  973. break;
  974. }
  975. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  976. __func__, usb_tx_cfg.bit_format,
  977. ucontrol->value.integer.value[0]);
  978. return 0;
  979. }
  980. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  981. struct snd_ctl_elem_value *ucontrol)
  982. {
  983. int rc = 0;
  984. switch (ucontrol->value.integer.value[0]) {
  985. case 3:
  986. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  987. break;
  988. case 2:
  989. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  990. break;
  991. case 1:
  992. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  993. break;
  994. case 0:
  995. default:
  996. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  997. break;
  998. }
  999. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1000. __func__, usb_tx_cfg.bit_format,
  1001. ucontrol->value.integer.value[0]);
  1002. return rc;
  1003. }
  1004. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1005. struct snd_ctl_elem_value *ucontrol)
  1006. {
  1007. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1008. usb_rx_cfg.channels);
  1009. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1010. return 0;
  1011. }
  1012. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1013. struct snd_ctl_elem_value *ucontrol)
  1014. {
  1015. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1016. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1017. return 1;
  1018. }
  1019. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1020. struct snd_ctl_elem_value *ucontrol)
  1021. {
  1022. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1023. usb_tx_cfg.channels);
  1024. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1025. return 0;
  1026. }
  1027. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1028. struct snd_ctl_elem_value *ucontrol)
  1029. {
  1030. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1031. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1032. return 1;
  1033. }
  1034. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1035. struct snd_ctl_elem_value *ucontrol)
  1036. {
  1037. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1038. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1039. ucontrol->value.integer.value[0]);
  1040. return 0;
  1041. }
  1042. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1043. struct snd_ctl_elem_value *ucontrol)
  1044. {
  1045. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1046. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1047. return 1;
  1048. }
  1049. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  1050. {
  1051. int idx = 0;
  1052. if (strnstr(kcontrol->id.name, "Display Port RX",
  1053. sizeof("Display Port RX"))) {
  1054. idx = EXT_DISP_RX_IDX_DP;
  1055. } else {
  1056. pr_err("%s: unsupported BE: %s\n",
  1057. __func__, kcontrol->id.name);
  1058. idx = -EINVAL;
  1059. }
  1060. return idx;
  1061. }
  1062. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  1063. struct snd_ctl_elem_value *ucontrol)
  1064. {
  1065. int idx = ext_disp_get_port_idx(kcontrol);
  1066. if (idx < 0)
  1067. return idx;
  1068. switch (ext_disp_rx_cfg[idx].bit_format) {
  1069. case SNDRV_PCM_FORMAT_S24_3LE:
  1070. ucontrol->value.integer.value[0] = 2;
  1071. break;
  1072. case SNDRV_PCM_FORMAT_S24_LE:
  1073. ucontrol->value.integer.value[0] = 1;
  1074. break;
  1075. case SNDRV_PCM_FORMAT_S16_LE:
  1076. default:
  1077. ucontrol->value.integer.value[0] = 0;
  1078. break;
  1079. }
  1080. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1081. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1082. ucontrol->value.integer.value[0]);
  1083. return 0;
  1084. }
  1085. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  1086. struct snd_ctl_elem_value *ucontrol)
  1087. {
  1088. int idx = ext_disp_get_port_idx(kcontrol);
  1089. if (idx < 0)
  1090. return idx;
  1091. switch (ucontrol->value.integer.value[0]) {
  1092. case 2:
  1093. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1094. break;
  1095. case 1:
  1096. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1097. break;
  1098. case 0:
  1099. default:
  1100. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1101. break;
  1102. }
  1103. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1104. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1105. ucontrol->value.integer.value[0]);
  1106. return 0;
  1107. }
  1108. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  1109. struct snd_ctl_elem_value *ucontrol)
  1110. {
  1111. int idx = ext_disp_get_port_idx(kcontrol);
  1112. if (idx < 0)
  1113. return idx;
  1114. ucontrol->value.integer.value[0] =
  1115. ext_disp_rx_cfg[idx].channels - 2;
  1116. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1117. idx, ext_disp_rx_cfg[idx].channels);
  1118. return 0;
  1119. }
  1120. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  1121. struct snd_ctl_elem_value *ucontrol)
  1122. {
  1123. int idx = ext_disp_get_port_idx(kcontrol);
  1124. if (idx < 0)
  1125. return idx;
  1126. ext_disp_rx_cfg[idx].channels =
  1127. ucontrol->value.integer.value[0] + 2;
  1128. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1129. idx, ext_disp_rx_cfg[idx].channels);
  1130. return 1;
  1131. }
  1132. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1133. struct snd_ctl_elem_value *ucontrol)
  1134. {
  1135. int sample_rate_val;
  1136. int idx = ext_disp_get_port_idx(kcontrol);
  1137. if (idx < 0)
  1138. return idx;
  1139. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1140. case SAMPLING_RATE_176P4KHZ:
  1141. sample_rate_val = 6;
  1142. break;
  1143. case SAMPLING_RATE_88P2KHZ:
  1144. sample_rate_val = 5;
  1145. break;
  1146. case SAMPLING_RATE_44P1KHZ:
  1147. sample_rate_val = 4;
  1148. break;
  1149. case SAMPLING_RATE_32KHZ:
  1150. sample_rate_val = 3;
  1151. break;
  1152. case SAMPLING_RATE_192KHZ:
  1153. sample_rate_val = 2;
  1154. break;
  1155. case SAMPLING_RATE_96KHZ:
  1156. sample_rate_val = 1;
  1157. break;
  1158. case SAMPLING_RATE_48KHZ:
  1159. default:
  1160. sample_rate_val = 0;
  1161. break;
  1162. }
  1163. ucontrol->value.integer.value[0] = sample_rate_val;
  1164. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1165. idx, ext_disp_rx_cfg[idx].sample_rate);
  1166. return 0;
  1167. }
  1168. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1169. struct snd_ctl_elem_value *ucontrol)
  1170. {
  1171. int idx = ext_disp_get_port_idx(kcontrol);
  1172. if (idx < 0)
  1173. return idx;
  1174. switch (ucontrol->value.integer.value[0]) {
  1175. case 6:
  1176. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1177. break;
  1178. case 5:
  1179. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1180. break;
  1181. case 4:
  1182. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1183. break;
  1184. case 3:
  1185. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1186. break;
  1187. case 2:
  1188. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1189. break;
  1190. case 1:
  1191. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1192. break;
  1193. case 0:
  1194. default:
  1195. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1196. break;
  1197. }
  1198. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1199. __func__, ucontrol->value.integer.value[0], idx,
  1200. ext_disp_rx_cfg[idx].sample_rate);
  1201. return 0;
  1202. }
  1203. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1204. struct snd_ctl_elem_value *ucontrol)
  1205. {
  1206. pr_debug("%s: proxy_rx channels = %d\n",
  1207. __func__, proxy_rx_cfg.channels);
  1208. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1209. return 0;
  1210. }
  1211. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1212. struct snd_ctl_elem_value *ucontrol)
  1213. {
  1214. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1215. pr_debug("%s: proxy_rx channels = %d\n",
  1216. __func__, proxy_rx_cfg.channels);
  1217. return 1;
  1218. }
  1219. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1220. struct tdm_port *port)
  1221. {
  1222. if (port) {
  1223. if (strnstr(kcontrol->id.name, "PRI",
  1224. sizeof(kcontrol->id.name))) {
  1225. port->mode = TDM_PRI;
  1226. } else if (strnstr(kcontrol->id.name, "SEC",
  1227. sizeof(kcontrol->id.name))) {
  1228. port->mode = TDM_SEC;
  1229. } else if (strnstr(kcontrol->id.name, "TERT",
  1230. sizeof(kcontrol->id.name))) {
  1231. port->mode = TDM_TERT;
  1232. } else if (strnstr(kcontrol->id.name, "QUAT",
  1233. sizeof(kcontrol->id.name))) {
  1234. port->mode = TDM_QUAT;
  1235. } else if (strnstr(kcontrol->id.name, "QUIN",
  1236. sizeof(kcontrol->id.name))) {
  1237. port->mode = TDM_QUIN;
  1238. } else if (strnstr(kcontrol->id.name, "SEN",
  1239. sizeof(kcontrol->id.name))) {
  1240. port->mode = TDM_SEN;
  1241. } else {
  1242. pr_err("%s: unsupported mode in: %s\n",
  1243. __func__, kcontrol->id.name);
  1244. return -EINVAL;
  1245. }
  1246. if (strnstr(kcontrol->id.name, "RX_0",
  1247. sizeof(kcontrol->id.name)) ||
  1248. strnstr(kcontrol->id.name, "TX_0",
  1249. sizeof(kcontrol->id.name))) {
  1250. port->channel = TDM_0;
  1251. } else if (strnstr(kcontrol->id.name, "RX_1",
  1252. sizeof(kcontrol->id.name)) ||
  1253. strnstr(kcontrol->id.name, "TX_1",
  1254. sizeof(kcontrol->id.name))) {
  1255. port->channel = TDM_1;
  1256. } else if (strnstr(kcontrol->id.name, "RX_2",
  1257. sizeof(kcontrol->id.name)) ||
  1258. strnstr(kcontrol->id.name, "TX_2",
  1259. sizeof(kcontrol->id.name))) {
  1260. port->channel = TDM_2;
  1261. } else if (strnstr(kcontrol->id.name, "RX_3",
  1262. sizeof(kcontrol->id.name)) ||
  1263. strnstr(kcontrol->id.name, "TX_3",
  1264. sizeof(kcontrol->id.name))) {
  1265. port->channel = TDM_3;
  1266. } else if (strnstr(kcontrol->id.name, "RX_4",
  1267. sizeof(kcontrol->id.name)) ||
  1268. strnstr(kcontrol->id.name, "TX_4",
  1269. sizeof(kcontrol->id.name))) {
  1270. port->channel = TDM_4;
  1271. } else if (strnstr(kcontrol->id.name, "RX_5",
  1272. sizeof(kcontrol->id.name)) ||
  1273. strnstr(kcontrol->id.name, "TX_5",
  1274. sizeof(kcontrol->id.name))) {
  1275. port->channel = TDM_5;
  1276. } else if (strnstr(kcontrol->id.name, "RX_6",
  1277. sizeof(kcontrol->id.name)) ||
  1278. strnstr(kcontrol->id.name, "TX_6",
  1279. sizeof(kcontrol->id.name))) {
  1280. port->channel = TDM_6;
  1281. } else if (strnstr(kcontrol->id.name, "RX_7",
  1282. sizeof(kcontrol->id.name)) ||
  1283. strnstr(kcontrol->id.name, "TX_7",
  1284. sizeof(kcontrol->id.name))) {
  1285. port->channel = TDM_7;
  1286. } else {
  1287. pr_err("%s: unsupported channel in: %s\n",
  1288. __func__, kcontrol->id.name);
  1289. return -EINVAL;
  1290. }
  1291. } else {
  1292. return -EINVAL;
  1293. }
  1294. return 0;
  1295. }
  1296. static int tdm_get_sample_rate(int value)
  1297. {
  1298. int sample_rate = 0;
  1299. switch (value) {
  1300. case 0:
  1301. sample_rate = SAMPLING_RATE_8KHZ;
  1302. break;
  1303. case 1:
  1304. sample_rate = SAMPLING_RATE_16KHZ;
  1305. break;
  1306. case 2:
  1307. sample_rate = SAMPLING_RATE_32KHZ;
  1308. break;
  1309. case 3:
  1310. sample_rate = SAMPLING_RATE_48KHZ;
  1311. break;
  1312. case 4:
  1313. sample_rate = SAMPLING_RATE_176P4KHZ;
  1314. break;
  1315. case 5:
  1316. sample_rate = SAMPLING_RATE_352P8KHZ;
  1317. break;
  1318. default:
  1319. sample_rate = SAMPLING_RATE_48KHZ;
  1320. break;
  1321. }
  1322. return sample_rate;
  1323. }
  1324. static int tdm_get_sample_rate_val(int sample_rate)
  1325. {
  1326. int sample_rate_val = 0;
  1327. switch (sample_rate) {
  1328. case SAMPLING_RATE_8KHZ:
  1329. sample_rate_val = 0;
  1330. break;
  1331. case SAMPLING_RATE_16KHZ:
  1332. sample_rate_val = 1;
  1333. break;
  1334. case SAMPLING_RATE_32KHZ:
  1335. sample_rate_val = 2;
  1336. break;
  1337. case SAMPLING_RATE_48KHZ:
  1338. sample_rate_val = 3;
  1339. break;
  1340. case SAMPLING_RATE_176P4KHZ:
  1341. sample_rate_val = 4;
  1342. break;
  1343. case SAMPLING_RATE_352P8KHZ:
  1344. sample_rate_val = 5;
  1345. break;
  1346. default:
  1347. sample_rate_val = 3;
  1348. break;
  1349. }
  1350. return sample_rate_val;
  1351. }
  1352. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1353. struct snd_ctl_elem_value *ucontrol)
  1354. {
  1355. struct tdm_port port;
  1356. int ret = tdm_get_port_idx(kcontrol, &port);
  1357. if (ret) {
  1358. pr_err("%s: unsupported control: %s\n",
  1359. __func__, kcontrol->id.name);
  1360. } else {
  1361. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1362. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1363. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1364. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1365. ucontrol->value.enumerated.item[0]);
  1366. }
  1367. return ret;
  1368. }
  1369. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1370. struct snd_ctl_elem_value *ucontrol)
  1371. {
  1372. struct tdm_port port;
  1373. int ret = tdm_get_port_idx(kcontrol, &port);
  1374. if (ret) {
  1375. pr_err("%s: unsupported control: %s\n",
  1376. __func__, kcontrol->id.name);
  1377. } else {
  1378. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1379. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1380. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1381. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1382. ucontrol->value.enumerated.item[0]);
  1383. }
  1384. return ret;
  1385. }
  1386. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1387. struct snd_ctl_elem_value *ucontrol)
  1388. {
  1389. struct tdm_port port;
  1390. int ret = tdm_get_port_idx(kcontrol, &port);
  1391. if (ret) {
  1392. pr_err("%s: unsupported control: %s\n",
  1393. __func__, kcontrol->id.name);
  1394. } else {
  1395. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1396. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1397. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1398. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1399. ucontrol->value.enumerated.item[0]);
  1400. }
  1401. return ret;
  1402. }
  1403. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1404. struct snd_ctl_elem_value *ucontrol)
  1405. {
  1406. struct tdm_port port;
  1407. int ret = tdm_get_port_idx(kcontrol, &port);
  1408. if (ret) {
  1409. pr_err("%s: unsupported control: %s\n",
  1410. __func__, kcontrol->id.name);
  1411. } else {
  1412. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1413. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1414. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1415. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1416. ucontrol->value.enumerated.item[0]);
  1417. }
  1418. return ret;
  1419. }
  1420. static int tdm_get_format(int value)
  1421. {
  1422. int format = 0;
  1423. switch (value) {
  1424. case 0:
  1425. format = SNDRV_PCM_FORMAT_S16_LE;
  1426. break;
  1427. case 1:
  1428. format = SNDRV_PCM_FORMAT_S24_LE;
  1429. break;
  1430. case 2:
  1431. format = SNDRV_PCM_FORMAT_S32_LE;
  1432. break;
  1433. default:
  1434. format = SNDRV_PCM_FORMAT_S16_LE;
  1435. break;
  1436. }
  1437. return format;
  1438. }
  1439. static int tdm_get_format_val(int format)
  1440. {
  1441. int value = 0;
  1442. switch (format) {
  1443. case SNDRV_PCM_FORMAT_S16_LE:
  1444. value = 0;
  1445. break;
  1446. case SNDRV_PCM_FORMAT_S24_LE:
  1447. value = 1;
  1448. break;
  1449. case SNDRV_PCM_FORMAT_S32_LE:
  1450. value = 2;
  1451. break;
  1452. default:
  1453. value = 0;
  1454. break;
  1455. }
  1456. return value;
  1457. }
  1458. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1459. struct snd_ctl_elem_value *ucontrol)
  1460. {
  1461. struct tdm_port port;
  1462. int ret = tdm_get_port_idx(kcontrol, &port);
  1463. if (ret) {
  1464. pr_err("%s: unsupported control: %s\n",
  1465. __func__, kcontrol->id.name);
  1466. } else {
  1467. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1468. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1469. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1470. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1471. ucontrol->value.enumerated.item[0]);
  1472. }
  1473. return ret;
  1474. }
  1475. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1476. struct snd_ctl_elem_value *ucontrol)
  1477. {
  1478. struct tdm_port port;
  1479. int ret = tdm_get_port_idx(kcontrol, &port);
  1480. if (ret) {
  1481. pr_err("%s: unsupported control: %s\n",
  1482. __func__, kcontrol->id.name);
  1483. } else {
  1484. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1485. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1486. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1487. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1488. ucontrol->value.enumerated.item[0]);
  1489. }
  1490. return ret;
  1491. }
  1492. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1493. struct snd_ctl_elem_value *ucontrol)
  1494. {
  1495. struct tdm_port port;
  1496. int ret = tdm_get_port_idx(kcontrol, &port);
  1497. if (ret) {
  1498. pr_err("%s: unsupported control: %s\n",
  1499. __func__, kcontrol->id.name);
  1500. } else {
  1501. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1502. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1503. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1504. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1505. ucontrol->value.enumerated.item[0]);
  1506. }
  1507. return ret;
  1508. }
  1509. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1510. struct snd_ctl_elem_value *ucontrol)
  1511. {
  1512. struct tdm_port port;
  1513. int ret = tdm_get_port_idx(kcontrol, &port);
  1514. if (ret) {
  1515. pr_err("%s: unsupported control: %s\n",
  1516. __func__, kcontrol->id.name);
  1517. } else {
  1518. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1519. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1520. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1521. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1522. ucontrol->value.enumerated.item[0]);
  1523. }
  1524. return ret;
  1525. }
  1526. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1527. struct snd_ctl_elem_value *ucontrol)
  1528. {
  1529. struct tdm_port port;
  1530. int ret = tdm_get_port_idx(kcontrol, &port);
  1531. if (ret) {
  1532. pr_err("%s: unsupported control: %s\n",
  1533. __func__, kcontrol->id.name);
  1534. } else {
  1535. ucontrol->value.enumerated.item[0] =
  1536. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1537. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1538. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1539. ucontrol->value.enumerated.item[0]);
  1540. }
  1541. return ret;
  1542. }
  1543. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1544. struct snd_ctl_elem_value *ucontrol)
  1545. {
  1546. struct tdm_port port;
  1547. int ret = tdm_get_port_idx(kcontrol, &port);
  1548. if (ret) {
  1549. pr_err("%s: unsupported control: %s\n",
  1550. __func__, kcontrol->id.name);
  1551. } else {
  1552. tdm_rx_cfg[port.mode][port.channel].channels =
  1553. ucontrol->value.enumerated.item[0] + 1;
  1554. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1555. tdm_rx_cfg[port.mode][port.channel].channels,
  1556. ucontrol->value.enumerated.item[0] + 1);
  1557. }
  1558. return ret;
  1559. }
  1560. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1561. struct snd_ctl_elem_value *ucontrol)
  1562. {
  1563. struct tdm_port port;
  1564. int ret = tdm_get_port_idx(kcontrol, &port);
  1565. if (ret) {
  1566. pr_err("%s: unsupported control: %s\n",
  1567. __func__, kcontrol->id.name);
  1568. } else {
  1569. ucontrol->value.enumerated.item[0] =
  1570. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1571. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1572. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1573. ucontrol->value.enumerated.item[0]);
  1574. }
  1575. return ret;
  1576. }
  1577. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1578. struct snd_ctl_elem_value *ucontrol)
  1579. {
  1580. struct tdm_port port;
  1581. int ret = tdm_get_port_idx(kcontrol, &port);
  1582. if (ret) {
  1583. pr_err("%s: unsupported control: %s\n",
  1584. __func__, kcontrol->id.name);
  1585. } else {
  1586. tdm_tx_cfg[port.mode][port.channel].channels =
  1587. ucontrol->value.enumerated.item[0] + 1;
  1588. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1589. tdm_tx_cfg[port.mode][port.channel].channels,
  1590. ucontrol->value.enumerated.item[0] + 1);
  1591. }
  1592. return ret;
  1593. }
  1594. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1595. {
  1596. int idx = 0;
  1597. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1598. sizeof("PRIM_AUX_PCM"))) {
  1599. idx = PRIM_AUX_PCM;
  1600. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1601. sizeof("SEC_AUX_PCM"))) {
  1602. idx = SEC_AUX_PCM;
  1603. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1604. sizeof("TERT_AUX_PCM"))) {
  1605. idx = TERT_AUX_PCM;
  1606. } else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  1607. sizeof("QUAT_AUX_PCM"))) {
  1608. idx = QUAT_AUX_PCM;
  1609. } else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  1610. sizeof("QUIN_AUX_PCM"))) {
  1611. idx = QUIN_AUX_PCM;
  1612. } else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  1613. sizeof("SEN_AUX_PCM"))) {
  1614. idx = SEN_AUX_PCM;
  1615. } else {
  1616. pr_err("%s: unsupported port: %s\n",
  1617. __func__, kcontrol->id.name);
  1618. idx = -EINVAL;
  1619. }
  1620. return idx;
  1621. }
  1622. static int aux_pcm_get_sample_rate(int value)
  1623. {
  1624. int sample_rate = 0;
  1625. switch (value) {
  1626. case 1:
  1627. sample_rate = SAMPLING_RATE_16KHZ;
  1628. break;
  1629. case 0:
  1630. default:
  1631. sample_rate = SAMPLING_RATE_8KHZ;
  1632. break;
  1633. }
  1634. return sample_rate;
  1635. }
  1636. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1637. {
  1638. int sample_rate_val = 0;
  1639. switch (sample_rate) {
  1640. case SAMPLING_RATE_16KHZ:
  1641. sample_rate_val = 1;
  1642. break;
  1643. case SAMPLING_RATE_8KHZ:
  1644. default:
  1645. sample_rate_val = 0;
  1646. break;
  1647. }
  1648. return sample_rate_val;
  1649. }
  1650. static int mi2s_auxpcm_get_format(int value)
  1651. {
  1652. int format = 0;
  1653. switch (value) {
  1654. case 0:
  1655. format = SNDRV_PCM_FORMAT_S16_LE;
  1656. break;
  1657. case 1:
  1658. format = SNDRV_PCM_FORMAT_S24_LE;
  1659. break;
  1660. case 2:
  1661. format = SNDRV_PCM_FORMAT_S24_3LE;
  1662. break;
  1663. case 3:
  1664. format = SNDRV_PCM_FORMAT_S32_LE;
  1665. break;
  1666. default:
  1667. format = SNDRV_PCM_FORMAT_S16_LE;
  1668. break;
  1669. }
  1670. return format;
  1671. }
  1672. static int mi2s_auxpcm_get_format_value(int format)
  1673. {
  1674. int value = 0;
  1675. switch (format) {
  1676. case SNDRV_PCM_FORMAT_S16_LE:
  1677. value = 0;
  1678. break;
  1679. case SNDRV_PCM_FORMAT_S24_LE:
  1680. value = 1;
  1681. break;
  1682. case SNDRV_PCM_FORMAT_S24_3LE:
  1683. value = 2;
  1684. break;
  1685. case SNDRV_PCM_FORMAT_S32_LE:
  1686. value = 3;
  1687. break;
  1688. default:
  1689. value = 0;
  1690. break;
  1691. }
  1692. return value;
  1693. }
  1694. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1695. struct snd_ctl_elem_value *ucontrol)
  1696. {
  1697. int idx = aux_pcm_get_port_idx(kcontrol);
  1698. if (idx < 0)
  1699. return idx;
  1700. ucontrol->value.enumerated.item[0] =
  1701. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1702. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1703. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1704. ucontrol->value.enumerated.item[0]);
  1705. return 0;
  1706. }
  1707. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1708. struct snd_ctl_elem_value *ucontrol)
  1709. {
  1710. int idx = aux_pcm_get_port_idx(kcontrol);
  1711. if (idx < 0)
  1712. return idx;
  1713. aux_pcm_rx_cfg[idx].sample_rate =
  1714. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1715. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1716. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1717. ucontrol->value.enumerated.item[0]);
  1718. return 0;
  1719. }
  1720. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1721. struct snd_ctl_elem_value *ucontrol)
  1722. {
  1723. int idx = aux_pcm_get_port_idx(kcontrol);
  1724. if (idx < 0)
  1725. return idx;
  1726. ucontrol->value.enumerated.item[0] =
  1727. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1728. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1729. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1730. ucontrol->value.enumerated.item[0]);
  1731. return 0;
  1732. }
  1733. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1734. struct snd_ctl_elem_value *ucontrol)
  1735. {
  1736. int idx = aux_pcm_get_port_idx(kcontrol);
  1737. if (idx < 0)
  1738. return idx;
  1739. aux_pcm_tx_cfg[idx].sample_rate =
  1740. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1741. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1742. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1743. ucontrol->value.enumerated.item[0]);
  1744. return 0;
  1745. }
  1746. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1747. struct snd_ctl_elem_value *ucontrol)
  1748. {
  1749. int idx = aux_pcm_get_port_idx(kcontrol);
  1750. if (idx < 0)
  1751. return idx;
  1752. ucontrol->value.enumerated.item[0] =
  1753. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1754. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1755. idx, aux_pcm_rx_cfg[idx].bit_format,
  1756. ucontrol->value.enumerated.item[0]);
  1757. return 0;
  1758. }
  1759. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1760. struct snd_ctl_elem_value *ucontrol)
  1761. {
  1762. int idx = aux_pcm_get_port_idx(kcontrol);
  1763. if (idx < 0)
  1764. return idx;
  1765. aux_pcm_rx_cfg[idx].bit_format =
  1766. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1767. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1768. idx, aux_pcm_rx_cfg[idx].bit_format,
  1769. ucontrol->value.enumerated.item[0]);
  1770. return 0;
  1771. }
  1772. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1773. struct snd_ctl_elem_value *ucontrol)
  1774. {
  1775. int idx = aux_pcm_get_port_idx(kcontrol);
  1776. if (idx < 0)
  1777. return idx;
  1778. ucontrol->value.enumerated.item[0] =
  1779. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1780. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1781. idx, aux_pcm_tx_cfg[idx].bit_format,
  1782. ucontrol->value.enumerated.item[0]);
  1783. return 0;
  1784. }
  1785. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  1786. struct snd_ctl_elem_value *ucontrol)
  1787. {
  1788. int idx = aux_pcm_get_port_idx(kcontrol);
  1789. if (idx < 0)
  1790. return idx;
  1791. aux_pcm_tx_cfg[idx].bit_format =
  1792. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1793. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1794. idx, aux_pcm_tx_cfg[idx].bit_format,
  1795. ucontrol->value.enumerated.item[0]);
  1796. return 0;
  1797. }
  1798. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  1799. {
  1800. int idx = 0;
  1801. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  1802. sizeof("PRIM_MI2S_RX"))) {
  1803. idx = PRIM_MI2S;
  1804. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  1805. sizeof("SEC_MI2S_RX"))) {
  1806. idx = SEC_MI2S;
  1807. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  1808. sizeof("TERT_MI2S_RX"))) {
  1809. idx = TERT_MI2S;
  1810. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  1811. sizeof("QUAT_MI2S_RX"))) {
  1812. idx = QUAT_MI2S;
  1813. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  1814. sizeof("QUIN_MI2S_RX"))) {
  1815. idx = QUIN_MI2S;
  1816. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  1817. sizeof("SEN_MI2S_RX"))) {
  1818. idx = SEN_MI2S;
  1819. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  1820. sizeof("PRIM_MI2S_TX"))) {
  1821. idx = PRIM_MI2S;
  1822. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  1823. sizeof("SEC_MI2S_TX"))) {
  1824. idx = SEC_MI2S;
  1825. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  1826. sizeof("TERT_MI2S_TX"))) {
  1827. idx = TERT_MI2S;
  1828. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  1829. sizeof("QUAT_MI2S_TX"))) {
  1830. idx = QUAT_MI2S;
  1831. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  1832. sizeof("QUIN_MI2S_TX"))) {
  1833. idx = QUIN_MI2S;
  1834. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  1835. sizeof("SEN_MI2S_TX"))) {
  1836. idx = SEN_MI2S;
  1837. } else {
  1838. pr_err("%s: unsupported channel: %s\n",
  1839. __func__, kcontrol->id.name);
  1840. idx = -EINVAL;
  1841. }
  1842. return idx;
  1843. }
  1844. static int mi2s_get_sample_rate(int value)
  1845. {
  1846. int sample_rate = 0;
  1847. switch (value) {
  1848. case 0:
  1849. sample_rate = SAMPLING_RATE_8KHZ;
  1850. break;
  1851. case 1:
  1852. sample_rate = SAMPLING_RATE_11P025KHZ;
  1853. break;
  1854. case 2:
  1855. sample_rate = SAMPLING_RATE_16KHZ;
  1856. break;
  1857. case 3:
  1858. sample_rate = SAMPLING_RATE_22P05KHZ;
  1859. break;
  1860. case 4:
  1861. sample_rate = SAMPLING_RATE_32KHZ;
  1862. break;
  1863. case 5:
  1864. sample_rate = SAMPLING_RATE_44P1KHZ;
  1865. break;
  1866. case 6:
  1867. sample_rate = SAMPLING_RATE_48KHZ;
  1868. break;
  1869. case 7:
  1870. sample_rate = SAMPLING_RATE_96KHZ;
  1871. break;
  1872. case 8:
  1873. sample_rate = SAMPLING_RATE_192KHZ;
  1874. break;
  1875. default:
  1876. sample_rate = SAMPLING_RATE_48KHZ;
  1877. break;
  1878. }
  1879. return sample_rate;
  1880. }
  1881. static int mi2s_get_sample_rate_val(int sample_rate)
  1882. {
  1883. int sample_rate_val = 0;
  1884. switch (sample_rate) {
  1885. case SAMPLING_RATE_8KHZ:
  1886. sample_rate_val = 0;
  1887. break;
  1888. case SAMPLING_RATE_11P025KHZ:
  1889. sample_rate_val = 1;
  1890. break;
  1891. case SAMPLING_RATE_16KHZ:
  1892. sample_rate_val = 2;
  1893. break;
  1894. case SAMPLING_RATE_22P05KHZ:
  1895. sample_rate_val = 3;
  1896. break;
  1897. case SAMPLING_RATE_32KHZ:
  1898. sample_rate_val = 4;
  1899. break;
  1900. case SAMPLING_RATE_44P1KHZ:
  1901. sample_rate_val = 5;
  1902. break;
  1903. case SAMPLING_RATE_48KHZ:
  1904. sample_rate_val = 6;
  1905. break;
  1906. case SAMPLING_RATE_96KHZ:
  1907. sample_rate_val = 7;
  1908. break;
  1909. case SAMPLING_RATE_192KHZ:
  1910. sample_rate_val = 8;
  1911. break;
  1912. default:
  1913. sample_rate_val = 6;
  1914. break;
  1915. }
  1916. return sample_rate_val;
  1917. }
  1918. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1919. struct snd_ctl_elem_value *ucontrol)
  1920. {
  1921. int idx = mi2s_get_port_idx(kcontrol);
  1922. if (idx < 0)
  1923. return idx;
  1924. ucontrol->value.enumerated.item[0] =
  1925. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  1926. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1927. idx, mi2s_rx_cfg[idx].sample_rate,
  1928. ucontrol->value.enumerated.item[0]);
  1929. return 0;
  1930. }
  1931. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1932. struct snd_ctl_elem_value *ucontrol)
  1933. {
  1934. int idx = mi2s_get_port_idx(kcontrol);
  1935. if (idx < 0)
  1936. return idx;
  1937. mi2s_rx_cfg[idx].sample_rate =
  1938. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1939. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1940. idx, mi2s_rx_cfg[idx].sample_rate,
  1941. ucontrol->value.enumerated.item[0]);
  1942. return 0;
  1943. }
  1944. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1945. struct snd_ctl_elem_value *ucontrol)
  1946. {
  1947. int idx = mi2s_get_port_idx(kcontrol);
  1948. if (idx < 0)
  1949. return idx;
  1950. ucontrol->value.enumerated.item[0] =
  1951. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  1952. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1953. idx, mi2s_tx_cfg[idx].sample_rate,
  1954. ucontrol->value.enumerated.item[0]);
  1955. return 0;
  1956. }
  1957. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1958. struct snd_ctl_elem_value *ucontrol)
  1959. {
  1960. int idx = mi2s_get_port_idx(kcontrol);
  1961. if (idx < 0)
  1962. return idx;
  1963. mi2s_tx_cfg[idx].sample_rate =
  1964. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1965. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1966. idx, mi2s_tx_cfg[idx].sample_rate,
  1967. ucontrol->value.enumerated.item[0]);
  1968. return 0;
  1969. }
  1970. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  1971. struct snd_ctl_elem_value *ucontrol)
  1972. {
  1973. int idx = mi2s_get_port_idx(kcontrol);
  1974. if (idx < 0)
  1975. return idx;
  1976. ucontrol->value.enumerated.item[0] =
  1977. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  1978. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1979. idx, mi2s_rx_cfg[idx].bit_format,
  1980. ucontrol->value.enumerated.item[0]);
  1981. return 0;
  1982. }
  1983. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  1984. struct snd_ctl_elem_value *ucontrol)
  1985. {
  1986. int idx = mi2s_get_port_idx(kcontrol);
  1987. if (idx < 0)
  1988. return idx;
  1989. mi2s_rx_cfg[idx].bit_format =
  1990. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1991. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1992. idx, mi2s_rx_cfg[idx].bit_format,
  1993. ucontrol->value.enumerated.item[0]);
  1994. return 0;
  1995. }
  1996. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  1997. struct snd_ctl_elem_value *ucontrol)
  1998. {
  1999. int idx = mi2s_get_port_idx(kcontrol);
  2000. if (idx < 0)
  2001. return idx;
  2002. ucontrol->value.enumerated.item[0] =
  2003. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2004. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2005. idx, mi2s_tx_cfg[idx].bit_format,
  2006. ucontrol->value.enumerated.item[0]);
  2007. return 0;
  2008. }
  2009. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2010. struct snd_ctl_elem_value *ucontrol)
  2011. {
  2012. int idx = mi2s_get_port_idx(kcontrol);
  2013. if (idx < 0)
  2014. return idx;
  2015. mi2s_tx_cfg[idx].bit_format =
  2016. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2017. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2018. idx, mi2s_tx_cfg[idx].bit_format,
  2019. ucontrol->value.enumerated.item[0]);
  2020. return 0;
  2021. }
  2022. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2023. struct snd_ctl_elem_value *ucontrol)
  2024. {
  2025. int idx = mi2s_get_port_idx(kcontrol);
  2026. if (idx < 0)
  2027. return idx;
  2028. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2029. idx, mi2s_rx_cfg[idx].channels);
  2030. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2031. return 0;
  2032. }
  2033. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2034. struct snd_ctl_elem_value *ucontrol)
  2035. {
  2036. int idx = mi2s_get_port_idx(kcontrol);
  2037. if (idx < 0)
  2038. return idx;
  2039. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2040. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2041. idx, mi2s_rx_cfg[idx].channels);
  2042. return 1;
  2043. }
  2044. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2045. struct snd_ctl_elem_value *ucontrol)
  2046. {
  2047. int idx = mi2s_get_port_idx(kcontrol);
  2048. if (idx < 0)
  2049. return idx;
  2050. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2051. idx, mi2s_tx_cfg[idx].channels);
  2052. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2053. return 0;
  2054. }
  2055. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2056. struct snd_ctl_elem_value *ucontrol)
  2057. {
  2058. int idx = mi2s_get_port_idx(kcontrol);
  2059. if (idx < 0)
  2060. return idx;
  2061. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2062. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2063. idx, mi2s_tx_cfg[idx].channels);
  2064. return 1;
  2065. }
  2066. static int msm_get_port_id(int be_id)
  2067. {
  2068. int afe_port_id = 0;
  2069. switch (be_id) {
  2070. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2071. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  2072. break;
  2073. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2074. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  2075. break;
  2076. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2077. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  2078. break;
  2079. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2080. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  2081. break;
  2082. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2083. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  2084. break;
  2085. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2086. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  2087. break;
  2088. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  2089. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  2090. break;
  2091. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  2092. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  2093. break;
  2094. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  2095. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  2096. break;
  2097. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  2098. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  2099. break;
  2100. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  2101. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  2102. break;
  2103. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  2104. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  2105. break;
  2106. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2107. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  2108. break;
  2109. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2110. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_1;
  2111. break;
  2112. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2113. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_2;
  2114. break;
  2115. default:
  2116. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  2117. afe_port_id = -EINVAL;
  2118. }
  2119. return afe_port_id;
  2120. }
  2121. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  2122. {
  2123. u32 bit_per_sample = 0;
  2124. switch (bit_format) {
  2125. case SNDRV_PCM_FORMAT_S32_LE:
  2126. case SNDRV_PCM_FORMAT_S24_3LE:
  2127. case SNDRV_PCM_FORMAT_S24_LE:
  2128. bit_per_sample = 32;
  2129. break;
  2130. case SNDRV_PCM_FORMAT_S16_LE:
  2131. default:
  2132. bit_per_sample = 16;
  2133. break;
  2134. }
  2135. return bit_per_sample;
  2136. }
  2137. static void update_mi2s_clk_val(int dai_id, int stream)
  2138. {
  2139. u32 bit_per_sample = 0;
  2140. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2141. bit_per_sample =
  2142. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  2143. mi2s_clk[dai_id].clk_freq_in_hz =
  2144. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2145. } else {
  2146. bit_per_sample =
  2147. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  2148. mi2s_clk[dai_id].clk_freq_in_hz =
  2149. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2150. }
  2151. }
  2152. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  2153. {
  2154. int ret = 0;
  2155. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2156. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2157. int port_id = 0;
  2158. int index = cpu_dai->id;
  2159. port_id = msm_get_port_id(rtd->dai_link->id);
  2160. if (port_id < 0) {
  2161. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  2162. ret = port_id;
  2163. goto err;
  2164. }
  2165. if (enable) {
  2166. update_mi2s_clk_val(index, substream->stream);
  2167. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  2168. mi2s_clk[index].clk_freq_in_hz);
  2169. }
  2170. mi2s_clk[index].enable = enable;
  2171. ret = afe_set_lpass_clock_v2(port_id,
  2172. &mi2s_clk[index]);
  2173. if (ret < 0) {
  2174. dev_err(rtd->card->dev,
  2175. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  2176. __func__, port_id, ret);
  2177. goto err;
  2178. }
  2179. err:
  2180. return ret;
  2181. }
  2182. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  2183. {
  2184. int idx = 0;
  2185. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  2186. sizeof("WSA_CDC_DMA_RX_0")))
  2187. idx = WSA_CDC_DMA_RX_0;
  2188. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2189. sizeof("WSA_CDC_DMA_RX_0")))
  2190. idx = WSA_CDC_DMA_RX_1;
  2191. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2192. sizeof("RX_CDC_DMA_RX_0")))
  2193. idx = RX_CDC_DMA_RX_0;
  2194. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2195. sizeof("RX_CDC_DMA_RX_1")))
  2196. idx = RX_CDC_DMA_RX_1;
  2197. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2198. sizeof("RX_CDC_DMA_RX_2")))
  2199. idx = RX_CDC_DMA_RX_2;
  2200. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2201. sizeof("RX_CDC_DMA_RX_3")))
  2202. idx = RX_CDC_DMA_RX_3;
  2203. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2204. sizeof("RX_CDC_DMA_RX_5")))
  2205. idx = RX_CDC_DMA_RX_5;
  2206. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2207. sizeof("WSA_CDC_DMA_TX_0")))
  2208. idx = WSA_CDC_DMA_TX_0;
  2209. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2210. sizeof("WSA_CDC_DMA_TX_1")))
  2211. idx = WSA_CDC_DMA_TX_1;
  2212. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2213. sizeof("WSA_CDC_DMA_TX_2")))
  2214. idx = WSA_CDC_DMA_TX_2;
  2215. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2216. sizeof("TX_CDC_DMA_TX_0")))
  2217. idx = TX_CDC_DMA_TX_0;
  2218. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2219. sizeof("TX_CDC_DMA_TX_3")))
  2220. idx = TX_CDC_DMA_TX_3;
  2221. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2222. sizeof("TX_CDC_DMA_TX_4")))
  2223. idx = TX_CDC_DMA_TX_4;
  2224. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2225. sizeof("VA_CDC_DMA_TX_0")))
  2226. idx = VA_CDC_DMA_TX_0;
  2227. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2228. sizeof("VA_CDC_DMA_TX_1")))
  2229. idx = VA_CDC_DMA_TX_1;
  2230. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2231. sizeof("VA_CDC_DMA_TX_2")))
  2232. idx = VA_CDC_DMA_TX_2;
  2233. else {
  2234. pr_err("%s: unsupported channel: %s\n",
  2235. __func__, kcontrol->id.name);
  2236. return -EINVAL;
  2237. }
  2238. return idx;
  2239. }
  2240. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2241. struct snd_ctl_elem_value *ucontrol)
  2242. {
  2243. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2244. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2245. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2246. return ch_num;
  2247. }
  2248. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2249. cdc_dma_rx_cfg[ch_num].channels - 1);
  2250. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2251. return 0;
  2252. }
  2253. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2254. struct snd_ctl_elem_value *ucontrol)
  2255. {
  2256. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2257. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2258. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2259. return ch_num;
  2260. }
  2261. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2262. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2263. cdc_dma_rx_cfg[ch_num].channels);
  2264. return 1;
  2265. }
  2266. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2267. struct snd_ctl_elem_value *ucontrol)
  2268. {
  2269. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2270. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2271. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2272. return ch_num;
  2273. }
  2274. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2275. case SNDRV_PCM_FORMAT_S32_LE:
  2276. ucontrol->value.integer.value[0] = 3;
  2277. break;
  2278. case SNDRV_PCM_FORMAT_S24_3LE:
  2279. ucontrol->value.integer.value[0] = 2;
  2280. break;
  2281. case SNDRV_PCM_FORMAT_S24_LE:
  2282. ucontrol->value.integer.value[0] = 1;
  2283. break;
  2284. case SNDRV_PCM_FORMAT_S16_LE:
  2285. default:
  2286. ucontrol->value.integer.value[0] = 0;
  2287. break;
  2288. }
  2289. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2290. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2291. ucontrol->value.integer.value[0]);
  2292. return 0;
  2293. }
  2294. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2295. struct snd_ctl_elem_value *ucontrol)
  2296. {
  2297. int rc = 0;
  2298. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2299. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2300. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2301. return ch_num;
  2302. }
  2303. switch (ucontrol->value.integer.value[0]) {
  2304. case 3:
  2305. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2306. break;
  2307. case 2:
  2308. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2309. break;
  2310. case 1:
  2311. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2312. break;
  2313. case 0:
  2314. default:
  2315. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2316. break;
  2317. }
  2318. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2319. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2320. ucontrol->value.integer.value[0]);
  2321. return rc;
  2322. }
  2323. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2324. {
  2325. int sample_rate_val = 0;
  2326. switch (sample_rate) {
  2327. case SAMPLING_RATE_8KHZ:
  2328. sample_rate_val = 0;
  2329. break;
  2330. case SAMPLING_RATE_11P025KHZ:
  2331. sample_rate_val = 1;
  2332. break;
  2333. case SAMPLING_RATE_16KHZ:
  2334. sample_rate_val = 2;
  2335. break;
  2336. case SAMPLING_RATE_22P05KHZ:
  2337. sample_rate_val = 3;
  2338. break;
  2339. case SAMPLING_RATE_32KHZ:
  2340. sample_rate_val = 4;
  2341. break;
  2342. case SAMPLING_RATE_44P1KHZ:
  2343. sample_rate_val = 5;
  2344. break;
  2345. case SAMPLING_RATE_48KHZ:
  2346. sample_rate_val = 6;
  2347. break;
  2348. case SAMPLING_RATE_88P2KHZ:
  2349. sample_rate_val = 7;
  2350. break;
  2351. case SAMPLING_RATE_96KHZ:
  2352. sample_rate_val = 8;
  2353. break;
  2354. case SAMPLING_RATE_176P4KHZ:
  2355. sample_rate_val = 9;
  2356. break;
  2357. case SAMPLING_RATE_192KHZ:
  2358. sample_rate_val = 10;
  2359. break;
  2360. case SAMPLING_RATE_352P8KHZ:
  2361. sample_rate_val = 11;
  2362. break;
  2363. case SAMPLING_RATE_384KHZ:
  2364. sample_rate_val = 12;
  2365. break;
  2366. default:
  2367. sample_rate_val = 6;
  2368. break;
  2369. }
  2370. return sample_rate_val;
  2371. }
  2372. static int cdc_dma_get_sample_rate(int value)
  2373. {
  2374. int sample_rate = 0;
  2375. switch (value) {
  2376. case 0:
  2377. sample_rate = SAMPLING_RATE_8KHZ;
  2378. break;
  2379. case 1:
  2380. sample_rate = SAMPLING_RATE_11P025KHZ;
  2381. break;
  2382. case 2:
  2383. sample_rate = SAMPLING_RATE_16KHZ;
  2384. break;
  2385. case 3:
  2386. sample_rate = SAMPLING_RATE_22P05KHZ;
  2387. break;
  2388. case 4:
  2389. sample_rate = SAMPLING_RATE_32KHZ;
  2390. break;
  2391. case 5:
  2392. sample_rate = SAMPLING_RATE_44P1KHZ;
  2393. break;
  2394. case 6:
  2395. sample_rate = SAMPLING_RATE_48KHZ;
  2396. break;
  2397. case 7:
  2398. sample_rate = SAMPLING_RATE_88P2KHZ;
  2399. break;
  2400. case 8:
  2401. sample_rate = SAMPLING_RATE_96KHZ;
  2402. break;
  2403. case 9:
  2404. sample_rate = SAMPLING_RATE_176P4KHZ;
  2405. break;
  2406. case 10:
  2407. sample_rate = SAMPLING_RATE_192KHZ;
  2408. break;
  2409. case 11:
  2410. sample_rate = SAMPLING_RATE_352P8KHZ;
  2411. break;
  2412. case 12:
  2413. sample_rate = SAMPLING_RATE_384KHZ;
  2414. break;
  2415. default:
  2416. sample_rate = SAMPLING_RATE_48KHZ;
  2417. break;
  2418. }
  2419. return sample_rate;
  2420. }
  2421. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2422. struct snd_ctl_elem_value *ucontrol)
  2423. {
  2424. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2425. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2426. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2427. return ch_num;
  2428. }
  2429. ucontrol->value.enumerated.item[0] =
  2430. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2431. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2432. cdc_dma_rx_cfg[ch_num].sample_rate);
  2433. return 0;
  2434. }
  2435. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2436. struct snd_ctl_elem_value *ucontrol)
  2437. {
  2438. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2439. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2440. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2441. return ch_num;
  2442. }
  2443. cdc_dma_rx_cfg[ch_num].sample_rate =
  2444. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2445. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2446. __func__, ucontrol->value.enumerated.item[0],
  2447. cdc_dma_rx_cfg[ch_num].sample_rate);
  2448. return 0;
  2449. }
  2450. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2451. struct snd_ctl_elem_value *ucontrol)
  2452. {
  2453. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2454. if (ch_num < 0) {
  2455. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2456. return ch_num;
  2457. }
  2458. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2459. cdc_dma_tx_cfg[ch_num].channels);
  2460. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2461. return 0;
  2462. }
  2463. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2464. struct snd_ctl_elem_value *ucontrol)
  2465. {
  2466. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2467. if (ch_num < 0) {
  2468. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2469. return ch_num;
  2470. }
  2471. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2472. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2473. cdc_dma_tx_cfg[ch_num].channels);
  2474. return 1;
  2475. }
  2476. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2477. struct snd_ctl_elem_value *ucontrol)
  2478. {
  2479. int sample_rate_val;
  2480. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2481. if (ch_num < 0) {
  2482. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2483. return ch_num;
  2484. }
  2485. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2486. case SAMPLING_RATE_384KHZ:
  2487. sample_rate_val = 12;
  2488. break;
  2489. case SAMPLING_RATE_352P8KHZ:
  2490. sample_rate_val = 11;
  2491. break;
  2492. case SAMPLING_RATE_192KHZ:
  2493. sample_rate_val = 10;
  2494. break;
  2495. case SAMPLING_RATE_176P4KHZ:
  2496. sample_rate_val = 9;
  2497. break;
  2498. case SAMPLING_RATE_96KHZ:
  2499. sample_rate_val = 8;
  2500. break;
  2501. case SAMPLING_RATE_88P2KHZ:
  2502. sample_rate_val = 7;
  2503. break;
  2504. case SAMPLING_RATE_48KHZ:
  2505. sample_rate_val = 6;
  2506. break;
  2507. case SAMPLING_RATE_44P1KHZ:
  2508. sample_rate_val = 5;
  2509. break;
  2510. case SAMPLING_RATE_32KHZ:
  2511. sample_rate_val = 4;
  2512. break;
  2513. case SAMPLING_RATE_22P05KHZ:
  2514. sample_rate_val = 3;
  2515. break;
  2516. case SAMPLING_RATE_16KHZ:
  2517. sample_rate_val = 2;
  2518. break;
  2519. case SAMPLING_RATE_11P025KHZ:
  2520. sample_rate_val = 1;
  2521. break;
  2522. case SAMPLING_RATE_8KHZ:
  2523. sample_rate_val = 0;
  2524. break;
  2525. default:
  2526. sample_rate_val = 6;
  2527. break;
  2528. }
  2529. ucontrol->value.integer.value[0] = sample_rate_val;
  2530. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2531. cdc_dma_tx_cfg[ch_num].sample_rate);
  2532. return 0;
  2533. }
  2534. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2535. struct snd_ctl_elem_value *ucontrol)
  2536. {
  2537. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2538. if (ch_num < 0) {
  2539. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2540. return ch_num;
  2541. }
  2542. switch (ucontrol->value.integer.value[0]) {
  2543. case 12:
  2544. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2545. break;
  2546. case 11:
  2547. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2548. break;
  2549. case 10:
  2550. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2551. break;
  2552. case 9:
  2553. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2554. break;
  2555. case 8:
  2556. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2557. break;
  2558. case 7:
  2559. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2560. break;
  2561. case 6:
  2562. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2563. break;
  2564. case 5:
  2565. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2566. break;
  2567. case 4:
  2568. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2569. break;
  2570. case 3:
  2571. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2572. break;
  2573. case 2:
  2574. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2575. break;
  2576. case 1:
  2577. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2578. break;
  2579. case 0:
  2580. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2581. break;
  2582. default:
  2583. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2584. break;
  2585. }
  2586. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2587. __func__, ucontrol->value.integer.value[0],
  2588. cdc_dma_tx_cfg[ch_num].sample_rate);
  2589. return 0;
  2590. }
  2591. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2592. struct snd_ctl_elem_value *ucontrol)
  2593. {
  2594. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2595. if (ch_num < 0) {
  2596. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2597. return ch_num;
  2598. }
  2599. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2600. case SNDRV_PCM_FORMAT_S32_LE:
  2601. ucontrol->value.integer.value[0] = 3;
  2602. break;
  2603. case SNDRV_PCM_FORMAT_S24_3LE:
  2604. ucontrol->value.integer.value[0] = 2;
  2605. break;
  2606. case SNDRV_PCM_FORMAT_S24_LE:
  2607. ucontrol->value.integer.value[0] = 1;
  2608. break;
  2609. case SNDRV_PCM_FORMAT_S16_LE:
  2610. default:
  2611. ucontrol->value.integer.value[0] = 0;
  2612. break;
  2613. }
  2614. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2615. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2616. ucontrol->value.integer.value[0]);
  2617. return 0;
  2618. }
  2619. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2620. struct snd_ctl_elem_value *ucontrol)
  2621. {
  2622. int rc = 0;
  2623. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2624. if (ch_num < 0) {
  2625. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2626. return ch_num;
  2627. }
  2628. switch (ucontrol->value.integer.value[0]) {
  2629. case 3:
  2630. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2631. break;
  2632. case 2:
  2633. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2634. break;
  2635. case 1:
  2636. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2637. break;
  2638. case 0:
  2639. default:
  2640. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2641. break;
  2642. }
  2643. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2644. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2645. ucontrol->value.integer.value[0]);
  2646. return rc;
  2647. }
  2648. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2649. {
  2650. int idx = 0;
  2651. switch (be_id) {
  2652. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2653. idx = WSA_CDC_DMA_RX_0;
  2654. break;
  2655. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2656. idx = WSA_CDC_DMA_TX_0;
  2657. break;
  2658. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2659. idx = WSA_CDC_DMA_RX_1;
  2660. break;
  2661. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2662. idx = WSA_CDC_DMA_TX_1;
  2663. break;
  2664. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2665. idx = WSA_CDC_DMA_TX_2;
  2666. break;
  2667. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2668. idx = RX_CDC_DMA_RX_0;
  2669. break;
  2670. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2671. idx = RX_CDC_DMA_RX_1;
  2672. break;
  2673. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2674. idx = RX_CDC_DMA_RX_2;
  2675. break;
  2676. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2677. idx = RX_CDC_DMA_RX_3;
  2678. break;
  2679. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2680. idx = RX_CDC_DMA_RX_5;
  2681. break;
  2682. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2683. idx = TX_CDC_DMA_TX_0;
  2684. break;
  2685. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2686. idx = TX_CDC_DMA_TX_3;
  2687. break;
  2688. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2689. idx = TX_CDC_DMA_TX_4;
  2690. break;
  2691. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2692. idx = VA_CDC_DMA_TX_0;
  2693. break;
  2694. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2695. idx = VA_CDC_DMA_TX_1;
  2696. break;
  2697. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2698. idx = VA_CDC_DMA_TX_2;
  2699. break;
  2700. default:
  2701. idx = RX_CDC_DMA_RX_0;
  2702. break;
  2703. }
  2704. return idx;
  2705. }
  2706. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  2707. struct snd_ctl_elem_value *ucontrol)
  2708. {
  2709. /*
  2710. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  2711. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  2712. * value.
  2713. */
  2714. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  2715. case SAMPLING_RATE_96KHZ:
  2716. ucontrol->value.integer.value[0] = 5;
  2717. break;
  2718. case SAMPLING_RATE_88P2KHZ:
  2719. ucontrol->value.integer.value[0] = 4;
  2720. break;
  2721. case SAMPLING_RATE_48KHZ:
  2722. ucontrol->value.integer.value[0] = 3;
  2723. break;
  2724. case SAMPLING_RATE_44P1KHZ:
  2725. ucontrol->value.integer.value[0] = 2;
  2726. break;
  2727. case SAMPLING_RATE_16KHZ:
  2728. ucontrol->value.integer.value[0] = 1;
  2729. break;
  2730. case SAMPLING_RATE_8KHZ:
  2731. default:
  2732. ucontrol->value.integer.value[0] = 0;
  2733. break;
  2734. }
  2735. pr_debug("%s: sample rate = %d\n", __func__,
  2736. slim_rx_cfg[SLIM_RX_7].sample_rate);
  2737. return 0;
  2738. }
  2739. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  2740. struct snd_ctl_elem_value *ucontrol)
  2741. {
  2742. switch (ucontrol->value.integer.value[0]) {
  2743. case 1:
  2744. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2745. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2746. break;
  2747. case 2:
  2748. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2749. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2750. break;
  2751. case 3:
  2752. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2753. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2754. break;
  2755. case 4:
  2756. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2757. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2758. break;
  2759. case 5:
  2760. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2761. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2762. break;
  2763. case 0:
  2764. default:
  2765. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2766. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2767. break;
  2768. }
  2769. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  2770. __func__,
  2771. slim_rx_cfg[SLIM_RX_7].sample_rate,
  2772. slim_tx_cfg[SLIM_TX_7].sample_rate,
  2773. ucontrol->value.enumerated.item[0]);
  2774. return 0;
  2775. }
  2776. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  2777. struct snd_ctl_elem_value *ucontrol)
  2778. {
  2779. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  2780. case SAMPLING_RATE_96KHZ:
  2781. ucontrol->value.integer.value[0] = 5;
  2782. break;
  2783. case SAMPLING_RATE_88P2KHZ:
  2784. ucontrol->value.integer.value[0] = 4;
  2785. break;
  2786. case SAMPLING_RATE_48KHZ:
  2787. ucontrol->value.integer.value[0] = 3;
  2788. break;
  2789. case SAMPLING_RATE_44P1KHZ:
  2790. ucontrol->value.integer.value[0] = 2;
  2791. break;
  2792. case SAMPLING_RATE_16KHZ:
  2793. ucontrol->value.integer.value[0] = 1;
  2794. break;
  2795. case SAMPLING_RATE_8KHZ:
  2796. default:
  2797. ucontrol->value.integer.value[0] = 0;
  2798. break;
  2799. }
  2800. pr_debug("%s: sample rate rx = %d\n", __func__,
  2801. slim_rx_cfg[SLIM_RX_7].sample_rate);
  2802. return 0;
  2803. }
  2804. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  2805. struct snd_ctl_elem_value *ucontrol)
  2806. {
  2807. switch (ucontrol->value.integer.value[0]) {
  2808. case 1:
  2809. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2810. break;
  2811. case 2:
  2812. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2813. break;
  2814. case 3:
  2815. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2816. break;
  2817. case 4:
  2818. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2819. break;
  2820. case 5:
  2821. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2822. break;
  2823. case 0:
  2824. default:
  2825. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2826. break;
  2827. }
  2828. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  2829. __func__,
  2830. slim_rx_cfg[SLIM_RX_7].sample_rate,
  2831. ucontrol->value.enumerated.item[0]);
  2832. return 0;
  2833. }
  2834. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  2835. struct snd_ctl_elem_value *ucontrol)
  2836. {
  2837. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  2838. case SAMPLING_RATE_96KHZ:
  2839. ucontrol->value.integer.value[0] = 5;
  2840. break;
  2841. case SAMPLING_RATE_88P2KHZ:
  2842. ucontrol->value.integer.value[0] = 4;
  2843. break;
  2844. case SAMPLING_RATE_48KHZ:
  2845. ucontrol->value.integer.value[0] = 3;
  2846. break;
  2847. case SAMPLING_RATE_44P1KHZ:
  2848. ucontrol->value.integer.value[0] = 2;
  2849. break;
  2850. case SAMPLING_RATE_16KHZ:
  2851. ucontrol->value.integer.value[0] = 1;
  2852. break;
  2853. case SAMPLING_RATE_8KHZ:
  2854. default:
  2855. ucontrol->value.integer.value[0] = 0;
  2856. break;
  2857. }
  2858. pr_debug("%s: sample rate tx = %d\n", __func__,
  2859. slim_tx_cfg[SLIM_TX_7].sample_rate);
  2860. return 0;
  2861. }
  2862. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  2863. struct snd_ctl_elem_value *ucontrol)
  2864. {
  2865. switch (ucontrol->value.integer.value[0]) {
  2866. case 1:
  2867. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2868. break;
  2869. case 2:
  2870. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2871. break;
  2872. case 3:
  2873. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2874. break;
  2875. case 4:
  2876. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2877. break;
  2878. case 5:
  2879. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2880. break;
  2881. case 0:
  2882. default:
  2883. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2884. break;
  2885. }
  2886. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  2887. __func__,
  2888. slim_tx_cfg[SLIM_TX_7].sample_rate,
  2889. ucontrol->value.enumerated.item[0]);
  2890. return 0;
  2891. }
  2892. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  2893. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  2894. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2895. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  2896. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2897. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  2898. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2899. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  2900. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2901. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  2902. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2903. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  2904. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2905. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  2906. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2907. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  2908. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2909. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  2910. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2911. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  2912. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2913. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  2914. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2915. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  2916. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2917. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  2918. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2919. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  2920. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2921. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  2922. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2923. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  2924. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2925. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  2926. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2927. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  2928. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2929. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  2930. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2931. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  2932. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2933. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  2934. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2935. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  2936. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2937. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  2938. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2939. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  2940. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2941. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  2942. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2943. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  2944. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2945. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  2946. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2947. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  2948. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2949. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  2950. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2951. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  2952. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2953. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  2954. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2955. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  2956. wsa_cdc_dma_rx_0_sample_rate,
  2957. cdc_dma_rx_sample_rate_get,
  2958. cdc_dma_rx_sample_rate_put),
  2959. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  2960. wsa_cdc_dma_rx_1_sample_rate,
  2961. cdc_dma_rx_sample_rate_get,
  2962. cdc_dma_rx_sample_rate_put),
  2963. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  2964. rx_cdc_dma_rx_0_sample_rate,
  2965. cdc_dma_rx_sample_rate_get,
  2966. cdc_dma_rx_sample_rate_put),
  2967. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  2968. rx_cdc_dma_rx_1_sample_rate,
  2969. cdc_dma_rx_sample_rate_get,
  2970. cdc_dma_rx_sample_rate_put),
  2971. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  2972. rx_cdc_dma_rx_2_sample_rate,
  2973. cdc_dma_rx_sample_rate_get,
  2974. cdc_dma_rx_sample_rate_put),
  2975. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  2976. rx_cdc_dma_rx_3_sample_rate,
  2977. cdc_dma_rx_sample_rate_get,
  2978. cdc_dma_rx_sample_rate_put),
  2979. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  2980. rx_cdc_dma_rx_5_sample_rate,
  2981. cdc_dma_rx_sample_rate_get,
  2982. cdc_dma_rx_sample_rate_put),
  2983. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  2984. wsa_cdc_dma_tx_0_sample_rate,
  2985. cdc_dma_tx_sample_rate_get,
  2986. cdc_dma_tx_sample_rate_put),
  2987. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  2988. wsa_cdc_dma_tx_1_sample_rate,
  2989. cdc_dma_tx_sample_rate_get,
  2990. cdc_dma_tx_sample_rate_put),
  2991. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  2992. wsa_cdc_dma_tx_2_sample_rate,
  2993. cdc_dma_tx_sample_rate_get,
  2994. cdc_dma_tx_sample_rate_put),
  2995. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  2996. tx_cdc_dma_tx_0_sample_rate,
  2997. cdc_dma_tx_sample_rate_get,
  2998. cdc_dma_tx_sample_rate_put),
  2999. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3000. tx_cdc_dma_tx_3_sample_rate,
  3001. cdc_dma_tx_sample_rate_get,
  3002. cdc_dma_tx_sample_rate_put),
  3003. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3004. tx_cdc_dma_tx_4_sample_rate,
  3005. cdc_dma_tx_sample_rate_get,
  3006. cdc_dma_tx_sample_rate_put),
  3007. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3008. va_cdc_dma_tx_0_sample_rate,
  3009. cdc_dma_tx_sample_rate_get,
  3010. cdc_dma_tx_sample_rate_put),
  3011. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3012. va_cdc_dma_tx_1_sample_rate,
  3013. cdc_dma_tx_sample_rate_get,
  3014. cdc_dma_tx_sample_rate_put),
  3015. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  3016. va_cdc_dma_tx_2_sample_rate,
  3017. cdc_dma_tx_sample_rate_get,
  3018. cdc_dma_tx_sample_rate_put),
  3019. };
  3020. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3021. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3022. usb_audio_rx_sample_rate_get,
  3023. usb_audio_rx_sample_rate_put),
  3024. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3025. usb_audio_tx_sample_rate_get,
  3026. usb_audio_tx_sample_rate_put),
  3027. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3028. tdm_rx_sample_rate_get,
  3029. tdm_rx_sample_rate_put),
  3030. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3031. tdm_rx_sample_rate_get,
  3032. tdm_rx_sample_rate_put),
  3033. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3034. tdm_rx_sample_rate_get,
  3035. tdm_rx_sample_rate_put),
  3036. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3037. tdm_rx_sample_rate_get,
  3038. tdm_rx_sample_rate_put),
  3039. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3040. tdm_rx_sample_rate_get,
  3041. tdm_rx_sample_rate_put),
  3042. SOC_ENUM_EXT("SEN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3043. tdm_rx_sample_rate_get,
  3044. tdm_rx_sample_rate_put),
  3045. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3046. tdm_tx_sample_rate_get,
  3047. tdm_tx_sample_rate_put),
  3048. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3049. tdm_tx_sample_rate_get,
  3050. tdm_tx_sample_rate_put),
  3051. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3052. tdm_tx_sample_rate_get,
  3053. tdm_tx_sample_rate_put),
  3054. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3055. tdm_tx_sample_rate_get,
  3056. tdm_tx_sample_rate_put),
  3057. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3058. tdm_tx_sample_rate_get,
  3059. tdm_tx_sample_rate_put),
  3060. SOC_ENUM_EXT("SEN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3061. tdm_tx_sample_rate_get,
  3062. tdm_tx_sample_rate_put),
  3063. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3064. aux_pcm_rx_sample_rate_get,
  3065. aux_pcm_rx_sample_rate_put),
  3066. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3067. aux_pcm_rx_sample_rate_get,
  3068. aux_pcm_rx_sample_rate_put),
  3069. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3070. aux_pcm_rx_sample_rate_get,
  3071. aux_pcm_rx_sample_rate_put),
  3072. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3073. aux_pcm_rx_sample_rate_get,
  3074. aux_pcm_rx_sample_rate_put),
  3075. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3076. aux_pcm_rx_sample_rate_get,
  3077. aux_pcm_rx_sample_rate_put),
  3078. SOC_ENUM_EXT("SEN_AUX_PCM_RX SampleRate", sen_aux_pcm_rx_sample_rate,
  3079. aux_pcm_rx_sample_rate_get,
  3080. aux_pcm_rx_sample_rate_put),
  3081. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3082. aux_pcm_tx_sample_rate_get,
  3083. aux_pcm_tx_sample_rate_put),
  3084. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3085. aux_pcm_tx_sample_rate_get,
  3086. aux_pcm_tx_sample_rate_put),
  3087. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3088. aux_pcm_tx_sample_rate_get,
  3089. aux_pcm_tx_sample_rate_put),
  3090. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3091. aux_pcm_tx_sample_rate_get,
  3092. aux_pcm_tx_sample_rate_put),
  3093. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3094. aux_pcm_tx_sample_rate_get,
  3095. aux_pcm_tx_sample_rate_put),
  3096. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3097. aux_pcm_tx_sample_rate_get,
  3098. aux_pcm_tx_sample_rate_put),
  3099. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3100. mi2s_rx_sample_rate_get,
  3101. mi2s_rx_sample_rate_put),
  3102. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3103. mi2s_rx_sample_rate_get,
  3104. mi2s_rx_sample_rate_put),
  3105. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3106. mi2s_rx_sample_rate_get,
  3107. mi2s_rx_sample_rate_put),
  3108. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3109. mi2s_rx_sample_rate_get,
  3110. mi2s_rx_sample_rate_put),
  3111. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3112. mi2s_rx_sample_rate_get,
  3113. mi2s_rx_sample_rate_put),
  3114. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3115. mi2s_rx_sample_rate_get,
  3116. mi2s_rx_sample_rate_put),
  3117. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3118. mi2s_tx_sample_rate_get,
  3119. mi2s_tx_sample_rate_put),
  3120. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3121. mi2s_tx_sample_rate_get,
  3122. mi2s_tx_sample_rate_put),
  3123. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3124. mi2s_tx_sample_rate_get,
  3125. mi2s_tx_sample_rate_put),
  3126. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3127. mi2s_tx_sample_rate_get,
  3128. mi2s_tx_sample_rate_put),
  3129. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3130. mi2s_tx_sample_rate_get,
  3131. mi2s_tx_sample_rate_put),
  3132. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3133. mi2s_tx_sample_rate_get,
  3134. mi2s_tx_sample_rate_put),
  3135. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3136. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3137. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3138. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3139. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3140. tdm_rx_format_get,
  3141. tdm_rx_format_put),
  3142. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3143. tdm_rx_format_get,
  3144. tdm_rx_format_put),
  3145. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3146. tdm_rx_format_get,
  3147. tdm_rx_format_put),
  3148. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3149. tdm_rx_format_get,
  3150. tdm_rx_format_put),
  3151. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3152. tdm_rx_format_get,
  3153. tdm_rx_format_put),
  3154. SOC_ENUM_EXT("SEN_TDM_RX_0 Format", tdm_rx_format,
  3155. tdm_rx_format_get,
  3156. tdm_rx_format_put),
  3157. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3158. tdm_tx_format_get,
  3159. tdm_tx_format_put),
  3160. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3161. tdm_tx_format_get,
  3162. tdm_tx_format_put),
  3163. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3164. tdm_tx_format_get,
  3165. tdm_tx_format_put),
  3166. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3167. tdm_tx_format_get,
  3168. tdm_tx_format_put),
  3169. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3170. tdm_tx_format_get,
  3171. tdm_tx_format_put),
  3172. SOC_ENUM_EXT("SEN_TDM_TX_0 Format", tdm_tx_format,
  3173. tdm_tx_format_get,
  3174. tdm_tx_format_put),
  3175. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3176. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3177. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3178. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3179. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3180. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3181. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3182. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3183. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3184. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3185. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3186. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3187. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3188. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3189. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3190. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3191. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3192. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3193. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3194. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3195. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3196. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3197. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3198. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3199. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3200. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3201. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3202. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3203. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3204. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3205. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3206. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3207. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3208. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3209. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3210. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3211. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3212. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3213. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3214. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3215. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3216. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3217. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3218. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3219. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3220. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3221. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3222. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3223. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3224. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3225. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3226. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3227. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3228. proxy_rx_ch_get, proxy_rx_ch_put),
  3229. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3230. tdm_rx_ch_get,
  3231. tdm_rx_ch_put),
  3232. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3233. tdm_rx_ch_get,
  3234. tdm_rx_ch_put),
  3235. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3236. tdm_rx_ch_get,
  3237. tdm_rx_ch_put),
  3238. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3239. tdm_rx_ch_get,
  3240. tdm_rx_ch_put),
  3241. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3242. tdm_rx_ch_get,
  3243. tdm_rx_ch_put),
  3244. SOC_ENUM_EXT("SEN_TDM_RX_0 Channels", tdm_rx_chs,
  3245. tdm_rx_ch_get,
  3246. tdm_rx_ch_put),
  3247. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3248. tdm_tx_ch_get,
  3249. tdm_tx_ch_put),
  3250. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3251. tdm_tx_ch_get,
  3252. tdm_tx_ch_put),
  3253. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3254. tdm_tx_ch_get,
  3255. tdm_tx_ch_put),
  3256. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3257. tdm_tx_ch_get,
  3258. tdm_tx_ch_put),
  3259. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3260. tdm_tx_ch_get,
  3261. tdm_tx_ch_put),
  3262. SOC_ENUM_EXT("SEN_TDM_TX_0 Channels", tdm_tx_chs,
  3263. tdm_tx_ch_get,
  3264. tdm_tx_ch_put),
  3265. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3266. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3267. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3268. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3269. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3270. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3271. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3272. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3273. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3274. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3275. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3276. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3277. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3278. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3279. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3280. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3281. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3282. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3283. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3284. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3285. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3286. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3287. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3288. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3289. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3290. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3291. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3292. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3293. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3294. ext_disp_rx_sample_rate_get,
  3295. ext_disp_rx_sample_rate_put),
  3296. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3297. msm_bt_sample_rate_get,
  3298. msm_bt_sample_rate_put),
  3299. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3300. msm_bt_sample_rate_rx_get,
  3301. msm_bt_sample_rate_rx_put),
  3302. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3303. msm_bt_sample_rate_tx_get,
  3304. msm_bt_sample_rate_tx_put),
  3305. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  3306. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  3307. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3308. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3309. };
  3310. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3311. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3312. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3313. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3314. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3315. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3316. aux_pcm_rx_sample_rate_get,
  3317. aux_pcm_rx_sample_rate_put),
  3318. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3319. aux_pcm_tx_sample_rate_get,
  3320. aux_pcm_tx_sample_rate_put),
  3321. };
  3322. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3323. {
  3324. int idx;
  3325. switch (be_id) {
  3326. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3327. idx = EXT_DISP_RX_IDX_DP;
  3328. break;
  3329. default:
  3330. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3331. idx = -EINVAL;
  3332. break;
  3333. }
  3334. return idx;
  3335. }
  3336. static int kona_send_island_va_config(int32_t be_id)
  3337. {
  3338. int rc = 0;
  3339. int port_id = 0xFFFF;
  3340. port_id = msm_get_port_id(be_id);
  3341. if (port_id < 0) {
  3342. pr_err("%s: Invalid island interface, be_id: %d\n",
  3343. __func__, be_id);
  3344. rc = -EINVAL;
  3345. } else {
  3346. /*
  3347. * send island mode config
  3348. * This should be the first configuration
  3349. */
  3350. rc = afe_send_port_island_mode(port_id);
  3351. if (rc)
  3352. pr_err("%s: afe send island mode failed %d\n",
  3353. __func__, rc);
  3354. }
  3355. return rc;
  3356. }
  3357. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3358. struct snd_pcm_hw_params *params)
  3359. {
  3360. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3361. struct snd_interval *rate = hw_param_interval(params,
  3362. SNDRV_PCM_HW_PARAM_RATE);
  3363. struct snd_interval *channels = hw_param_interval(params,
  3364. SNDRV_PCM_HW_PARAM_CHANNELS);
  3365. int idx = 0, rc = 0;
  3366. pr_debug("%s: format = %d, rate = %d\n",
  3367. __func__, params_format(params), params_rate(params));
  3368. switch (dai_link->id) {
  3369. case MSM_BACKEND_DAI_USB_RX:
  3370. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3371. usb_rx_cfg.bit_format);
  3372. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3373. channels->min = channels->max = usb_rx_cfg.channels;
  3374. break;
  3375. case MSM_BACKEND_DAI_USB_TX:
  3376. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3377. usb_tx_cfg.bit_format);
  3378. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3379. channels->min = channels->max = usb_tx_cfg.channels;
  3380. break;
  3381. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3382. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3383. if (idx < 0) {
  3384. pr_err("%s: Incorrect ext disp idx %d\n",
  3385. __func__, idx);
  3386. rc = idx;
  3387. goto done;
  3388. }
  3389. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3390. ext_disp_rx_cfg[idx].bit_format);
  3391. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3392. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3393. break;
  3394. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3395. channels->min = channels->max = proxy_rx_cfg.channels;
  3396. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3397. break;
  3398. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3399. channels->min = channels->max =
  3400. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3401. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3402. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3403. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3404. break;
  3405. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3406. channels->min = channels->max =
  3407. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3408. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3409. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3410. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3411. break;
  3412. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3413. channels->min = channels->max =
  3414. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3415. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3416. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3417. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3418. break;
  3419. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3420. channels->min = channels->max =
  3421. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3422. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3423. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3424. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3425. break;
  3426. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3427. channels->min = channels->max =
  3428. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3429. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3430. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3431. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3432. break;
  3433. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3434. channels->min = channels->max =
  3435. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3436. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3437. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3438. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3439. break;
  3440. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3441. channels->min = channels->max =
  3442. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3443. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3444. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3445. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3446. break;
  3447. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3448. channels->min = channels->max =
  3449. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3450. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3451. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3452. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3453. break;
  3454. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3455. channels->min = channels->max =
  3456. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3457. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3458. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3459. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3460. break;
  3461. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3462. channels->min = channels->max =
  3463. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3464. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3465. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3466. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3467. break;
  3468. case MSM_BACKEND_DAI_SEN_TDM_RX_0:
  3469. channels->min = channels->max =
  3470. tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3471. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3472. tdm_rx_cfg[TDM_SEN][TDM_0].bit_format);
  3473. rate->min = rate->max = tdm_rx_cfg[TDM_SEN][TDM_0].sample_rate;
  3474. break;
  3475. case MSM_BACKEND_DAI_SEN_TDM_TX_0:
  3476. channels->min = channels->max =
  3477. tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3478. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3479. tdm_tx_cfg[TDM_SEN][TDM_0].bit_format);
  3480. rate->min = rate->max = tdm_tx_cfg[TDM_SEN][TDM_0].sample_rate;
  3481. break;
  3482. case MSM_BACKEND_DAI_AUXPCM_RX:
  3483. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3484. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3485. rate->min = rate->max =
  3486. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3487. channels->min = channels->max =
  3488. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3489. break;
  3490. case MSM_BACKEND_DAI_AUXPCM_TX:
  3491. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3492. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3493. rate->min = rate->max =
  3494. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3495. channels->min = channels->max =
  3496. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3497. break;
  3498. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3499. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3500. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3501. rate->min = rate->max =
  3502. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3503. channels->min = channels->max =
  3504. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3505. break;
  3506. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3507. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3508. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3509. rate->min = rate->max =
  3510. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3511. channels->min = channels->max =
  3512. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3513. break;
  3514. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3515. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3516. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3517. rate->min = rate->max =
  3518. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3519. channels->min = channels->max =
  3520. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3521. break;
  3522. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3523. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3524. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3525. rate->min = rate->max =
  3526. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3527. channels->min = channels->max =
  3528. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3529. break;
  3530. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  3531. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3532. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  3533. rate->min = rate->max =
  3534. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  3535. channels->min = channels->max =
  3536. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  3537. break;
  3538. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  3539. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3540. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  3541. rate->min = rate->max =
  3542. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  3543. channels->min = channels->max =
  3544. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  3545. break;
  3546. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  3547. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3548. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  3549. rate->min = rate->max =
  3550. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  3551. channels->min = channels->max =
  3552. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  3553. break;
  3554. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  3555. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3556. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  3557. rate->min = rate->max =
  3558. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  3559. channels->min = channels->max =
  3560. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  3561. break;
  3562. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  3563. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3564. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  3565. rate->min = rate->max =
  3566. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  3567. channels->min = channels->max =
  3568. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  3569. break;
  3570. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  3571. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3572. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  3573. rate->min = rate->max =
  3574. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  3575. channels->min = channels->max =
  3576. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  3577. break;
  3578. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3579. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3580. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  3581. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  3582. channels->min = channels->max =
  3583. mi2s_rx_cfg[PRIM_MI2S].channels;
  3584. break;
  3585. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3586. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3587. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  3588. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  3589. channels->min = channels->max =
  3590. mi2s_tx_cfg[PRIM_MI2S].channels;
  3591. break;
  3592. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3593. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3594. mi2s_rx_cfg[SEC_MI2S].bit_format);
  3595. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  3596. channels->min = channels->max =
  3597. mi2s_rx_cfg[SEC_MI2S].channels;
  3598. break;
  3599. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3600. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3601. mi2s_tx_cfg[SEC_MI2S].bit_format);
  3602. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  3603. channels->min = channels->max =
  3604. mi2s_tx_cfg[SEC_MI2S].channels;
  3605. break;
  3606. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3607. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3608. mi2s_rx_cfg[TERT_MI2S].bit_format);
  3609. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  3610. channels->min = channels->max =
  3611. mi2s_rx_cfg[TERT_MI2S].channels;
  3612. break;
  3613. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3614. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3615. mi2s_tx_cfg[TERT_MI2S].bit_format);
  3616. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  3617. channels->min = channels->max =
  3618. mi2s_tx_cfg[TERT_MI2S].channels;
  3619. break;
  3620. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  3621. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3622. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  3623. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  3624. channels->min = channels->max =
  3625. mi2s_rx_cfg[QUAT_MI2S].channels;
  3626. break;
  3627. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  3628. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3629. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  3630. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  3631. channels->min = channels->max =
  3632. mi2s_tx_cfg[QUAT_MI2S].channels;
  3633. break;
  3634. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  3635. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3636. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  3637. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  3638. channels->min = channels->max =
  3639. mi2s_rx_cfg[QUIN_MI2S].channels;
  3640. break;
  3641. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  3642. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3643. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  3644. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  3645. channels->min = channels->max =
  3646. mi2s_tx_cfg[QUIN_MI2S].channels;
  3647. break;
  3648. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  3649. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3650. mi2s_rx_cfg[SEN_MI2S].bit_format);
  3651. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  3652. channels->min = channels->max =
  3653. mi2s_rx_cfg[SEN_MI2S].channels;
  3654. break;
  3655. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  3656. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3657. mi2s_tx_cfg[SEN_MI2S].bit_format);
  3658. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  3659. channels->min = channels->max =
  3660. mi2s_tx_cfg[SEN_MI2S].channels;
  3661. break;
  3662. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3663. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3664. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3665. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3666. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3667. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3668. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3669. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3670. cdc_dma_rx_cfg[idx].bit_format);
  3671. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  3672. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  3673. break;
  3674. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3675. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3676. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3677. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3678. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3679. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3680. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3681. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3682. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3683. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3684. cdc_dma_tx_cfg[idx].bit_format);
  3685. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  3686. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  3687. break;
  3688. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3689. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3690. SNDRV_PCM_FORMAT_S32_LE);
  3691. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  3692. channels->min = channels->max = msm_vi_feed_tx_ch;
  3693. break;
  3694. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  3695. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3696. slim_rx_cfg[SLIM_RX_7].bit_format);
  3697. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  3698. channels->min = channels->max =
  3699. slim_rx_cfg[SLIM_RX_7].channels;
  3700. break;
  3701. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  3702. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  3703. channels->min = channels->max =
  3704. slim_tx_cfg[SLIM_TX_7].channels;
  3705. break;
  3706. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  3707. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  3708. channels->min = channels->max =
  3709. slim_tx_cfg[SLIM_TX_8].channels;
  3710. break;
  3711. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  3712. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3713. afe_loopback_tx_cfg[idx].bit_format);
  3714. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  3715. channels->min = channels->max =
  3716. afe_loopback_tx_cfg[idx].channels;
  3717. break;
  3718. default:
  3719. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3720. break;
  3721. }
  3722. done:
  3723. return rc;
  3724. }
  3725. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  3726. {
  3727. struct snd_soc_card *card = component->card;
  3728. struct msm_asoc_mach_data *pdata =
  3729. snd_soc_card_get_drvdata(card);
  3730. if (!pdata->fsa_handle)
  3731. return false;
  3732. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  3733. }
  3734. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  3735. {
  3736. int value = 0;
  3737. bool ret = false;
  3738. struct snd_soc_card *card;
  3739. struct msm_asoc_mach_data *pdata;
  3740. if (!component) {
  3741. pr_err("%s component is NULL\n", __func__);
  3742. return false;
  3743. }
  3744. card = component->card;
  3745. pdata = snd_soc_card_get_drvdata(card);
  3746. if (!pdata)
  3747. return false;
  3748. if (wcd_mbhc_cfg.enable_usbc_analog)
  3749. return msm_usbc_swap_gnd_mic(component, active);
  3750. /* if usbc is not defined, swap using us_euro_gpio_p */
  3751. if (pdata->us_euro_gpio_p) {
  3752. value = msm_cdc_pinctrl_get_state(
  3753. pdata->us_euro_gpio_p);
  3754. if (value)
  3755. msm_cdc_pinctrl_select_sleep_state(
  3756. pdata->us_euro_gpio_p);
  3757. else
  3758. msm_cdc_pinctrl_select_active_state(
  3759. pdata->us_euro_gpio_p);
  3760. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  3761. __func__, value, !value);
  3762. ret = true;
  3763. }
  3764. return ret;
  3765. }
  3766. static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  3767. struct snd_pcm_hw_params *params)
  3768. {
  3769. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3770. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3771. int ret = 0;
  3772. int slot_width = 32;
  3773. int channels, slots;
  3774. unsigned int slot_mask, rate, clk_freq;
  3775. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  3776. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  3777. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  3778. switch (cpu_dai->id) {
  3779. case AFE_PORT_ID_PRIMARY_TDM_RX:
  3780. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3781. break;
  3782. case AFE_PORT_ID_SECONDARY_TDM_RX:
  3783. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3784. break;
  3785. case AFE_PORT_ID_TERTIARY_TDM_RX:
  3786. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3787. break;
  3788. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  3789. slots = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3790. break;
  3791. case AFE_PORT_ID_QUINARY_TDM_RX:
  3792. slots = tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3793. break;
  3794. case AFE_PORT_ID_SENARY_TDM_RX:
  3795. slots = tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3796. break;
  3797. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3798. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3799. break;
  3800. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3801. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3802. break;
  3803. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3804. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3805. break;
  3806. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  3807. slots = tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3808. break;
  3809. case AFE_PORT_ID_QUINARY_TDM_TX:
  3810. slots = tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3811. break;
  3812. case AFE_PORT_ID_SENARY_TDM_TX:
  3813. slots = tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3814. break;
  3815. default:
  3816. pr_err("%s: dai id 0x%x not supported\n",
  3817. __func__, cpu_dai->id);
  3818. return -EINVAL;
  3819. }
  3820. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3821. /*2 slot config - bits 0 and 1 set for the first two slots */
  3822. slot_mask = 0x0000FFFF >> (16 - slots);
  3823. channels = slots;
  3824. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  3825. __func__, slot_width, slots);
  3826. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  3827. slots, slot_width);
  3828. if (ret < 0) {
  3829. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  3830. __func__, ret);
  3831. goto end;
  3832. }
  3833. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3834. 0, NULL, channels, slot_offset);
  3835. if (ret < 0) {
  3836. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  3837. __func__, ret);
  3838. goto end;
  3839. }
  3840. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  3841. /*2 slot config - bits 0 and 1 set for the first two slots */
  3842. slot_mask = 0x0000FFFF >> (16 - slots);
  3843. channels = slots;
  3844. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  3845. __func__, slot_width, slots);
  3846. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  3847. slots, slot_width);
  3848. if (ret < 0) {
  3849. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  3850. __func__, ret);
  3851. goto end;
  3852. }
  3853. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3854. channels, slot_offset, 0, NULL);
  3855. if (ret < 0) {
  3856. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  3857. __func__, ret);
  3858. goto end;
  3859. }
  3860. } else {
  3861. ret = -EINVAL;
  3862. pr_err("%s: invalid use case, err:%d\n",
  3863. __func__, ret);
  3864. goto end;
  3865. }
  3866. rate = params_rate(params);
  3867. clk_freq = rate * slot_width * slots;
  3868. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  3869. if (ret < 0)
  3870. pr_err("%s: failed to set tdm clk, err:%d\n",
  3871. __func__, ret);
  3872. end:
  3873. return ret;
  3874. }
  3875. static int msm_get_tdm_mode(u32 port_id)
  3876. {
  3877. int tdm_mode;
  3878. switch (port_id) {
  3879. case AFE_PORT_ID_PRIMARY_TDM_RX:
  3880. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3881. tdm_mode = TDM_PRI;
  3882. break;
  3883. case AFE_PORT_ID_SECONDARY_TDM_RX:
  3884. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3885. tdm_mode = TDM_SEC;
  3886. break;
  3887. case AFE_PORT_ID_TERTIARY_TDM_RX:
  3888. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3889. tdm_mode = TDM_TERT;
  3890. break;
  3891. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  3892. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  3893. tdm_mode = TDM_QUAT;
  3894. break;
  3895. case AFE_PORT_ID_QUINARY_TDM_RX:
  3896. case AFE_PORT_ID_QUINARY_TDM_TX:
  3897. tdm_mode = TDM_QUIN;
  3898. break;
  3899. case AFE_PORT_ID_SENARY_TDM_RX:
  3900. case AFE_PORT_ID_SENARY_TDM_TX:
  3901. tdm_mode = TDM_SEN;
  3902. break;
  3903. default:
  3904. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  3905. tdm_mode = -EINVAL;
  3906. }
  3907. return tdm_mode;
  3908. }
  3909. static int kona_tdm_snd_startup(struct snd_pcm_substream *substream)
  3910. {
  3911. int ret = 0;
  3912. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3913. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3914. struct snd_soc_card *card = rtd->card;
  3915. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3916. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  3917. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  3918. ret = -EINVAL;
  3919. pr_err("%s: Invalid TDM interface %d\n",
  3920. __func__, ret);
  3921. return ret;
  3922. }
  3923. if (pdata->mi2s_gpio_p[tdm_mode]) {
  3924. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  3925. == 0) {
  3926. ret = msm_cdc_pinctrl_select_active_state(
  3927. pdata->mi2s_gpio_p[tdm_mode]);
  3928. if (ret) {
  3929. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  3930. __func__, ret);
  3931. goto done;
  3932. }
  3933. }
  3934. atomic_inc(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  3935. }
  3936. done:
  3937. return ret;
  3938. }
  3939. static void kona_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  3940. {
  3941. int ret = 0;
  3942. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3943. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3944. struct snd_soc_card *card = rtd->card;
  3945. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3946. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  3947. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  3948. ret = -EINVAL;
  3949. pr_err("%s: Invalid TDM interface %d\n",
  3950. __func__, ret);
  3951. return;
  3952. }
  3953. if (pdata->mi2s_gpio_p[tdm_mode]) {
  3954. atomic_dec(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  3955. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  3956. == 0) {
  3957. ret = msm_cdc_pinctrl_select_sleep_state(
  3958. pdata->mi2s_gpio_p[tdm_mode]);
  3959. if (ret)
  3960. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  3961. __func__, ret);
  3962. }
  3963. }
  3964. }
  3965. static int kona_aux_snd_startup(struct snd_pcm_substream *substream)
  3966. {
  3967. int ret = 0;
  3968. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3969. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3970. struct snd_soc_card *card = rtd->card;
  3971. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3972. u32 aux_mode = cpu_dai->id - 1;
  3973. if (aux_mode >= AUX_PCM_MAX) {
  3974. ret = -EINVAL;
  3975. pr_err("%s: Invalid AUX interface %d\n",
  3976. __func__, ret);
  3977. return ret;
  3978. }
  3979. if (pdata->mi2s_gpio_p[aux_mode]) {
  3980. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  3981. == 0) {
  3982. ret = msm_cdc_pinctrl_select_active_state(
  3983. pdata->mi2s_gpio_p[aux_mode]);
  3984. if (ret) {
  3985. pr_err("%s: AUX GPIO pinctrl set active failed with %d\n",
  3986. __func__, ret);
  3987. goto done;
  3988. }
  3989. }
  3990. atomic_inc(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  3991. }
  3992. done:
  3993. return ret;
  3994. }
  3995. static void kona_aux_snd_shutdown(struct snd_pcm_substream *substream)
  3996. {
  3997. int ret = 0;
  3998. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3999. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4000. struct snd_soc_card *card = rtd->card;
  4001. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4002. u32 aux_mode = cpu_dai->id - 1;
  4003. if (aux_mode >= AUX_PCM_MAX) {
  4004. pr_err("%s: Invalid AUX interface %d\n",
  4005. __func__, ret);
  4006. return;
  4007. }
  4008. if (pdata->mi2s_gpio_p[aux_mode]) {
  4009. atomic_dec(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4010. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4011. == 0) {
  4012. ret = msm_cdc_pinctrl_select_sleep_state(
  4013. pdata->mi2s_gpio_p[aux_mode]);
  4014. if (ret)
  4015. pr_err("%s: AUX GPIO pinctrl set sleep failed with %d\n",
  4016. __func__, ret);
  4017. }
  4018. }
  4019. }
  4020. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4021. {
  4022. int ret = 0;
  4023. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4024. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4025. switch (dai_link->id) {
  4026. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4027. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4028. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4029. ret = kona_send_island_va_config(dai_link->id);
  4030. if (ret)
  4031. pr_err("%s: send island va cfg failed, err: %d\n",
  4032. __func__, ret);
  4033. break;
  4034. }
  4035. return ret;
  4036. }
  4037. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4038. struct snd_pcm_hw_params *params)
  4039. {
  4040. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4041. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4042. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4043. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4044. int ret = 0;
  4045. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4046. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4047. u32 user_set_tx_ch = 0;
  4048. u32 user_set_rx_ch = 0;
  4049. u32 ch_id;
  4050. ret = snd_soc_dai_get_channel_map(codec_dai,
  4051. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4052. &rx_ch_cdc_dma);
  4053. if (ret < 0) {
  4054. pr_err("%s: failed to get codec chan map, err:%d\n",
  4055. __func__, ret);
  4056. goto err;
  4057. }
  4058. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4059. switch (dai_link->id) {
  4060. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4061. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4062. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4063. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4064. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4065. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4066. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4067. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4068. {
  4069. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4070. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4071. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4072. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4073. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4074. user_set_rx_ch, &rx_ch_cdc_dma);
  4075. if (ret < 0) {
  4076. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4077. __func__, ret);
  4078. goto err;
  4079. }
  4080. }
  4081. break;
  4082. }
  4083. } else {
  4084. switch (dai_link->id) {
  4085. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4086. {
  4087. user_set_tx_ch = msm_vi_feed_tx_ch;
  4088. }
  4089. break;
  4090. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4091. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4092. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4093. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4094. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4095. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4096. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4097. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4098. {
  4099. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4100. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4101. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4102. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4103. }
  4104. break;
  4105. }
  4106. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4107. &tx_ch_cdc_dma, 0, 0);
  4108. if (ret < 0) {
  4109. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4110. __func__, ret);
  4111. goto err;
  4112. }
  4113. }
  4114. err:
  4115. return ret;
  4116. }
  4117. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4118. {
  4119. cpumask_t mask;
  4120. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  4121. pm_qos_remove_request(&substream->latency_pm_qos_req);
  4122. cpumask_clear(&mask);
  4123. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  4124. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  4125. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  4126. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  4127. pm_qos_add_request(&substream->latency_pm_qos_req,
  4128. PM_QOS_CPU_DMA_LATENCY,
  4129. MSM_LL_QOS_VALUE);
  4130. return 0;
  4131. }
  4132. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4133. {
  4134. int ret = 0;
  4135. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4136. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4137. int index = cpu_dai->id;
  4138. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4139. struct snd_soc_card *card = rtd->card;
  4140. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4141. dev_dbg(rtd->card->dev,
  4142. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4143. __func__, substream->name, substream->stream,
  4144. cpu_dai->name, cpu_dai->id);
  4145. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4146. ret = -EINVAL;
  4147. dev_err(rtd->card->dev,
  4148. "%s: CPU DAI id (%d) out of range\n",
  4149. __func__, cpu_dai->id);
  4150. goto err;
  4151. }
  4152. /*
  4153. * Mutex protection in case the same MI2S
  4154. * interface using for both TX and RX so
  4155. * that the same clock won't be enable twice.
  4156. */
  4157. mutex_lock(&mi2s_intf_conf[index].lock);
  4158. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4159. /* Check if msm needs to provide the clock to the interface */
  4160. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4161. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4162. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4163. }
  4164. ret = msm_mi2s_set_sclk(substream, true);
  4165. if (ret < 0) {
  4166. dev_err(rtd->card->dev,
  4167. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4168. __func__, ret);
  4169. goto clean_up;
  4170. }
  4171. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4172. if (ret < 0) {
  4173. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4174. __func__, index, ret);
  4175. goto clk_off;
  4176. }
  4177. if (pdata->mi2s_gpio_p[index]) {
  4178. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4179. == 0) {
  4180. ret = msm_cdc_pinctrl_select_active_state(
  4181. pdata->mi2s_gpio_p[index]);
  4182. if (ret) {
  4183. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4184. __func__, ret);
  4185. goto clk_off;
  4186. }
  4187. }
  4188. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4189. }
  4190. }
  4191. clk_off:
  4192. if (ret < 0)
  4193. msm_mi2s_set_sclk(substream, false);
  4194. clean_up:
  4195. if (ret < 0)
  4196. mi2s_intf_conf[index].ref_cnt--;
  4197. mutex_unlock(&mi2s_intf_conf[index].lock);
  4198. err:
  4199. return ret;
  4200. }
  4201. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4202. {
  4203. int ret = 0;
  4204. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4205. int index = rtd->cpu_dai->id;
  4206. struct snd_soc_card *card = rtd->card;
  4207. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4208. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4209. substream->name, substream->stream);
  4210. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4211. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4212. return;
  4213. }
  4214. mutex_lock(&mi2s_intf_conf[index].lock);
  4215. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4216. if (pdata->mi2s_gpio_p[index]) {
  4217. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4218. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4219. == 0) {
  4220. ret = msm_cdc_pinctrl_select_sleep_state(
  4221. pdata->mi2s_gpio_p[index]);
  4222. if (ret)
  4223. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4224. __func__, ret);
  4225. }
  4226. }
  4227. ret = msm_mi2s_set_sclk(substream, false);
  4228. if (ret < 0)
  4229. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4230. __func__, index, ret);
  4231. }
  4232. mutex_unlock(&mi2s_intf_conf[index].lock);
  4233. }
  4234. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4235. struct snd_pcm_hw_params *params)
  4236. {
  4237. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4238. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4239. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4240. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4241. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4242. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4243. int ret = 0;
  4244. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4245. codec_dai->name, codec_dai->id);
  4246. ret = snd_soc_dai_get_channel_map(codec_dai,
  4247. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4248. if (ret) {
  4249. dev_err(rtd->dev,
  4250. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4251. __func__, ret);
  4252. goto err;
  4253. }
  4254. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4255. __func__, tx_ch_cnt, dai_link->id);
  4256. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4257. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4258. if (ret)
  4259. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4260. __func__, ret);
  4261. err:
  4262. return ret;
  4263. }
  4264. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4265. struct snd_pcm_hw_params *params)
  4266. {
  4267. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4268. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4269. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4270. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4271. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4272. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4273. int ret = 0;
  4274. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4275. codec_dai->name, codec_dai->id);
  4276. ret = snd_soc_dai_get_channel_map(codec_dai,
  4277. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4278. if (ret) {
  4279. dev_err(rtd->dev,
  4280. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4281. __func__, ret);
  4282. goto err;
  4283. }
  4284. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4285. __func__, tx_ch_cnt, dai_link->id);
  4286. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4287. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4288. if (ret)
  4289. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4290. __func__, ret);
  4291. err:
  4292. return ret;
  4293. }
  4294. static struct snd_soc_ops kona_aux_be_ops = {
  4295. .startup = kona_aux_snd_startup,
  4296. .shutdown = kona_aux_snd_shutdown
  4297. };
  4298. static struct snd_soc_ops kona_tdm_be_ops = {
  4299. .hw_params = kona_tdm_snd_hw_params,
  4300. .startup = kona_tdm_snd_startup,
  4301. .shutdown = kona_tdm_snd_shutdown
  4302. };
  4303. static struct snd_soc_ops msm_mi2s_be_ops = {
  4304. .startup = msm_mi2s_snd_startup,
  4305. .shutdown = msm_mi2s_snd_shutdown,
  4306. };
  4307. static struct snd_soc_ops msm_fe_qos_ops = {
  4308. .prepare = msm_fe_qos_prepare,
  4309. };
  4310. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4311. .startup = msm_snd_cdc_dma_startup,
  4312. .hw_params = msm_snd_cdc_dma_hw_params,
  4313. };
  4314. static struct snd_soc_ops msm_wcn_ops = {
  4315. .hw_params = msm_wcn_hw_params,
  4316. };
  4317. static struct snd_soc_ops msm_wcn_ops_lito = {
  4318. .hw_params = msm_wcn_hw_params_lito,
  4319. };
  4320. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4321. struct snd_kcontrol *kcontrol, int event)
  4322. {
  4323. struct msm_asoc_mach_data *pdata = NULL;
  4324. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4325. int ret = 0;
  4326. u32 dmic_idx;
  4327. int *dmic_gpio_cnt;
  4328. struct device_node *dmic_gpio;
  4329. char *wname;
  4330. wname = strpbrk(w->name, "012345");
  4331. if (!wname) {
  4332. dev_err(component->dev, "%s: widget not found\n", __func__);
  4333. return -EINVAL;
  4334. }
  4335. ret = kstrtouint(wname, 10, &dmic_idx);
  4336. if (ret < 0) {
  4337. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4338. __func__);
  4339. return -EINVAL;
  4340. }
  4341. pdata = snd_soc_card_get_drvdata(component->card);
  4342. switch (dmic_idx) {
  4343. case 0:
  4344. case 1:
  4345. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4346. dmic_gpio = pdata->dmic01_gpio_p;
  4347. break;
  4348. case 2:
  4349. case 3:
  4350. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4351. dmic_gpio = pdata->dmic23_gpio_p;
  4352. break;
  4353. case 4:
  4354. case 5:
  4355. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4356. dmic_gpio = pdata->dmic45_gpio_p;
  4357. break;
  4358. default:
  4359. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4360. __func__);
  4361. return -EINVAL;
  4362. }
  4363. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4364. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4365. switch (event) {
  4366. case SND_SOC_DAPM_PRE_PMU:
  4367. (*dmic_gpio_cnt)++;
  4368. if (*dmic_gpio_cnt == 1) {
  4369. ret = msm_cdc_pinctrl_select_active_state(
  4370. dmic_gpio);
  4371. if (ret < 0) {
  4372. pr_err("%s: gpio set cannot be activated %sd",
  4373. __func__, "dmic_gpio");
  4374. return ret;
  4375. }
  4376. }
  4377. break;
  4378. case SND_SOC_DAPM_POST_PMD:
  4379. (*dmic_gpio_cnt)--;
  4380. if (*dmic_gpio_cnt == 0) {
  4381. ret = msm_cdc_pinctrl_select_sleep_state(
  4382. dmic_gpio);
  4383. if (ret < 0) {
  4384. pr_err("%s: gpio set cannot be de-activated %sd",
  4385. __func__, "dmic_gpio");
  4386. return ret;
  4387. }
  4388. }
  4389. break;
  4390. default:
  4391. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  4392. return -EINVAL;
  4393. }
  4394. return 0;
  4395. }
  4396. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  4397. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  4398. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  4399. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  4400. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  4401. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  4402. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  4403. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  4404. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  4405. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  4406. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  4407. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  4408. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  4409. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  4410. };
  4411. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4412. {
  4413. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4414. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  4415. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4416. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4417. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4418. }
  4419. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  4420. {
  4421. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4422. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  4423. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4424. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4425. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4426. }
  4427. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  4428. {
  4429. int ret = -EINVAL;
  4430. struct snd_soc_component *component;
  4431. struct snd_soc_dapm_context *dapm;
  4432. struct snd_card *card;
  4433. struct snd_info_entry *entry;
  4434. struct snd_soc_component *aux_comp;
  4435. struct msm_asoc_mach_data *pdata =
  4436. snd_soc_card_get_drvdata(rtd->card);
  4437. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4438. if (!component) {
  4439. pr_err("%s: could not find component for bolero_codec\n",
  4440. __func__);
  4441. return ret;
  4442. }
  4443. dapm = snd_soc_component_get_dapm(component);
  4444. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  4445. ARRAY_SIZE(msm_int_snd_controls));
  4446. if (ret < 0) {
  4447. pr_err("%s: add_component_controls failed: %d\n",
  4448. __func__, ret);
  4449. return ret;
  4450. }
  4451. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  4452. ARRAY_SIZE(msm_common_snd_controls));
  4453. if (ret < 0) {
  4454. pr_err("%s: add common snd controls failed: %d\n",
  4455. __func__, ret);
  4456. return ret;
  4457. }
  4458. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  4459. ARRAY_SIZE(msm_int_dapm_widgets));
  4460. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4461. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4462. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4463. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4464. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  4465. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  4466. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  4467. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  4468. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  4469. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  4470. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  4471. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  4472. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  4473. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  4474. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  4475. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  4476. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  4477. snd_soc_dapm_sync(dapm);
  4478. /*
  4479. * Send speaker configuration only for WSA8810.
  4480. * Default configuration is for WSA8815.
  4481. */
  4482. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  4483. __func__, rtd->card->num_aux_devs);
  4484. if (rtd->card->num_aux_devs &&
  4485. !list_empty(&rtd->card->component_dev_list)) {
  4486. list_for_each_entry(aux_comp,
  4487. &rtd->card->aux_comp_list,
  4488. card_aux_list) {
  4489. if (aux_comp->name != NULL && (
  4490. !strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4491. !strcmp(aux_comp->name, WSA8810_NAME_2))) {
  4492. wsa_macro_set_spkr_mode(component,
  4493. WSA_MACRO_SPKR_MODE_1);
  4494. wsa_macro_set_spkr_gain_offset(component,
  4495. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  4496. }
  4497. }
  4498. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  4499. sm_port_map);
  4500. }
  4501. card = rtd->card->snd_card;
  4502. if (!pdata->codec_root) {
  4503. entry = snd_info_create_subdir(card->module, "codecs",
  4504. card->proc_root);
  4505. if (!entry) {
  4506. pr_debug("%s: Cannot create codecs module entry\n",
  4507. __func__);
  4508. ret = 0;
  4509. goto err;
  4510. }
  4511. pdata->codec_root = entry;
  4512. }
  4513. bolero_info_create_codec_entry(pdata->codec_root, component);
  4514. bolero_register_wake_irq(component, false);
  4515. codec_reg_done = true;
  4516. return 0;
  4517. err:
  4518. return ret;
  4519. }
  4520. static void *def_wcd_mbhc_cal(void)
  4521. {
  4522. void *wcd_mbhc_cal;
  4523. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  4524. u16 *btn_high;
  4525. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  4526. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  4527. if (!wcd_mbhc_cal)
  4528. return NULL;
  4529. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  4530. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  4531. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  4532. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  4533. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  4534. btn_high[0] = 75;
  4535. btn_high[1] = 150;
  4536. btn_high[2] = 237;
  4537. btn_high[3] = 500;
  4538. btn_high[4] = 500;
  4539. btn_high[5] = 500;
  4540. btn_high[6] = 500;
  4541. btn_high[7] = 500;
  4542. return wcd_mbhc_cal;
  4543. }
  4544. /* Digital audio interface glue - connects codec <---> CPU */
  4545. static struct snd_soc_dai_link msm_common_dai_links[] = {
  4546. /* FrontEnd DAI Links */
  4547. {/* hw:x,0 */
  4548. .name = MSM_DAILINK_NAME(Media1),
  4549. .stream_name = "MultiMedia1",
  4550. .cpu_dai_name = "MultiMedia1",
  4551. .platform_name = "msm-pcm-dsp.0",
  4552. .dynamic = 1,
  4553. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4554. .dpcm_playback = 1,
  4555. .dpcm_capture = 1,
  4556. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4557. SND_SOC_DPCM_TRIGGER_POST},
  4558. .codec_dai_name = "snd-soc-dummy-dai",
  4559. .codec_name = "snd-soc-dummy",
  4560. .ignore_suspend = 1,
  4561. /* this dainlink has playback support */
  4562. .ignore_pmdown_time = 1,
  4563. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  4564. },
  4565. {/* hw:x,1 */
  4566. .name = MSM_DAILINK_NAME(Media2),
  4567. .stream_name = "MultiMedia2",
  4568. .cpu_dai_name = "MultiMedia2",
  4569. .platform_name = "msm-pcm-dsp.0",
  4570. .dynamic = 1,
  4571. .dpcm_playback = 1,
  4572. .dpcm_capture = 1,
  4573. .codec_dai_name = "snd-soc-dummy-dai",
  4574. .codec_name = "snd-soc-dummy",
  4575. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4576. SND_SOC_DPCM_TRIGGER_POST},
  4577. .ignore_suspend = 1,
  4578. /* this dainlink has playback support */
  4579. .ignore_pmdown_time = 1,
  4580. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  4581. },
  4582. {/* hw:x,2 */
  4583. .name = "VoiceMMode1",
  4584. .stream_name = "VoiceMMode1",
  4585. .cpu_dai_name = "VoiceMMode1",
  4586. .platform_name = "msm-pcm-voice",
  4587. .dynamic = 1,
  4588. .dpcm_playback = 1,
  4589. .dpcm_capture = 1,
  4590. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4591. SND_SOC_DPCM_TRIGGER_POST},
  4592. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4593. .ignore_suspend = 1,
  4594. .ignore_pmdown_time = 1,
  4595. .codec_dai_name = "snd-soc-dummy-dai",
  4596. .codec_name = "snd-soc-dummy",
  4597. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  4598. },
  4599. {/* hw:x,3 */
  4600. .name = "MSM VoIP",
  4601. .stream_name = "VoIP",
  4602. .cpu_dai_name = "VoIP",
  4603. .platform_name = "msm-voip-dsp",
  4604. .dynamic = 1,
  4605. .dpcm_playback = 1,
  4606. .dpcm_capture = 1,
  4607. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4608. SND_SOC_DPCM_TRIGGER_POST},
  4609. .codec_dai_name = "snd-soc-dummy-dai",
  4610. .codec_name = "snd-soc-dummy",
  4611. .ignore_suspend = 1,
  4612. /* this dainlink has playback support */
  4613. .ignore_pmdown_time = 1,
  4614. .id = MSM_FRONTEND_DAI_VOIP,
  4615. },
  4616. {/* hw:x,4 */
  4617. .name = MSM_DAILINK_NAME(ULL),
  4618. .stream_name = "MultiMedia3",
  4619. .cpu_dai_name = "MultiMedia3",
  4620. .platform_name = "msm-pcm-dsp.2",
  4621. .dynamic = 1,
  4622. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4623. .dpcm_playback = 1,
  4624. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4625. SND_SOC_DPCM_TRIGGER_POST},
  4626. .codec_dai_name = "snd-soc-dummy-dai",
  4627. .codec_name = "snd-soc-dummy",
  4628. .ignore_suspend = 1,
  4629. /* this dainlink has playback support */
  4630. .ignore_pmdown_time = 1,
  4631. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  4632. },
  4633. {/* hw:x,5 */
  4634. .name = "MSM AFE-PCM RX",
  4635. .stream_name = "AFE-PROXY RX",
  4636. .cpu_dai_name = "msm-dai-q6-dev.241",
  4637. .codec_name = "msm-stub-codec.1",
  4638. .codec_dai_name = "msm-stub-rx",
  4639. .platform_name = "msm-pcm-afe",
  4640. .dpcm_playback = 1,
  4641. .ignore_suspend = 1,
  4642. /* this dainlink has playback support */
  4643. .ignore_pmdown_time = 1,
  4644. },
  4645. {/* hw:x,6 */
  4646. .name = "MSM AFE-PCM TX",
  4647. .stream_name = "AFE-PROXY TX",
  4648. .cpu_dai_name = "msm-dai-q6-dev.240",
  4649. .codec_name = "msm-stub-codec.1",
  4650. .codec_dai_name = "msm-stub-tx",
  4651. .platform_name = "msm-pcm-afe",
  4652. .dpcm_capture = 1,
  4653. .ignore_suspend = 1,
  4654. },
  4655. {/* hw:x,7 */
  4656. .name = MSM_DAILINK_NAME(Compress1),
  4657. .stream_name = "Compress1",
  4658. .cpu_dai_name = "MultiMedia4",
  4659. .platform_name = "msm-compress-dsp",
  4660. .dynamic = 1,
  4661. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  4662. .dpcm_playback = 1,
  4663. .dpcm_capture = 1,
  4664. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4665. SND_SOC_DPCM_TRIGGER_POST},
  4666. .codec_dai_name = "snd-soc-dummy-dai",
  4667. .codec_name = "snd-soc-dummy",
  4668. .ignore_suspend = 1,
  4669. .ignore_pmdown_time = 1,
  4670. /* this dainlink has playback support */
  4671. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  4672. },
  4673. /* Hostless PCM purpose */
  4674. {/* hw:x,8 */
  4675. .name = "AUXPCM Hostless",
  4676. .stream_name = "AUXPCM Hostless",
  4677. .cpu_dai_name = "AUXPCM_HOSTLESS",
  4678. .platform_name = "msm-pcm-hostless",
  4679. .dynamic = 1,
  4680. .dpcm_playback = 1,
  4681. .dpcm_capture = 1,
  4682. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4683. SND_SOC_DPCM_TRIGGER_POST},
  4684. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4685. .ignore_suspend = 1,
  4686. /* this dainlink has playback support */
  4687. .ignore_pmdown_time = 1,
  4688. .codec_dai_name = "snd-soc-dummy-dai",
  4689. .codec_name = "snd-soc-dummy",
  4690. },
  4691. {/* hw:x,9 */
  4692. .name = MSM_DAILINK_NAME(LowLatency),
  4693. .stream_name = "MultiMedia5",
  4694. .cpu_dai_name = "MultiMedia5",
  4695. .platform_name = "msm-pcm-dsp.1",
  4696. .dynamic = 1,
  4697. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4698. .dpcm_playback = 1,
  4699. .dpcm_capture = 1,
  4700. .codec_dai_name = "snd-soc-dummy-dai",
  4701. .codec_name = "snd-soc-dummy",
  4702. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4703. SND_SOC_DPCM_TRIGGER_POST},
  4704. .ignore_suspend = 1,
  4705. /* this dainlink has playback support */
  4706. .ignore_pmdown_time = 1,
  4707. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  4708. .ops = &msm_fe_qos_ops,
  4709. },
  4710. {/* hw:x,10 */
  4711. .name = "Listen 1 Audio Service",
  4712. .stream_name = "Listen 1 Audio Service",
  4713. .cpu_dai_name = "LSM1",
  4714. .platform_name = "msm-lsm-client",
  4715. .dynamic = 1,
  4716. .dpcm_capture = 1,
  4717. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4718. SND_SOC_DPCM_TRIGGER_POST },
  4719. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4720. .ignore_suspend = 1,
  4721. .codec_dai_name = "snd-soc-dummy-dai",
  4722. .codec_name = "snd-soc-dummy",
  4723. .id = MSM_FRONTEND_DAI_LSM1,
  4724. },
  4725. /* Multiple Tunnel instances */
  4726. {/* hw:x,11 */
  4727. .name = MSM_DAILINK_NAME(Compress2),
  4728. .stream_name = "Compress2",
  4729. .cpu_dai_name = "MultiMedia7",
  4730. .platform_name = "msm-compress-dsp",
  4731. .dynamic = 1,
  4732. .dpcm_playback = 1,
  4733. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4734. SND_SOC_DPCM_TRIGGER_POST},
  4735. .codec_dai_name = "snd-soc-dummy-dai",
  4736. .codec_name = "snd-soc-dummy",
  4737. .ignore_suspend = 1,
  4738. .ignore_pmdown_time = 1,
  4739. /* this dainlink has playback support */
  4740. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  4741. },
  4742. {/* hw:x,12 */
  4743. .name = MSM_DAILINK_NAME(MultiMedia10),
  4744. .stream_name = "MultiMedia10",
  4745. .cpu_dai_name = "MultiMedia10",
  4746. .platform_name = "msm-pcm-dsp.1",
  4747. .dynamic = 1,
  4748. .dpcm_playback = 1,
  4749. .dpcm_capture = 1,
  4750. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4751. SND_SOC_DPCM_TRIGGER_POST},
  4752. .codec_dai_name = "snd-soc-dummy-dai",
  4753. .codec_name = "snd-soc-dummy",
  4754. .ignore_suspend = 1,
  4755. .ignore_pmdown_time = 1,
  4756. /* this dainlink has playback support */
  4757. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  4758. },
  4759. {/* hw:x,13 */
  4760. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  4761. .stream_name = "MM_NOIRQ",
  4762. .cpu_dai_name = "MultiMedia8",
  4763. .platform_name = "msm-pcm-dsp-noirq",
  4764. .dynamic = 1,
  4765. .dpcm_playback = 1,
  4766. .dpcm_capture = 1,
  4767. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4768. SND_SOC_DPCM_TRIGGER_POST},
  4769. .codec_dai_name = "snd-soc-dummy-dai",
  4770. .codec_name = "snd-soc-dummy",
  4771. .ignore_suspend = 1,
  4772. .ignore_pmdown_time = 1,
  4773. /* this dainlink has playback support */
  4774. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  4775. .ops = &msm_fe_qos_ops,
  4776. },
  4777. /* HDMI Hostless */
  4778. {/* hw:x,14 */
  4779. .name = "HDMI_RX_HOSTLESS",
  4780. .stream_name = "HDMI_RX_HOSTLESS",
  4781. .cpu_dai_name = "HDMI_HOSTLESS",
  4782. .platform_name = "msm-pcm-hostless",
  4783. .dynamic = 1,
  4784. .dpcm_playback = 1,
  4785. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4786. SND_SOC_DPCM_TRIGGER_POST},
  4787. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4788. .ignore_suspend = 1,
  4789. .ignore_pmdown_time = 1,
  4790. .codec_dai_name = "snd-soc-dummy-dai",
  4791. .codec_name = "snd-soc-dummy",
  4792. },
  4793. {/* hw:x,15 */
  4794. .name = "VoiceMMode2",
  4795. .stream_name = "VoiceMMode2",
  4796. .cpu_dai_name = "VoiceMMode2",
  4797. .platform_name = "msm-pcm-voice",
  4798. .dynamic = 1,
  4799. .dpcm_playback = 1,
  4800. .dpcm_capture = 1,
  4801. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4802. SND_SOC_DPCM_TRIGGER_POST},
  4803. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4804. .ignore_suspend = 1,
  4805. .ignore_pmdown_time = 1,
  4806. .codec_dai_name = "snd-soc-dummy-dai",
  4807. .codec_name = "snd-soc-dummy",
  4808. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  4809. },
  4810. /* LSM FE */
  4811. {/* hw:x,16 */
  4812. .name = "Listen 2 Audio Service",
  4813. .stream_name = "Listen 2 Audio Service",
  4814. .cpu_dai_name = "LSM2",
  4815. .platform_name = "msm-lsm-client",
  4816. .dynamic = 1,
  4817. .dpcm_capture = 1,
  4818. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4819. SND_SOC_DPCM_TRIGGER_POST },
  4820. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4821. .ignore_suspend = 1,
  4822. .codec_dai_name = "snd-soc-dummy-dai",
  4823. .codec_name = "snd-soc-dummy",
  4824. .id = MSM_FRONTEND_DAI_LSM2,
  4825. },
  4826. {/* hw:x,17 */
  4827. .name = "Listen 3 Audio Service",
  4828. .stream_name = "Listen 3 Audio Service",
  4829. .cpu_dai_name = "LSM3",
  4830. .platform_name = "msm-lsm-client",
  4831. .dynamic = 1,
  4832. .dpcm_capture = 1,
  4833. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4834. SND_SOC_DPCM_TRIGGER_POST },
  4835. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4836. .ignore_suspend = 1,
  4837. .codec_dai_name = "snd-soc-dummy-dai",
  4838. .codec_name = "snd-soc-dummy",
  4839. .id = MSM_FRONTEND_DAI_LSM3,
  4840. },
  4841. {/* hw:x,18 */
  4842. .name = "Listen 4 Audio Service",
  4843. .stream_name = "Listen 4 Audio Service",
  4844. .cpu_dai_name = "LSM4",
  4845. .platform_name = "msm-lsm-client",
  4846. .dynamic = 1,
  4847. .dpcm_capture = 1,
  4848. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4849. SND_SOC_DPCM_TRIGGER_POST },
  4850. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4851. .ignore_suspend = 1,
  4852. .codec_dai_name = "snd-soc-dummy-dai",
  4853. .codec_name = "snd-soc-dummy",
  4854. .id = MSM_FRONTEND_DAI_LSM4,
  4855. },
  4856. {/* hw:x,19 */
  4857. .name = "Listen 5 Audio Service",
  4858. .stream_name = "Listen 5 Audio Service",
  4859. .cpu_dai_name = "LSM5",
  4860. .platform_name = "msm-lsm-client",
  4861. .dynamic = 1,
  4862. .dpcm_capture = 1,
  4863. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4864. SND_SOC_DPCM_TRIGGER_POST },
  4865. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4866. .ignore_suspend = 1,
  4867. .codec_dai_name = "snd-soc-dummy-dai",
  4868. .codec_name = "snd-soc-dummy",
  4869. .id = MSM_FRONTEND_DAI_LSM5,
  4870. },
  4871. {/* hw:x,20 */
  4872. .name = "Listen 6 Audio Service",
  4873. .stream_name = "Listen 6 Audio Service",
  4874. .cpu_dai_name = "LSM6",
  4875. .platform_name = "msm-lsm-client",
  4876. .dynamic = 1,
  4877. .dpcm_capture = 1,
  4878. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4879. SND_SOC_DPCM_TRIGGER_POST },
  4880. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4881. .ignore_suspend = 1,
  4882. .codec_dai_name = "snd-soc-dummy-dai",
  4883. .codec_name = "snd-soc-dummy",
  4884. .id = MSM_FRONTEND_DAI_LSM6,
  4885. },
  4886. {/* hw:x,21 */
  4887. .name = "Listen 7 Audio Service",
  4888. .stream_name = "Listen 7 Audio Service",
  4889. .cpu_dai_name = "LSM7",
  4890. .platform_name = "msm-lsm-client",
  4891. .dynamic = 1,
  4892. .dpcm_capture = 1,
  4893. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4894. SND_SOC_DPCM_TRIGGER_POST },
  4895. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4896. .ignore_suspend = 1,
  4897. .codec_dai_name = "snd-soc-dummy-dai",
  4898. .codec_name = "snd-soc-dummy",
  4899. .id = MSM_FRONTEND_DAI_LSM7,
  4900. },
  4901. {/* hw:x,22 */
  4902. .name = "Listen 8 Audio Service",
  4903. .stream_name = "Listen 8 Audio Service",
  4904. .cpu_dai_name = "LSM8",
  4905. .platform_name = "msm-lsm-client",
  4906. .dynamic = 1,
  4907. .dpcm_capture = 1,
  4908. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4909. SND_SOC_DPCM_TRIGGER_POST },
  4910. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4911. .ignore_suspend = 1,
  4912. .codec_dai_name = "snd-soc-dummy-dai",
  4913. .codec_name = "snd-soc-dummy",
  4914. .id = MSM_FRONTEND_DAI_LSM8,
  4915. },
  4916. {/* hw:x,23 */
  4917. .name = MSM_DAILINK_NAME(Media9),
  4918. .stream_name = "MultiMedia9",
  4919. .cpu_dai_name = "MultiMedia9",
  4920. .platform_name = "msm-pcm-dsp.0",
  4921. .dynamic = 1,
  4922. .dpcm_playback = 1,
  4923. .dpcm_capture = 1,
  4924. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4925. SND_SOC_DPCM_TRIGGER_POST},
  4926. .codec_dai_name = "snd-soc-dummy-dai",
  4927. .codec_name = "snd-soc-dummy",
  4928. .ignore_suspend = 1,
  4929. /* this dainlink has playback support */
  4930. .ignore_pmdown_time = 1,
  4931. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  4932. },
  4933. {/* hw:x,24 */
  4934. .name = MSM_DAILINK_NAME(Compress4),
  4935. .stream_name = "Compress4",
  4936. .cpu_dai_name = "MultiMedia11",
  4937. .platform_name = "msm-compress-dsp",
  4938. .dynamic = 1,
  4939. .dpcm_playback = 1,
  4940. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4941. SND_SOC_DPCM_TRIGGER_POST},
  4942. .codec_dai_name = "snd-soc-dummy-dai",
  4943. .codec_name = "snd-soc-dummy",
  4944. .ignore_suspend = 1,
  4945. .ignore_pmdown_time = 1,
  4946. /* this dainlink has playback support */
  4947. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  4948. },
  4949. {/* hw:x,25 */
  4950. .name = MSM_DAILINK_NAME(Compress5),
  4951. .stream_name = "Compress5",
  4952. .cpu_dai_name = "MultiMedia12",
  4953. .platform_name = "msm-compress-dsp",
  4954. .dynamic = 1,
  4955. .dpcm_playback = 1,
  4956. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4957. SND_SOC_DPCM_TRIGGER_POST},
  4958. .codec_dai_name = "snd-soc-dummy-dai",
  4959. .codec_name = "snd-soc-dummy",
  4960. .ignore_suspend = 1,
  4961. .ignore_pmdown_time = 1,
  4962. /* this dainlink has playback support */
  4963. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  4964. },
  4965. {/* hw:x,26 */
  4966. .name = MSM_DAILINK_NAME(Compress6),
  4967. .stream_name = "Compress6",
  4968. .cpu_dai_name = "MultiMedia13",
  4969. .platform_name = "msm-compress-dsp",
  4970. .dynamic = 1,
  4971. .dpcm_playback = 1,
  4972. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4973. SND_SOC_DPCM_TRIGGER_POST},
  4974. .codec_dai_name = "snd-soc-dummy-dai",
  4975. .codec_name = "snd-soc-dummy",
  4976. .ignore_suspend = 1,
  4977. .ignore_pmdown_time = 1,
  4978. /* this dainlink has playback support */
  4979. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  4980. },
  4981. {/* hw:x,27 */
  4982. .name = MSM_DAILINK_NAME(Compress7),
  4983. .stream_name = "Compress7",
  4984. .cpu_dai_name = "MultiMedia14",
  4985. .platform_name = "msm-compress-dsp",
  4986. .dynamic = 1,
  4987. .dpcm_playback = 1,
  4988. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4989. SND_SOC_DPCM_TRIGGER_POST},
  4990. .codec_dai_name = "snd-soc-dummy-dai",
  4991. .codec_name = "snd-soc-dummy",
  4992. .ignore_suspend = 1,
  4993. .ignore_pmdown_time = 1,
  4994. /* this dainlink has playback support */
  4995. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  4996. },
  4997. {/* hw:x,28 */
  4998. .name = MSM_DAILINK_NAME(Compress8),
  4999. .stream_name = "Compress8",
  5000. .cpu_dai_name = "MultiMedia15",
  5001. .platform_name = "msm-compress-dsp",
  5002. .dynamic = 1,
  5003. .dpcm_playback = 1,
  5004. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5005. SND_SOC_DPCM_TRIGGER_POST},
  5006. .codec_dai_name = "snd-soc-dummy-dai",
  5007. .codec_name = "snd-soc-dummy",
  5008. .ignore_suspend = 1,
  5009. .ignore_pmdown_time = 1,
  5010. /* this dainlink has playback support */
  5011. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5012. },
  5013. {/* hw:x,29 */
  5014. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5015. .stream_name = "MM_NOIRQ_2",
  5016. .cpu_dai_name = "MultiMedia16",
  5017. .platform_name = "msm-pcm-dsp-noirq",
  5018. .dynamic = 1,
  5019. .dpcm_playback = 1,
  5020. .dpcm_capture = 1,
  5021. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5022. SND_SOC_DPCM_TRIGGER_POST},
  5023. .codec_dai_name = "snd-soc-dummy-dai",
  5024. .codec_name = "snd-soc-dummy",
  5025. .ignore_suspend = 1,
  5026. .ignore_pmdown_time = 1,
  5027. /* this dainlink has playback support */
  5028. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5029. .ops = &msm_fe_qos_ops,
  5030. },
  5031. {/* hw:x,30 */
  5032. .name = "CDC_DMA Hostless",
  5033. .stream_name = "CDC_DMA Hostless",
  5034. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  5035. .platform_name = "msm-pcm-hostless",
  5036. .dynamic = 1,
  5037. .dpcm_playback = 1,
  5038. .dpcm_capture = 1,
  5039. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5040. SND_SOC_DPCM_TRIGGER_POST},
  5041. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5042. .ignore_suspend = 1,
  5043. /* this dailink has playback support */
  5044. .ignore_pmdown_time = 1,
  5045. .codec_dai_name = "snd-soc-dummy-dai",
  5046. .codec_name = "snd-soc-dummy",
  5047. },
  5048. {/* hw:x,31 */
  5049. .name = "TX3_CDC_DMA Hostless",
  5050. .stream_name = "TX3_CDC_DMA Hostless",
  5051. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  5052. .platform_name = "msm-pcm-hostless",
  5053. .dynamic = 1,
  5054. .dpcm_capture = 1,
  5055. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5056. SND_SOC_DPCM_TRIGGER_POST},
  5057. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5058. .ignore_suspend = 1,
  5059. .codec_dai_name = "snd-soc-dummy-dai",
  5060. .codec_name = "snd-soc-dummy",
  5061. },
  5062. {/* hw:x,32 */
  5063. .name = "Tertiary MI2S TX_Hostless",
  5064. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5065. .cpu_dai_name = "TERT_MI2S_TX_HOSTLESS",
  5066. .platform_name = "msm-pcm-hostless",
  5067. .dynamic = 1,
  5068. .dpcm_capture = 1,
  5069. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5070. SND_SOC_DPCM_TRIGGER_POST},
  5071. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5072. .ignore_suspend = 1,
  5073. .ignore_pmdown_time = 1,
  5074. .codec_dai_name = "snd-soc-dummy-dai",
  5075. .codec_name = "snd-soc-dummy",
  5076. },
  5077. };
  5078. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5079. {/* hw:x,33 */
  5080. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5081. .stream_name = "WSA CDC DMA0 Capture",
  5082. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  5083. .platform_name = "msm-pcm-hostless",
  5084. .codec_name = "bolero_codec",
  5085. .codec_dai_name = "wsa_macro_vifeedback",
  5086. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5087. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5088. .ignore_suspend = 1,
  5089. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5090. .ops = &msm_cdc_dma_be_ops,
  5091. },
  5092. };
  5093. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5094. {/* hw:x,34 */
  5095. .name = MSM_DAILINK_NAME(ASM Loopback),
  5096. .stream_name = "MultiMedia6",
  5097. .cpu_dai_name = "MultiMedia6",
  5098. .platform_name = "msm-pcm-loopback",
  5099. .dynamic = 1,
  5100. .dpcm_playback = 1,
  5101. .dpcm_capture = 1,
  5102. .codec_dai_name = "snd-soc-dummy-dai",
  5103. .codec_name = "snd-soc-dummy",
  5104. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5105. SND_SOC_DPCM_TRIGGER_POST},
  5106. .ignore_suspend = 1,
  5107. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5108. .ignore_pmdown_time = 1,
  5109. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5110. },
  5111. {/* hw:x,35 */
  5112. .name = "USB Audio Hostless",
  5113. .stream_name = "USB Audio Hostless",
  5114. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  5115. .platform_name = "msm-pcm-hostless",
  5116. .dynamic = 1,
  5117. .dpcm_playback = 1,
  5118. .dpcm_capture = 1,
  5119. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5120. SND_SOC_DPCM_TRIGGER_POST},
  5121. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5122. .ignore_suspend = 1,
  5123. .ignore_pmdown_time = 1,
  5124. .codec_dai_name = "snd-soc-dummy-dai",
  5125. .codec_name = "snd-soc-dummy",
  5126. },
  5127. {/* hw:x,36 */
  5128. .name = "SLIMBUS_7 Hostless",
  5129. .stream_name = "SLIMBUS_7 Hostless",
  5130. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  5131. .platform_name = "msm-pcm-hostless",
  5132. .dynamic = 1,
  5133. .dpcm_capture = 1,
  5134. .dpcm_playback = 1,
  5135. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5136. SND_SOC_DPCM_TRIGGER_POST},
  5137. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5138. .ignore_suspend = 1,
  5139. .ignore_pmdown_time = 1,
  5140. .codec_dai_name = "snd-soc-dummy-dai",
  5141. .codec_name = "snd-soc-dummy",
  5142. },
  5143. {/* hw:x,37 */
  5144. .name = "Compress Capture",
  5145. .stream_name = "Compress9",
  5146. .cpu_dai_name = "MultiMedia17",
  5147. .platform_name = "msm-compress-dsp",
  5148. .dynamic = 1,
  5149. .dpcm_capture = 1,
  5150. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5151. SND_SOC_DPCM_TRIGGER_POST},
  5152. .codec_dai_name = "snd-soc-dummy-dai",
  5153. .codec_name = "snd-soc-dummy",
  5154. .ignore_suspend = 1,
  5155. .ignore_pmdown_time = 1,
  5156. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5157. },
  5158. {/* hw:x,38 */
  5159. .name = "SLIMBUS_8 Hostless",
  5160. .stream_name = "SLIMBUS_8 Hostless",
  5161. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  5162. .platform_name = "msm-pcm-hostless",
  5163. .dynamic = 1,
  5164. .dpcm_capture = 1,
  5165. .dpcm_playback = 1,
  5166. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5167. SND_SOC_DPCM_TRIGGER_POST},
  5168. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5169. .ignore_suspend = 1,
  5170. .ignore_pmdown_time = 1,
  5171. .codec_dai_name = "snd-soc-dummy-dai",
  5172. .codec_name = "snd-soc-dummy",
  5173. },
  5174. {/* hw:x,39 */
  5175. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5176. .stream_name = "TX CDC DMA5 Capture",
  5177. .cpu_dai_name = "msm-dai-cdc-dma-dev.45115",
  5178. .platform_name = "msm-pcm-hostless",
  5179. .codec_name = "bolero_codec",
  5180. .codec_dai_name = "tx_macro_tx3",
  5181. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5182. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5183. .ignore_suspend = 1,
  5184. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5185. .ops = &msm_cdc_dma_be_ops,
  5186. },
  5187. };
  5188. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5189. /* Backend AFE DAI Links */
  5190. {
  5191. .name = LPASS_BE_AFE_PCM_RX,
  5192. .stream_name = "AFE Playback",
  5193. .cpu_dai_name = "msm-dai-q6-dev.224",
  5194. .platform_name = "msm-pcm-routing",
  5195. .codec_name = "msm-stub-codec.1",
  5196. .codec_dai_name = "msm-stub-rx",
  5197. .no_pcm = 1,
  5198. .dpcm_playback = 1,
  5199. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5200. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5201. /* this dainlink has playback support */
  5202. .ignore_pmdown_time = 1,
  5203. .ignore_suspend = 1,
  5204. },
  5205. {
  5206. .name = LPASS_BE_AFE_PCM_TX,
  5207. .stream_name = "AFE Capture",
  5208. .cpu_dai_name = "msm-dai-q6-dev.225",
  5209. .platform_name = "msm-pcm-routing",
  5210. .codec_name = "msm-stub-codec.1",
  5211. .codec_dai_name = "msm-stub-tx",
  5212. .no_pcm = 1,
  5213. .dpcm_capture = 1,
  5214. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5215. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5216. .ignore_suspend = 1,
  5217. },
  5218. /* Incall Record Uplink BACK END DAI Link */
  5219. {
  5220. .name = LPASS_BE_INCALL_RECORD_TX,
  5221. .stream_name = "Voice Uplink Capture",
  5222. .cpu_dai_name = "msm-dai-q6-dev.32772",
  5223. .platform_name = "msm-pcm-routing",
  5224. .codec_name = "msm-stub-codec.1",
  5225. .codec_dai_name = "msm-stub-tx",
  5226. .no_pcm = 1,
  5227. .dpcm_capture = 1,
  5228. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5229. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5230. .ignore_suspend = 1,
  5231. },
  5232. /* Incall Record Downlink BACK END DAI Link */
  5233. {
  5234. .name = LPASS_BE_INCALL_RECORD_RX,
  5235. .stream_name = "Voice Downlink Capture",
  5236. .cpu_dai_name = "msm-dai-q6-dev.32771",
  5237. .platform_name = "msm-pcm-routing",
  5238. .codec_name = "msm-stub-codec.1",
  5239. .codec_dai_name = "msm-stub-tx",
  5240. .no_pcm = 1,
  5241. .dpcm_capture = 1,
  5242. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5243. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5244. .ignore_suspend = 1,
  5245. },
  5246. /* Incall Music BACK END DAI Link */
  5247. {
  5248. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5249. .stream_name = "Voice Farend Playback",
  5250. .cpu_dai_name = "msm-dai-q6-dev.32773",
  5251. .platform_name = "msm-pcm-routing",
  5252. .codec_name = "msm-stub-codec.1",
  5253. .codec_dai_name = "msm-stub-rx",
  5254. .no_pcm = 1,
  5255. .dpcm_playback = 1,
  5256. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5257. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5258. .ignore_suspend = 1,
  5259. .ignore_pmdown_time = 1,
  5260. },
  5261. /* Incall Music 2 BACK END DAI Link */
  5262. {
  5263. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5264. .stream_name = "Voice2 Farend Playback",
  5265. .cpu_dai_name = "msm-dai-q6-dev.32770",
  5266. .platform_name = "msm-pcm-routing",
  5267. .codec_name = "msm-stub-codec.1",
  5268. .codec_dai_name = "msm-stub-rx",
  5269. .no_pcm = 1,
  5270. .dpcm_playback = 1,
  5271. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5272. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5273. .ignore_suspend = 1,
  5274. .ignore_pmdown_time = 1,
  5275. },
  5276. {
  5277. .name = LPASS_BE_USB_AUDIO_RX,
  5278. .stream_name = "USB Audio Playback",
  5279. .cpu_dai_name = "msm-dai-q6-dev.28672",
  5280. .platform_name = "msm-pcm-routing",
  5281. .codec_name = "msm-stub-codec.1",
  5282. .codec_dai_name = "msm-stub-rx",
  5283. .dynamic_be = 1,
  5284. .no_pcm = 1,
  5285. .dpcm_playback = 1,
  5286. .id = MSM_BACKEND_DAI_USB_RX,
  5287. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5288. .ignore_pmdown_time = 1,
  5289. .ignore_suspend = 1,
  5290. },
  5291. {
  5292. .name = LPASS_BE_USB_AUDIO_TX,
  5293. .stream_name = "USB Audio Capture",
  5294. .cpu_dai_name = "msm-dai-q6-dev.28673",
  5295. .platform_name = "msm-pcm-routing",
  5296. .codec_name = "msm-stub-codec.1",
  5297. .codec_dai_name = "msm-stub-tx",
  5298. .no_pcm = 1,
  5299. .dpcm_capture = 1,
  5300. .id = MSM_BACKEND_DAI_USB_TX,
  5301. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5302. .ignore_suspend = 1,
  5303. },
  5304. {
  5305. .name = LPASS_BE_PRI_TDM_RX_0,
  5306. .stream_name = "Primary TDM0 Playback",
  5307. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  5308. .platform_name = "msm-pcm-routing",
  5309. .codec_name = "msm-stub-codec.1",
  5310. .codec_dai_name = "msm-stub-rx",
  5311. .no_pcm = 1,
  5312. .dpcm_playback = 1,
  5313. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5314. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5315. .ops = &kona_tdm_be_ops,
  5316. .ignore_suspend = 1,
  5317. .ignore_pmdown_time = 1,
  5318. },
  5319. {
  5320. .name = LPASS_BE_PRI_TDM_TX_0,
  5321. .stream_name = "Primary TDM0 Capture",
  5322. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  5323. .platform_name = "msm-pcm-routing",
  5324. .codec_name = "msm-stub-codec.1",
  5325. .codec_dai_name = "msm-stub-tx",
  5326. .no_pcm = 1,
  5327. .dpcm_capture = 1,
  5328. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5329. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5330. .ops = &kona_tdm_be_ops,
  5331. .ignore_suspend = 1,
  5332. },
  5333. {
  5334. .name = LPASS_BE_SEC_TDM_RX_0,
  5335. .stream_name = "Secondary TDM0 Playback",
  5336. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  5337. .platform_name = "msm-pcm-routing",
  5338. .codec_name = "msm-stub-codec.1",
  5339. .codec_dai_name = "msm-stub-rx",
  5340. .no_pcm = 1,
  5341. .dpcm_playback = 1,
  5342. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5343. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5344. .ops = &kona_tdm_be_ops,
  5345. .ignore_suspend = 1,
  5346. .ignore_pmdown_time = 1,
  5347. },
  5348. {
  5349. .name = LPASS_BE_SEC_TDM_TX_0,
  5350. .stream_name = "Secondary TDM0 Capture",
  5351. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  5352. .platform_name = "msm-pcm-routing",
  5353. .codec_name = "msm-stub-codec.1",
  5354. .codec_dai_name = "msm-stub-tx",
  5355. .no_pcm = 1,
  5356. .dpcm_capture = 1,
  5357. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5358. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5359. .ops = &kona_tdm_be_ops,
  5360. .ignore_suspend = 1,
  5361. },
  5362. {
  5363. .name = LPASS_BE_TERT_TDM_RX_0,
  5364. .stream_name = "Tertiary TDM0 Playback",
  5365. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  5366. .platform_name = "msm-pcm-routing",
  5367. .codec_name = "msm-stub-codec.1",
  5368. .codec_dai_name = "msm-stub-rx",
  5369. .no_pcm = 1,
  5370. .dpcm_playback = 1,
  5371. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5372. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5373. .ops = &kona_tdm_be_ops,
  5374. .ignore_suspend = 1,
  5375. .ignore_pmdown_time = 1,
  5376. },
  5377. {
  5378. .name = LPASS_BE_TERT_TDM_TX_0,
  5379. .stream_name = "Tertiary TDM0 Capture",
  5380. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  5381. .platform_name = "msm-pcm-routing",
  5382. .codec_name = "msm-stub-codec.1",
  5383. .codec_dai_name = "msm-stub-tx",
  5384. .no_pcm = 1,
  5385. .dpcm_capture = 1,
  5386. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5388. .ops = &kona_tdm_be_ops,
  5389. .ignore_suspend = 1,
  5390. },
  5391. {
  5392. .name = LPASS_BE_QUAT_TDM_RX_0,
  5393. .stream_name = "Quaternary TDM0 Playback",
  5394. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  5395. .platform_name = "msm-pcm-routing",
  5396. .codec_name = "msm-stub-codec.1",
  5397. .codec_dai_name = "msm-stub-rx",
  5398. .no_pcm = 1,
  5399. .dpcm_playback = 1,
  5400. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5401. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5402. .ops = &kona_tdm_be_ops,
  5403. .ignore_suspend = 1,
  5404. .ignore_pmdown_time = 1,
  5405. },
  5406. {
  5407. .name = LPASS_BE_QUAT_TDM_TX_0,
  5408. .stream_name = "Quaternary TDM0 Capture",
  5409. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  5410. .platform_name = "msm-pcm-routing",
  5411. .codec_name = "msm-stub-codec.1",
  5412. .codec_dai_name = "msm-stub-tx",
  5413. .no_pcm = 1,
  5414. .dpcm_capture = 1,
  5415. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5416. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5417. .ops = &kona_tdm_be_ops,
  5418. .ignore_suspend = 1,
  5419. },
  5420. {
  5421. .name = LPASS_BE_QUIN_TDM_RX_0,
  5422. .stream_name = "Quinary TDM0 Playback",
  5423. .cpu_dai_name = "msm-dai-q6-tdm.36928",
  5424. .platform_name = "msm-pcm-routing",
  5425. .codec_name = "msm-stub-codec.1",
  5426. .codec_dai_name = "msm-stub-rx",
  5427. .no_pcm = 1,
  5428. .dpcm_playback = 1,
  5429. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5430. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5431. .ops = &kona_tdm_be_ops,
  5432. .ignore_suspend = 1,
  5433. .ignore_pmdown_time = 1,
  5434. },
  5435. {
  5436. .name = LPASS_BE_QUIN_TDM_TX_0,
  5437. .stream_name = "Quinary TDM0 Capture",
  5438. .cpu_dai_name = "msm-dai-q6-tdm.36929",
  5439. .platform_name = "msm-pcm-routing",
  5440. .codec_name = "msm-stub-codec.1",
  5441. .codec_dai_name = "msm-stub-tx",
  5442. .no_pcm = 1,
  5443. .dpcm_capture = 1,
  5444. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5445. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5446. .ops = &kona_tdm_be_ops,
  5447. .ignore_suspend = 1,
  5448. },
  5449. {
  5450. .name = LPASS_BE_SEN_TDM_RX_0,
  5451. .stream_name = "Senary TDM0 Playback",
  5452. .cpu_dai_name = "msm-dai-q6-tdm.36944",
  5453. .platform_name = "msm-pcm-routing",
  5454. .codec_name = "msm-stub-codec.1",
  5455. .codec_dai_name = "msm-stub-rx",
  5456. .no_pcm = 1,
  5457. .dpcm_playback = 1,
  5458. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5459. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5460. .ops = &kona_tdm_be_ops,
  5461. .ignore_suspend = 1,
  5462. .ignore_pmdown_time = 1,
  5463. },
  5464. {
  5465. .name = LPASS_BE_SEN_TDM_TX_0,
  5466. .stream_name = "Senary TDM0 Capture",
  5467. .cpu_dai_name = "msm-dai-q6-tdm.36945",
  5468. .platform_name = "msm-pcm-routing",
  5469. .codec_name = "msm-stub-codec.1",
  5470. .codec_dai_name = "msm-stub-tx",
  5471. .no_pcm = 1,
  5472. .dpcm_capture = 1,
  5473. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5474. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5475. .ops = &kona_tdm_be_ops,
  5476. .ignore_suspend = 1,
  5477. },
  5478. };
  5479. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5480. {
  5481. .name = LPASS_BE_SLIMBUS_7_RX,
  5482. .stream_name = "Slimbus7 Playback",
  5483. .cpu_dai_name = "msm-dai-q6-dev.16398",
  5484. .platform_name = "msm-pcm-routing",
  5485. .codec_name = "btfmslim_slave",
  5486. /* BT codec driver determines capabilities based on
  5487. * dai name, bt codecdai name should always contains
  5488. * supported usecase information
  5489. */
  5490. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  5491. .no_pcm = 1,
  5492. .dpcm_playback = 1,
  5493. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5494. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5495. .init = &msm_wcn_init,
  5496. .ops = &msm_wcn_ops,
  5497. /* dai link has playback support */
  5498. .ignore_pmdown_time = 1,
  5499. .ignore_suspend = 1,
  5500. },
  5501. {
  5502. .name = LPASS_BE_SLIMBUS_7_TX,
  5503. .stream_name = "Slimbus7 Capture",
  5504. .cpu_dai_name = "msm-dai-q6-dev.16399",
  5505. .platform_name = "msm-pcm-routing",
  5506. .codec_name = "btfmslim_slave",
  5507. .codec_dai_name = "btfm_bt_sco_slim_tx",
  5508. .no_pcm = 1,
  5509. .dpcm_capture = 1,
  5510. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5511. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5512. .ops = &msm_wcn_ops,
  5513. .ignore_suspend = 1,
  5514. },
  5515. };
  5516. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5517. {
  5518. .name = LPASS_BE_SLIMBUS_7_RX,
  5519. .stream_name = "Slimbus7 Playback",
  5520. .cpu_dai_name = "msm-dai-q6-dev.16398",
  5521. .platform_name = "msm-pcm-routing",
  5522. .codec_name = "btfmslim_slave",
  5523. /* BT codec driver determines capabilities based on
  5524. * dai name, bt codecdai name should always contains
  5525. * supported usecase information
  5526. */
  5527. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  5528. .no_pcm = 1,
  5529. .dpcm_playback = 1,
  5530. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5531. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5532. .init = &msm_wcn_init_lito,
  5533. .ops = &msm_wcn_ops_lito,
  5534. /* dai link has playback support */
  5535. .ignore_pmdown_time = 1,
  5536. .ignore_suspend = 1,
  5537. },
  5538. {
  5539. .name = LPASS_BE_SLIMBUS_7_TX,
  5540. .stream_name = "Slimbus7 Capture",
  5541. .cpu_dai_name = "msm-dai-q6-dev.16399",
  5542. .platform_name = "msm-pcm-routing",
  5543. .codec_name = "btfmslim_slave",
  5544. .codec_dai_name = "btfm_bt_sco_slim_tx",
  5545. .no_pcm = 1,
  5546. .dpcm_capture = 1,
  5547. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5548. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5549. .ops = &msm_wcn_ops_lito,
  5550. .ignore_suspend = 1,
  5551. },
  5552. {
  5553. .name = LPASS_BE_SLIMBUS_8_TX,
  5554. .stream_name = "Slimbus8 Capture",
  5555. .cpu_dai_name = "msm-dai-q6-dev.16401",
  5556. .platform_name = "msm-pcm-routing",
  5557. .codec_name = "btfmslim_slave",
  5558. .codec_dai_name = "btfm_fm_slim_tx",
  5559. .no_pcm = 1,
  5560. .dpcm_capture = 1,
  5561. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5562. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5563. .ops = &msm_wcn_ops_lito,
  5564. .ignore_suspend = 1,
  5565. },
  5566. };
  5567. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  5568. /* DISP PORT BACK END DAI Link */
  5569. {
  5570. .name = LPASS_BE_DISPLAY_PORT,
  5571. .stream_name = "Display Port Playback",
  5572. .cpu_dai_name = "msm-dai-q6-dp.24608",
  5573. .platform_name = "msm-pcm-routing",
  5574. .codec_name = "msm-ext-disp-audio-codec-rx",
  5575. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  5576. .no_pcm = 1,
  5577. .dpcm_playback = 1,
  5578. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  5579. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5580. .ignore_pmdown_time = 1,
  5581. .ignore_suspend = 1,
  5582. },
  5583. /* DISP PORT 1 BACK END DAI Link */
  5584. {
  5585. .name = LPASS_BE_DISPLAY_PORT1,
  5586. .stream_name = "Display Port1 Playback",
  5587. .cpu_dai_name = "msm-dai-q6-dp.24608",
  5588. .platform_name = "msm-pcm-routing",
  5589. .codec_name = "msm-ext-disp-audio-codec-rx",
  5590. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  5591. .no_pcm = 1,
  5592. .dpcm_playback = 1,
  5593. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  5594. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5595. .ignore_pmdown_time = 1,
  5596. .ignore_suspend = 1,
  5597. },
  5598. };
  5599. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  5600. {
  5601. .name = LPASS_BE_PRI_MI2S_RX,
  5602. .stream_name = "Primary MI2S Playback",
  5603. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  5604. .platform_name = "msm-pcm-routing",
  5605. .codec_name = "msm-stub-codec.1",
  5606. .codec_dai_name = "msm-stub-rx",
  5607. .no_pcm = 1,
  5608. .dpcm_playback = 1,
  5609. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  5610. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5611. .ops = &msm_mi2s_be_ops,
  5612. .ignore_suspend = 1,
  5613. .ignore_pmdown_time = 1,
  5614. },
  5615. {
  5616. .name = LPASS_BE_PRI_MI2S_TX,
  5617. .stream_name = "Primary MI2S Capture",
  5618. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  5619. .platform_name = "msm-pcm-routing",
  5620. .codec_name = "msm-stub-codec.1",
  5621. .codec_dai_name = "msm-stub-tx",
  5622. .no_pcm = 1,
  5623. .dpcm_capture = 1,
  5624. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  5625. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5626. .ops = &msm_mi2s_be_ops,
  5627. .ignore_suspend = 1,
  5628. },
  5629. {
  5630. .name = LPASS_BE_SEC_MI2S_RX,
  5631. .stream_name = "Secondary MI2S Playback",
  5632. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  5633. .platform_name = "msm-pcm-routing",
  5634. .codec_name = "msm-stub-codec.1",
  5635. .codec_dai_name = "msm-stub-rx",
  5636. .no_pcm = 1,
  5637. .dpcm_playback = 1,
  5638. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  5639. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5640. .ops = &msm_mi2s_be_ops,
  5641. .ignore_suspend = 1,
  5642. .ignore_pmdown_time = 1,
  5643. },
  5644. {
  5645. .name = LPASS_BE_SEC_MI2S_TX,
  5646. .stream_name = "Secondary MI2S Capture",
  5647. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  5648. .platform_name = "msm-pcm-routing",
  5649. .codec_name = "msm-stub-codec.1",
  5650. .codec_dai_name = "msm-stub-tx",
  5651. .no_pcm = 1,
  5652. .dpcm_capture = 1,
  5653. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  5654. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5655. .ops = &msm_mi2s_be_ops,
  5656. .ignore_suspend = 1,
  5657. },
  5658. {
  5659. .name = LPASS_BE_TERT_MI2S_RX,
  5660. .stream_name = "Tertiary MI2S Playback",
  5661. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  5662. .platform_name = "msm-pcm-routing",
  5663. .codec_name = "msm-stub-codec.1",
  5664. .codec_dai_name = "msm-stub-rx",
  5665. .no_pcm = 1,
  5666. .dpcm_playback = 1,
  5667. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  5668. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5669. .ops = &msm_mi2s_be_ops,
  5670. .ignore_suspend = 1,
  5671. .ignore_pmdown_time = 1,
  5672. },
  5673. {
  5674. .name = LPASS_BE_TERT_MI2S_TX,
  5675. .stream_name = "Tertiary MI2S Capture",
  5676. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  5677. .platform_name = "msm-pcm-routing",
  5678. .codec_name = "msm-stub-codec.1",
  5679. .codec_dai_name = "msm-stub-tx",
  5680. .no_pcm = 1,
  5681. .dpcm_capture = 1,
  5682. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  5683. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5684. .ops = &msm_mi2s_be_ops,
  5685. .ignore_suspend = 1,
  5686. },
  5687. {
  5688. .name = LPASS_BE_QUAT_MI2S_RX,
  5689. .stream_name = "Quaternary MI2S Playback",
  5690. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  5691. .platform_name = "msm-pcm-routing",
  5692. .codec_name = "msm-stub-codec.1",
  5693. .codec_dai_name = "msm-stub-rx",
  5694. .no_pcm = 1,
  5695. .dpcm_playback = 1,
  5696. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  5697. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5698. .ops = &msm_mi2s_be_ops,
  5699. .ignore_suspend = 1,
  5700. .ignore_pmdown_time = 1,
  5701. },
  5702. {
  5703. .name = LPASS_BE_QUAT_MI2S_TX,
  5704. .stream_name = "Quaternary MI2S Capture",
  5705. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  5706. .platform_name = "msm-pcm-routing",
  5707. .codec_name = "msm-stub-codec.1",
  5708. .codec_dai_name = "msm-stub-tx",
  5709. .no_pcm = 1,
  5710. .dpcm_capture = 1,
  5711. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  5712. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5713. .ops = &msm_mi2s_be_ops,
  5714. .ignore_suspend = 1,
  5715. },
  5716. {
  5717. .name = LPASS_BE_QUIN_MI2S_RX,
  5718. .stream_name = "Quinary MI2S Playback",
  5719. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  5720. .platform_name = "msm-pcm-routing",
  5721. .codec_name = "msm-stub-codec.1",
  5722. .codec_dai_name = "msm-stub-rx",
  5723. .no_pcm = 1,
  5724. .dpcm_playback = 1,
  5725. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  5726. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5727. .ops = &msm_mi2s_be_ops,
  5728. .ignore_suspend = 1,
  5729. .ignore_pmdown_time = 1,
  5730. },
  5731. {
  5732. .name = LPASS_BE_QUIN_MI2S_TX,
  5733. .stream_name = "Quinary MI2S Capture",
  5734. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  5735. .platform_name = "msm-pcm-routing",
  5736. .codec_name = "msm-stub-codec.1",
  5737. .codec_dai_name = "msm-stub-tx",
  5738. .no_pcm = 1,
  5739. .dpcm_capture = 1,
  5740. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  5741. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5742. .ops = &msm_mi2s_be_ops,
  5743. .ignore_suspend = 1,
  5744. },
  5745. {
  5746. .name = LPASS_BE_SENARY_MI2S_RX,
  5747. .stream_name = "Senary MI2S Playback",
  5748. .cpu_dai_name = "msm-dai-q6-mi2s.5",
  5749. .platform_name = "msm-pcm-routing",
  5750. .codec_name = "msm-stub-codec.1",
  5751. .codec_dai_name = "msm-stub-rx",
  5752. .no_pcm = 1,
  5753. .dpcm_playback = 1,
  5754. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  5755. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5756. .ops = &msm_mi2s_be_ops,
  5757. .ignore_suspend = 1,
  5758. .ignore_pmdown_time = 1,
  5759. },
  5760. {
  5761. .name = LPASS_BE_SENARY_MI2S_TX,
  5762. .stream_name = "Senary MI2S Capture",
  5763. .cpu_dai_name = "msm-dai-q6-mi2s.5",
  5764. .platform_name = "msm-pcm-routing",
  5765. .codec_name = "msm-stub-codec.1",
  5766. .codec_dai_name = "msm-stub-tx",
  5767. .no_pcm = 1,
  5768. .dpcm_capture = 1,
  5769. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  5770. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5771. .ops = &msm_mi2s_be_ops,
  5772. .ignore_suspend = 1,
  5773. },
  5774. };
  5775. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  5776. /* Primary AUX PCM Backend DAI Links */
  5777. {
  5778. .name = LPASS_BE_AUXPCM_RX,
  5779. .stream_name = "AUX PCM Playback",
  5780. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5781. .platform_name = "msm-pcm-routing",
  5782. .codec_name = "msm-stub-codec.1",
  5783. .codec_dai_name = "msm-stub-rx",
  5784. .no_pcm = 1,
  5785. .dpcm_playback = 1,
  5786. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  5787. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5788. .ops = &kona_aux_be_ops,
  5789. .ignore_pmdown_time = 1,
  5790. .ignore_suspend = 1,
  5791. },
  5792. {
  5793. .name = LPASS_BE_AUXPCM_TX,
  5794. .stream_name = "AUX PCM Capture",
  5795. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5796. .platform_name = "msm-pcm-routing",
  5797. .codec_name = "msm-stub-codec.1",
  5798. .codec_dai_name = "msm-stub-tx",
  5799. .no_pcm = 1,
  5800. .dpcm_capture = 1,
  5801. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  5802. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5803. .ops = &kona_aux_be_ops,
  5804. .ignore_suspend = 1,
  5805. },
  5806. /* Secondary AUX PCM Backend DAI Links */
  5807. {
  5808. .name = LPASS_BE_SEC_AUXPCM_RX,
  5809. .stream_name = "Sec AUX PCM Playback",
  5810. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  5811. .platform_name = "msm-pcm-routing",
  5812. .codec_name = "msm-stub-codec.1",
  5813. .codec_dai_name = "msm-stub-rx",
  5814. .no_pcm = 1,
  5815. .dpcm_playback = 1,
  5816. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  5817. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5818. .ops = &kona_aux_be_ops,
  5819. .ignore_pmdown_time = 1,
  5820. .ignore_suspend = 1,
  5821. },
  5822. {
  5823. .name = LPASS_BE_SEC_AUXPCM_TX,
  5824. .stream_name = "Sec AUX PCM Capture",
  5825. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  5826. .platform_name = "msm-pcm-routing",
  5827. .codec_name = "msm-stub-codec.1",
  5828. .codec_dai_name = "msm-stub-tx",
  5829. .no_pcm = 1,
  5830. .dpcm_capture = 1,
  5831. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  5832. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5833. .ops = &kona_aux_be_ops,
  5834. .ignore_suspend = 1,
  5835. },
  5836. /* Tertiary AUX PCM Backend DAI Links */
  5837. {
  5838. .name = LPASS_BE_TERT_AUXPCM_RX,
  5839. .stream_name = "Tert AUX PCM Playback",
  5840. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  5841. .platform_name = "msm-pcm-routing",
  5842. .codec_name = "msm-stub-codec.1",
  5843. .codec_dai_name = "msm-stub-rx",
  5844. .no_pcm = 1,
  5845. .dpcm_playback = 1,
  5846. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  5847. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5848. .ops = &kona_aux_be_ops,
  5849. .ignore_suspend = 1,
  5850. },
  5851. {
  5852. .name = LPASS_BE_TERT_AUXPCM_TX,
  5853. .stream_name = "Tert AUX PCM Capture",
  5854. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  5855. .platform_name = "msm-pcm-routing",
  5856. .codec_name = "msm-stub-codec.1",
  5857. .codec_dai_name = "msm-stub-tx",
  5858. .no_pcm = 1,
  5859. .dpcm_capture = 1,
  5860. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  5861. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5862. .ops = &kona_aux_be_ops,
  5863. .ignore_suspend = 1,
  5864. },
  5865. /* Quaternary AUX PCM Backend DAI Links */
  5866. {
  5867. .name = LPASS_BE_QUAT_AUXPCM_RX,
  5868. .stream_name = "Quat AUX PCM Playback",
  5869. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  5870. .platform_name = "msm-pcm-routing",
  5871. .codec_name = "msm-stub-codec.1",
  5872. .codec_dai_name = "msm-stub-rx",
  5873. .no_pcm = 1,
  5874. .dpcm_playback = 1,
  5875. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  5876. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5877. .ops = &kona_aux_be_ops,
  5878. .ignore_suspend = 1,
  5879. },
  5880. {
  5881. .name = LPASS_BE_QUAT_AUXPCM_TX,
  5882. .stream_name = "Quat AUX PCM Capture",
  5883. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  5884. .platform_name = "msm-pcm-routing",
  5885. .codec_name = "msm-stub-codec.1",
  5886. .codec_dai_name = "msm-stub-tx",
  5887. .no_pcm = 1,
  5888. .dpcm_capture = 1,
  5889. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  5890. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5891. .ops = &kona_aux_be_ops,
  5892. .ignore_suspend = 1,
  5893. },
  5894. /* Quinary AUX PCM Backend DAI Links */
  5895. {
  5896. .name = LPASS_BE_QUIN_AUXPCM_RX,
  5897. .stream_name = "Quin AUX PCM Playback",
  5898. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  5899. .platform_name = "msm-pcm-routing",
  5900. .codec_name = "msm-stub-codec.1",
  5901. .codec_dai_name = "msm-stub-rx",
  5902. .no_pcm = 1,
  5903. .dpcm_playback = 1,
  5904. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  5905. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5906. .ops = &kona_aux_be_ops,
  5907. .ignore_suspend = 1,
  5908. },
  5909. {
  5910. .name = LPASS_BE_QUIN_AUXPCM_TX,
  5911. .stream_name = "Quin AUX PCM Capture",
  5912. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  5913. .platform_name = "msm-pcm-routing",
  5914. .codec_name = "msm-stub-codec.1",
  5915. .codec_dai_name = "msm-stub-tx",
  5916. .no_pcm = 1,
  5917. .dpcm_capture = 1,
  5918. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  5919. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5920. .ops = &kona_aux_be_ops,
  5921. .ignore_suspend = 1,
  5922. },
  5923. /* Senary AUX PCM Backend DAI Links */
  5924. {
  5925. .name = LPASS_BE_SEN_AUXPCM_RX,
  5926. .stream_name = "Sen AUX PCM Playback",
  5927. .cpu_dai_name = "msm-dai-q6-auxpcm.6",
  5928. .platform_name = "msm-pcm-routing",
  5929. .codec_name = "msm-stub-codec.1",
  5930. .codec_dai_name = "msm-stub-rx",
  5931. .no_pcm = 1,
  5932. .dpcm_playback = 1,
  5933. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  5934. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5935. .ops = &kona_aux_be_ops,
  5936. .ignore_suspend = 1,
  5937. },
  5938. {
  5939. .name = LPASS_BE_SEN_AUXPCM_TX,
  5940. .stream_name = "Sen AUX PCM Capture",
  5941. .cpu_dai_name = "msm-dai-q6-auxpcm.6",
  5942. .platform_name = "msm-pcm-routing",
  5943. .codec_name = "msm-stub-codec.1",
  5944. .codec_dai_name = "msm-stub-tx",
  5945. .no_pcm = 1,
  5946. .dpcm_capture = 1,
  5947. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  5948. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5949. .ops = &kona_aux_be_ops,
  5950. .ignore_suspend = 1,
  5951. },
  5952. };
  5953. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  5954. /* WSA CDC DMA Backend DAI Links */
  5955. {
  5956. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  5957. .stream_name = "WSA CDC DMA0 Playback",
  5958. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  5959. .platform_name = "msm-pcm-routing",
  5960. .codec_name = "bolero_codec",
  5961. .codec_dai_name = "wsa_macro_rx1",
  5962. .no_pcm = 1,
  5963. .dpcm_playback = 1,
  5964. .init = &msm_int_audrx_init,
  5965. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  5966. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5967. .ignore_pmdown_time = 1,
  5968. .ignore_suspend = 1,
  5969. .ops = &msm_cdc_dma_be_ops,
  5970. },
  5971. {
  5972. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  5973. .stream_name = "WSA CDC DMA1 Playback",
  5974. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  5975. .platform_name = "msm-pcm-routing",
  5976. .codec_name = "bolero_codec",
  5977. .codec_dai_name = "wsa_macro_rx_mix",
  5978. .no_pcm = 1,
  5979. .dpcm_playback = 1,
  5980. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  5981. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5982. .ignore_pmdown_time = 1,
  5983. .ignore_suspend = 1,
  5984. .ops = &msm_cdc_dma_be_ops,
  5985. },
  5986. {
  5987. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  5988. .stream_name = "WSA CDC DMA1 Capture",
  5989. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  5990. .platform_name = "msm-pcm-routing",
  5991. .codec_name = "bolero_codec",
  5992. .codec_dai_name = "wsa_macro_echo",
  5993. .no_pcm = 1,
  5994. .dpcm_capture = 1,
  5995. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  5996. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5997. .ignore_suspend = 1,
  5998. .ops = &msm_cdc_dma_be_ops,
  5999. },
  6000. };
  6001. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6002. /* RX CDC DMA Backend DAI Links */
  6003. {
  6004. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6005. .stream_name = "RX CDC DMA0 Playback",
  6006. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  6007. .platform_name = "msm-pcm-routing",
  6008. .codec_name = "bolero_codec",
  6009. .codec_dai_name = "rx_macro_rx1",
  6010. .dynamic_be = 1,
  6011. .no_pcm = 1,
  6012. .dpcm_playback = 1,
  6013. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6014. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6015. .ignore_pmdown_time = 1,
  6016. .ignore_suspend = 1,
  6017. .ops = &msm_cdc_dma_be_ops,
  6018. },
  6019. {
  6020. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6021. .stream_name = "RX CDC DMA1 Playback",
  6022. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  6023. .platform_name = "msm-pcm-routing",
  6024. .codec_name = "bolero_codec",
  6025. .codec_dai_name = "rx_macro_rx2",
  6026. .dynamic_be = 1,
  6027. .no_pcm = 1,
  6028. .dpcm_playback = 1,
  6029. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6030. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6031. .ignore_pmdown_time = 1,
  6032. .ignore_suspend = 1,
  6033. .ops = &msm_cdc_dma_be_ops,
  6034. },
  6035. {
  6036. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6037. .stream_name = "RX CDC DMA2 Playback",
  6038. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  6039. .platform_name = "msm-pcm-routing",
  6040. .codec_name = "bolero_codec",
  6041. .codec_dai_name = "rx_macro_rx3",
  6042. .dynamic_be = 1,
  6043. .no_pcm = 1,
  6044. .dpcm_playback = 1,
  6045. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6046. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6047. .ignore_pmdown_time = 1,
  6048. .ignore_suspend = 1,
  6049. .ops = &msm_cdc_dma_be_ops,
  6050. },
  6051. {
  6052. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6053. .stream_name = "RX CDC DMA3 Playback",
  6054. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  6055. .platform_name = "msm-pcm-routing",
  6056. .codec_name = "bolero_codec",
  6057. .codec_dai_name = "rx_macro_rx4",
  6058. .dynamic_be = 1,
  6059. .no_pcm = 1,
  6060. .dpcm_playback = 1,
  6061. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6062. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6063. .ignore_pmdown_time = 1,
  6064. .ignore_suspend = 1,
  6065. .ops = &msm_cdc_dma_be_ops,
  6066. },
  6067. /* TX CDC DMA Backend DAI Links */
  6068. {
  6069. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6070. .stream_name = "TX CDC DMA3 Capture",
  6071. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  6072. .platform_name = "msm-pcm-routing",
  6073. .codec_name = "bolero_codec",
  6074. .codec_dai_name = "tx_macro_tx1",
  6075. .no_pcm = 1,
  6076. .dpcm_capture = 1,
  6077. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6078. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6079. .ignore_suspend = 1,
  6080. .ops = &msm_cdc_dma_be_ops,
  6081. },
  6082. {
  6083. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6084. .stream_name = "TX CDC DMA4 Capture",
  6085. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  6086. .platform_name = "msm-pcm-routing",
  6087. .codec_name = "bolero_codec",
  6088. .codec_dai_name = "tx_macro_tx2",
  6089. .no_pcm = 1,
  6090. .dpcm_capture = 1,
  6091. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6092. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6093. .ignore_suspend = 1,
  6094. .ops = &msm_cdc_dma_be_ops,
  6095. },
  6096. };
  6097. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6098. {
  6099. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6100. .stream_name = "VA CDC DMA0 Capture",
  6101. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  6102. .platform_name = "msm-pcm-routing",
  6103. .codec_name = "bolero_codec",
  6104. .codec_dai_name = "va_macro_tx1",
  6105. .no_pcm = 1,
  6106. .dpcm_capture = 1,
  6107. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6108. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6109. .ignore_suspend = 1,
  6110. .ops = &msm_cdc_dma_be_ops,
  6111. },
  6112. {
  6113. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6114. .stream_name = "VA CDC DMA1 Capture",
  6115. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  6116. .platform_name = "msm-pcm-routing",
  6117. .codec_name = "bolero_codec",
  6118. .codec_dai_name = "va_macro_tx2",
  6119. .no_pcm = 1,
  6120. .dpcm_capture = 1,
  6121. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6122. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6123. .ignore_suspend = 1,
  6124. .ops = &msm_cdc_dma_be_ops,
  6125. },
  6126. {
  6127. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6128. .stream_name = "VA CDC DMA2 Capture",
  6129. .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
  6130. .platform_name = "msm-pcm-routing",
  6131. .codec_name = "bolero_codec",
  6132. .codec_dai_name = "va_macro_tx3",
  6133. .no_pcm = 1,
  6134. .dpcm_capture = 1,
  6135. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6136. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6137. .ignore_suspend = 1,
  6138. .ops = &msm_cdc_dma_be_ops,
  6139. },
  6140. };
  6141. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6142. {
  6143. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6144. .stream_name = "AFE Loopback Capture",
  6145. .cpu_dai_name = "msm-dai-q6-dev.24577",
  6146. .platform_name = "msm-pcm-routing",
  6147. .codec_name = "msm-stub-codec.1",
  6148. .codec_dai_name = "msm-stub-tx",
  6149. .no_pcm = 1,
  6150. .dpcm_capture = 1,
  6151. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6152. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6153. .ignore_pmdown_time = 1,
  6154. .ignore_suspend = 1,
  6155. },
  6156. };
  6157. static struct snd_soc_dai_link msm_kona_dai_links[
  6158. ARRAY_SIZE(msm_common_dai_links) +
  6159. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6160. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6161. ARRAY_SIZE(msm_common_be_dai_links) +
  6162. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6163. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6164. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6165. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6166. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6167. ARRAY_SIZE(ext_disp_be_dai_link) +
  6168. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6169. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6170. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6171. static int msm_populate_dai_link_component_of_node(
  6172. struct snd_soc_card *card)
  6173. {
  6174. int i, index, ret = 0;
  6175. struct device *cdev = card->dev;
  6176. struct snd_soc_dai_link *dai_link = card->dai_link;
  6177. struct device_node *np;
  6178. if (!cdev) {
  6179. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6180. return -ENODEV;
  6181. }
  6182. for (i = 0; i < card->num_links; i++) {
  6183. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  6184. continue;
  6185. /* populate platform_of_node for snd card dai links */
  6186. if (dai_link[i].platform_name &&
  6187. !dai_link[i].platform_of_node) {
  6188. index = of_property_match_string(cdev->of_node,
  6189. "asoc-platform-names",
  6190. dai_link[i].platform_name);
  6191. if (index < 0) {
  6192. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6193. __func__, dai_link[i].platform_name);
  6194. ret = index;
  6195. goto err;
  6196. }
  6197. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6198. index);
  6199. if (!np) {
  6200. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6201. __func__, dai_link[i].platform_name,
  6202. index);
  6203. ret = -ENODEV;
  6204. goto err;
  6205. }
  6206. dai_link[i].platform_of_node = np;
  6207. dai_link[i].platform_name = NULL;
  6208. }
  6209. /* populate cpu_of_node for snd card dai links */
  6210. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  6211. index = of_property_match_string(cdev->of_node,
  6212. "asoc-cpu-names",
  6213. dai_link[i].cpu_dai_name);
  6214. if (index >= 0) {
  6215. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6216. index);
  6217. if (!np) {
  6218. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6219. __func__,
  6220. dai_link[i].cpu_dai_name);
  6221. ret = -ENODEV;
  6222. goto err;
  6223. }
  6224. dai_link[i].cpu_of_node = np;
  6225. dai_link[i].cpu_dai_name = NULL;
  6226. }
  6227. }
  6228. /* populate codec_of_node for snd card dai links */
  6229. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  6230. index = of_property_match_string(cdev->of_node,
  6231. "asoc-codec-names",
  6232. dai_link[i].codec_name);
  6233. if (index < 0)
  6234. continue;
  6235. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  6236. index);
  6237. if (!np) {
  6238. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6239. __func__, dai_link[i].codec_name);
  6240. ret = -ENODEV;
  6241. goto err;
  6242. }
  6243. dai_link[i].codec_of_node = np;
  6244. dai_link[i].codec_name = NULL;
  6245. }
  6246. }
  6247. err:
  6248. return ret;
  6249. }
  6250. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6251. {
  6252. int ret = -EINVAL;
  6253. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6254. if (!component) {
  6255. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6256. return ret;
  6257. }
  6258. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6259. ARRAY_SIZE(msm_snd_controls));
  6260. if (ret < 0) {
  6261. dev_err(component->dev,
  6262. "%s: add_codec_controls failed, err = %d\n",
  6263. __func__, ret);
  6264. return ret;
  6265. }
  6266. return ret;
  6267. }
  6268. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6269. struct snd_pcm_hw_params *params)
  6270. {
  6271. return 0;
  6272. }
  6273. static struct snd_soc_ops msm_stub_be_ops = {
  6274. .hw_params = msm_snd_stub_hw_params,
  6275. };
  6276. struct snd_soc_card snd_soc_card_stub_msm = {
  6277. .name = "kona-stub-snd-card",
  6278. };
  6279. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6280. /* FrontEnd DAI Links */
  6281. {
  6282. .name = "MSMSTUB Media1",
  6283. .stream_name = "MultiMedia1",
  6284. .cpu_dai_name = "MultiMedia1",
  6285. .platform_name = "msm-pcm-dsp.0",
  6286. .dynamic = 1,
  6287. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6288. .dpcm_playback = 1,
  6289. .dpcm_capture = 1,
  6290. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6291. SND_SOC_DPCM_TRIGGER_POST},
  6292. .codec_dai_name = "snd-soc-dummy-dai",
  6293. .codec_name = "snd-soc-dummy",
  6294. .ignore_suspend = 1,
  6295. /* this dainlink has playback support */
  6296. .ignore_pmdown_time = 1,
  6297. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  6298. },
  6299. };
  6300. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6301. /* Backend DAI Links */
  6302. {
  6303. .name = LPASS_BE_AUXPCM_RX,
  6304. .stream_name = "AUX PCM Playback",
  6305. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  6306. .platform_name = "msm-pcm-routing",
  6307. .codec_name = "msm-stub-codec.1",
  6308. .codec_dai_name = "msm-stub-rx",
  6309. .no_pcm = 1,
  6310. .dpcm_playback = 1,
  6311. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6312. .init = &msm_audrx_stub_init,
  6313. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6314. .ignore_pmdown_time = 1,
  6315. .ignore_suspend = 1,
  6316. .ops = &msm_stub_be_ops,
  6317. },
  6318. {
  6319. .name = LPASS_BE_AUXPCM_TX,
  6320. .stream_name = "AUX PCM Capture",
  6321. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  6322. .platform_name = "msm-pcm-routing",
  6323. .codec_name = "msm-stub-codec.1",
  6324. .codec_dai_name = "msm-stub-tx",
  6325. .no_pcm = 1,
  6326. .dpcm_capture = 1,
  6327. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6328. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6329. .ignore_suspend = 1,
  6330. .ops = &msm_stub_be_ops,
  6331. },
  6332. };
  6333. static struct snd_soc_dai_link msm_stub_dai_links[
  6334. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6335. ARRAY_SIZE(msm_stub_be_dai_links)];
  6336. static const struct of_device_id kona_asoc_machine_of_match[] = {
  6337. { .compatible = "qcom,kona-asoc-snd",
  6338. .data = "codec"},
  6339. { .compatible = "qcom,kona-asoc-snd-stub",
  6340. .data = "stub_codec"},
  6341. {},
  6342. };
  6343. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6344. {
  6345. struct snd_soc_card *card = NULL;
  6346. struct snd_soc_dai_link *dailink = NULL;
  6347. int len_1 = 0;
  6348. int len_2 = 0;
  6349. int total_links = 0;
  6350. int rc = 0;
  6351. u32 mi2s_audio_intf = 0;
  6352. u32 auxpcm_audio_intf = 0;
  6353. u32 val = 0;
  6354. u32 wcn_btfm_intf = 0;
  6355. const struct of_device_id *match;
  6356. match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
  6357. if (!match) {
  6358. dev_err(dev, "%s: No DT match found for sound card\n",
  6359. __func__);
  6360. return NULL;
  6361. }
  6362. if (!strcmp(match->data, "codec")) {
  6363. card = &snd_soc_card_kona_msm;
  6364. memcpy(msm_kona_dai_links + total_links,
  6365. msm_common_dai_links,
  6366. sizeof(msm_common_dai_links));
  6367. total_links += ARRAY_SIZE(msm_common_dai_links);
  6368. memcpy(msm_kona_dai_links + total_links,
  6369. msm_bolero_fe_dai_links,
  6370. sizeof(msm_bolero_fe_dai_links));
  6371. total_links +=
  6372. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6373. memcpy(msm_kona_dai_links + total_links,
  6374. msm_common_misc_fe_dai_links,
  6375. sizeof(msm_common_misc_fe_dai_links));
  6376. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6377. memcpy(msm_kona_dai_links + total_links,
  6378. msm_common_be_dai_links,
  6379. sizeof(msm_common_be_dai_links));
  6380. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6381. memcpy(msm_kona_dai_links + total_links,
  6382. msm_wsa_cdc_dma_be_dai_links,
  6383. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6384. total_links +=
  6385. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6386. memcpy(msm_kona_dai_links + total_links,
  6387. msm_rx_tx_cdc_dma_be_dai_links,
  6388. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6389. total_links +=
  6390. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6391. memcpy(msm_kona_dai_links + total_links,
  6392. msm_va_cdc_dma_be_dai_links,
  6393. sizeof(msm_va_cdc_dma_be_dai_links));
  6394. total_links +=
  6395. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6396. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6397. &mi2s_audio_intf);
  6398. if (rc) {
  6399. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6400. __func__);
  6401. } else {
  6402. if (mi2s_audio_intf) {
  6403. memcpy(msm_kona_dai_links + total_links,
  6404. msm_mi2s_be_dai_links,
  6405. sizeof(msm_mi2s_be_dai_links));
  6406. total_links +=
  6407. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6408. }
  6409. }
  6410. rc = of_property_read_u32(dev->of_node,
  6411. "qcom,auxpcm-audio-intf",
  6412. &auxpcm_audio_intf);
  6413. if (rc) {
  6414. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6415. __func__);
  6416. } else {
  6417. if (auxpcm_audio_intf) {
  6418. memcpy(msm_kona_dai_links + total_links,
  6419. msm_auxpcm_be_dai_links,
  6420. sizeof(msm_auxpcm_be_dai_links));
  6421. total_links +=
  6422. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6423. }
  6424. }
  6425. rc = of_property_read_u32(dev->of_node,
  6426. "qcom,ext-disp-audio-rx", &val);
  6427. if (!rc && val) {
  6428. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6429. __func__);
  6430. memcpy(msm_kona_dai_links + total_links,
  6431. ext_disp_be_dai_link,
  6432. sizeof(ext_disp_be_dai_link));
  6433. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6434. }
  6435. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6436. if (!rc && val) {
  6437. dev_dbg(dev, "%s(): WCN BT support present\n",
  6438. __func__);
  6439. memcpy(msm_kona_dai_links + total_links,
  6440. msm_wcn_be_dai_links,
  6441. sizeof(msm_wcn_be_dai_links));
  6442. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6443. }
  6444. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6445. &val);
  6446. if (!rc && val) {
  6447. memcpy(msm_kona_dai_links + total_links,
  6448. msm_afe_rxtx_lb_be_dai_link,
  6449. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6450. total_links +=
  6451. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6452. }
  6453. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6454. &wcn_btfm_intf);
  6455. if (rc) {
  6456. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6457. __func__);
  6458. } else {
  6459. if (wcn_btfm_intf) {
  6460. memcpy(msm_kona_dai_links + total_links,
  6461. msm_wcn_btfm_be_dai_links,
  6462. sizeof(msm_wcn_btfm_be_dai_links));
  6463. total_links +=
  6464. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6465. }
  6466. }
  6467. dailink = msm_kona_dai_links;
  6468. } else if(!strcmp(match->data, "stub_codec")) {
  6469. card = &snd_soc_card_stub_msm;
  6470. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6471. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6472. memcpy(msm_stub_dai_links,
  6473. msm_stub_fe_dai_links,
  6474. sizeof(msm_stub_fe_dai_links));
  6475. memcpy(msm_stub_dai_links + len_1,
  6476. msm_stub_be_dai_links,
  6477. sizeof(msm_stub_be_dai_links));
  6478. dailink = msm_stub_dai_links;
  6479. total_links = len_2;
  6480. }
  6481. if (card) {
  6482. card->dai_link = dailink;
  6483. card->num_links = total_links;
  6484. }
  6485. return card;
  6486. }
  6487. static int msm_wsa881x_init(struct snd_soc_component *component)
  6488. {
  6489. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6490. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6491. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6492. SPKR_L_BOOST, SPKR_L_VI};
  6493. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6494. SPKR_R_BOOST, SPKR_R_VI};
  6495. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  6496. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6497. struct msm_asoc_mach_data *pdata;
  6498. struct snd_soc_dapm_context *dapm;
  6499. struct snd_card *card;
  6500. struct snd_info_entry *entry;
  6501. int ret = 0;
  6502. if (!component) {
  6503. pr_err("%s component is NULL\n", __func__);
  6504. return -EINVAL;
  6505. }
  6506. card = component->card->snd_card;
  6507. dapm = snd_soc_component_get_dapm(component);
  6508. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  6509. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  6510. __func__, component->name);
  6511. wsa881x_set_channel_map(component, &spkleft_ports[0],
  6512. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  6513. &ch_rate[0], &spkleft_port_types[0]);
  6514. if (dapm->component) {
  6515. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  6516. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  6517. }
  6518. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  6519. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  6520. __func__, component->name);
  6521. wsa881x_set_channel_map(component, &spkright_ports[0],
  6522. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  6523. &ch_rate[0], &spkright_port_types[0]);
  6524. if (dapm->component) {
  6525. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  6526. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  6527. }
  6528. } else {
  6529. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  6530. component->name);
  6531. ret = -EINVAL;
  6532. goto err;
  6533. }
  6534. pdata = snd_soc_card_get_drvdata(component->card);
  6535. if (!pdata->codec_root) {
  6536. entry = snd_info_create_subdir(card->module, "codecs",
  6537. card->proc_root);
  6538. if (!entry) {
  6539. pr_err("%s: Cannot create codecs module entry\n",
  6540. __func__);
  6541. ret = 0;
  6542. goto err;
  6543. }
  6544. pdata->codec_root = entry;
  6545. }
  6546. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  6547. component);
  6548. err:
  6549. return ret;
  6550. }
  6551. static int msm_aux_codec_init(struct snd_soc_component *component)
  6552. {
  6553. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  6554. int ret = 0;
  6555. void *mbhc_calibration;
  6556. struct snd_info_entry *entry;
  6557. struct snd_card *card = component->card->snd_card;
  6558. struct msm_asoc_mach_data *pdata;
  6559. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  6560. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  6561. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  6562. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  6563. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  6564. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  6565. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  6566. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  6567. snd_soc_dapm_sync(dapm);
  6568. pdata = snd_soc_card_get_drvdata(component->card);
  6569. if (!pdata->codec_root) {
  6570. entry = snd_info_create_subdir(card->module, "codecs",
  6571. card->proc_root);
  6572. if (!entry) {
  6573. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  6574. __func__);
  6575. ret = 0;
  6576. goto mbhc_cfg_cal;
  6577. }
  6578. pdata->codec_root = entry;
  6579. }
  6580. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  6581. mbhc_cfg_cal:
  6582. mbhc_calibration = def_wcd_mbhc_cal();
  6583. if (!mbhc_calibration)
  6584. return -ENOMEM;
  6585. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6586. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6587. if (ret) {
  6588. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6589. __func__, ret);
  6590. goto err_hs_detect;
  6591. }
  6592. return 0;
  6593. err_hs_detect:
  6594. kfree(mbhc_calibration);
  6595. return ret;
  6596. }
  6597. static int msm_init_aux_dev(struct platform_device *pdev,
  6598. struct snd_soc_card *card)
  6599. {
  6600. struct device_node *wsa_of_node;
  6601. struct device_node *aux_codec_of_node;
  6602. u32 wsa_max_devs;
  6603. u32 wsa_dev_cnt;
  6604. u32 codec_max_aux_devs = 0;
  6605. u32 codec_aux_dev_cnt = 0;
  6606. int i;
  6607. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  6608. struct aux_codec_dev_info *aux_cdc_dev_info;
  6609. const char *auxdev_name_prefix[1];
  6610. char *dev_name_str = NULL;
  6611. int found = 0;
  6612. int codecs_found = 0;
  6613. int ret = 0;
  6614. /* Get maximum WSA device count for this platform */
  6615. ret = of_property_read_u32(pdev->dev.of_node,
  6616. "qcom,wsa-max-devs", &wsa_max_devs);
  6617. if (ret) {
  6618. dev_info(&pdev->dev,
  6619. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6620. __func__, pdev->dev.of_node->full_name, ret);
  6621. wsa_max_devs = 0;
  6622. goto codec_aux_dev;
  6623. }
  6624. if (wsa_max_devs == 0) {
  6625. dev_warn(&pdev->dev,
  6626. "%s: Max WSA devices is 0 for this target?\n",
  6627. __func__);
  6628. goto codec_aux_dev;
  6629. }
  6630. /* Get count of WSA device phandles for this platform */
  6631. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  6632. "qcom,wsa-devs", NULL);
  6633. if (wsa_dev_cnt == -ENOENT) {
  6634. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  6635. __func__);
  6636. goto err;
  6637. } else if (wsa_dev_cnt <= 0) {
  6638. dev_err(&pdev->dev,
  6639. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  6640. __func__, wsa_dev_cnt);
  6641. ret = -EINVAL;
  6642. goto err;
  6643. }
  6644. /*
  6645. * Expect total phandles count to be NOT less than maximum possible
  6646. * WSA count. However, if it is less, then assign same value to
  6647. * max count as well.
  6648. */
  6649. if (wsa_dev_cnt < wsa_max_devs) {
  6650. dev_dbg(&pdev->dev,
  6651. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  6652. __func__, wsa_max_devs, wsa_dev_cnt);
  6653. wsa_max_devs = wsa_dev_cnt;
  6654. }
  6655. /* Make sure prefix string passed for each WSA device */
  6656. ret = of_property_count_strings(pdev->dev.of_node,
  6657. "qcom,wsa-aux-dev-prefix");
  6658. if (ret != wsa_dev_cnt) {
  6659. dev_err(&pdev->dev,
  6660. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  6661. __func__, wsa_dev_cnt, ret);
  6662. ret = -EINVAL;
  6663. goto err;
  6664. }
  6665. /*
  6666. * Alloc mem to store phandle and index info of WSA device, if already
  6667. * registered with ALSA core
  6668. */
  6669. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  6670. sizeof(struct msm_wsa881x_dev_info),
  6671. GFP_KERNEL);
  6672. if (!wsa881x_dev_info) {
  6673. ret = -ENOMEM;
  6674. goto err;
  6675. }
  6676. /*
  6677. * search and check whether all WSA devices are already
  6678. * registered with ALSA core or not. If found a node, store
  6679. * the node and the index in a local array of struct for later
  6680. * use.
  6681. */
  6682. for (i = 0; i < wsa_dev_cnt; i++) {
  6683. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  6684. "qcom,wsa-devs", i);
  6685. if (unlikely(!wsa_of_node)) {
  6686. /* we should not be here */
  6687. dev_err(&pdev->dev,
  6688. "%s: wsa dev node is not present\n",
  6689. __func__);
  6690. ret = -EINVAL;
  6691. goto err;
  6692. }
  6693. if (soc_find_component(wsa_of_node, NULL)) {
  6694. /* WSA device registered with ALSA core */
  6695. wsa881x_dev_info[found].of_node = wsa_of_node;
  6696. wsa881x_dev_info[found].index = i;
  6697. found++;
  6698. if (found == wsa_max_devs)
  6699. break;
  6700. }
  6701. }
  6702. if (found < wsa_max_devs) {
  6703. dev_dbg(&pdev->dev,
  6704. "%s: failed to find %d components. Found only %d\n",
  6705. __func__, wsa_max_devs, found);
  6706. return -EPROBE_DEFER;
  6707. }
  6708. dev_info(&pdev->dev,
  6709. "%s: found %d wsa881x devices registered with ALSA core\n",
  6710. __func__, found);
  6711. codec_aux_dev:
  6712. /* Get maximum aux codec device count for this platform */
  6713. ret = of_property_read_u32(pdev->dev.of_node,
  6714. "qcom,codec-max-aux-devs",
  6715. &codec_max_aux_devs);
  6716. if (ret) {
  6717. dev_err(&pdev->dev,
  6718. "%s: codec-max-aux-devs property missing in DT %s, ret = %d\n",
  6719. __func__, pdev->dev.of_node->full_name, ret);
  6720. codec_max_aux_devs = 0;
  6721. goto aux_dev_register;
  6722. }
  6723. if (codec_max_aux_devs == 0) {
  6724. dev_dbg(&pdev->dev,
  6725. "%s: Max aux codec devices is 0 for this target?\n",
  6726. __func__);
  6727. goto aux_dev_register;
  6728. }
  6729. /* Get count of aux codec device phandles for this platform */
  6730. codec_aux_dev_cnt = of_count_phandle_with_args(
  6731. pdev->dev.of_node,
  6732. "qcom,codec-aux-devs", NULL);
  6733. if (codec_aux_dev_cnt == -ENOENT) {
  6734. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  6735. __func__);
  6736. goto err;
  6737. } else if (codec_aux_dev_cnt <= 0) {
  6738. dev_err(&pdev->dev,
  6739. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  6740. __func__, codec_aux_dev_cnt);
  6741. ret = -EINVAL;
  6742. goto err;
  6743. }
  6744. /*
  6745. * Expect total phandles count to be NOT less than maximum possible
  6746. * AUX device count. However, if it is less, then assign same value to
  6747. * max count as well.
  6748. */
  6749. if (codec_aux_dev_cnt < codec_max_aux_devs) {
  6750. dev_dbg(&pdev->dev,
  6751. "%s: codec_max_aux_devs = %d cannot exceed codec_aux_dev_cnt = %d\n",
  6752. __func__, codec_max_aux_devs,
  6753. codec_aux_dev_cnt);
  6754. codec_max_aux_devs = codec_aux_dev_cnt;
  6755. }
  6756. /*
  6757. * Alloc mem to store phandle and index info of aux codec
  6758. * if already registered with ALSA core
  6759. */
  6760. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
  6761. sizeof(struct aux_codec_dev_info),
  6762. GFP_KERNEL);
  6763. if (!aux_cdc_dev_info) {
  6764. ret = -ENOMEM;
  6765. goto err;
  6766. }
  6767. /*
  6768. * search and check whether all aux codecs are already
  6769. * registered with ALSA core or not. If found a node, store
  6770. * the node and the index in a local array of struct for later
  6771. * use.
  6772. */
  6773. for (i = 0; i < codec_aux_dev_cnt; i++) {
  6774. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  6775. "qcom,codec-aux-devs", i);
  6776. if (unlikely(!aux_codec_of_node)) {
  6777. /* we should not be here */
  6778. dev_err(&pdev->dev,
  6779. "%s: aux codec dev node is not present\n",
  6780. __func__);
  6781. ret = -EINVAL;
  6782. goto err;
  6783. }
  6784. if (soc_find_component(aux_codec_of_node, NULL)) {
  6785. /* AUX codec registered with ALSA core */
  6786. aux_cdc_dev_info[codecs_found].of_node =
  6787. aux_codec_of_node;
  6788. aux_cdc_dev_info[codecs_found].index = i;
  6789. codecs_found++;
  6790. }
  6791. }
  6792. if (codecs_found < codec_aux_dev_cnt) {
  6793. dev_dbg(&pdev->dev,
  6794. "%s: failed to find %d components. Found only %d\n",
  6795. __func__, codec_aux_dev_cnt, codecs_found);
  6796. return -EPROBE_DEFER;
  6797. }
  6798. dev_info(&pdev->dev,
  6799. "%s: found %d AUX codecs registered with ALSA core\n",
  6800. __func__, codecs_found);
  6801. aux_dev_register:
  6802. card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
  6803. card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
  6804. /* Alloc array of AUX devs struct */
  6805. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  6806. sizeof(struct snd_soc_aux_dev),
  6807. GFP_KERNEL);
  6808. if (!msm_aux_dev) {
  6809. ret = -ENOMEM;
  6810. goto err;
  6811. }
  6812. /* Alloc array of codec conf struct */
  6813. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  6814. sizeof(struct snd_soc_codec_conf),
  6815. GFP_KERNEL);
  6816. if (!msm_codec_conf) {
  6817. ret = -ENOMEM;
  6818. goto err;
  6819. }
  6820. for (i = 0; i < wsa_max_devs; i++) {
  6821. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  6822. GFP_KERNEL);
  6823. if (!dev_name_str) {
  6824. ret = -ENOMEM;
  6825. goto err;
  6826. }
  6827. ret = of_property_read_string_index(pdev->dev.of_node,
  6828. "qcom,wsa-aux-dev-prefix",
  6829. wsa881x_dev_info[i].index,
  6830. auxdev_name_prefix);
  6831. if (ret) {
  6832. dev_err(&pdev->dev,
  6833. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  6834. __func__, ret);
  6835. ret = -EINVAL;
  6836. goto err;
  6837. }
  6838. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  6839. msm_aux_dev[i].name = dev_name_str;
  6840. msm_aux_dev[i].codec_name = NULL;
  6841. msm_aux_dev[i].codec_of_node =
  6842. wsa881x_dev_info[i].of_node;
  6843. msm_aux_dev[i].init = msm_wsa881x_init;
  6844. msm_codec_conf[i].dev_name = NULL;
  6845. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  6846. msm_codec_conf[i].of_node =
  6847. wsa881x_dev_info[i].of_node;
  6848. }
  6849. for (i = 0; i < codec_aux_dev_cnt; i++) {
  6850. msm_aux_dev[wsa_max_devs + i].name = NULL;
  6851. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  6852. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  6853. aux_cdc_dev_info[i].of_node;
  6854. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  6855. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  6856. msm_codec_conf[wsa_max_devs + i].name_prefix =
  6857. NULL;
  6858. msm_codec_conf[wsa_max_devs + i].of_node =
  6859. aux_cdc_dev_info[i].of_node;
  6860. }
  6861. card->codec_conf = msm_codec_conf;
  6862. card->aux_dev = msm_aux_dev;
  6863. err:
  6864. return ret;
  6865. }
  6866. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  6867. {
  6868. int count = 0;
  6869. u32 mi2s_master_slave[MI2S_MAX];
  6870. int ret = 0;
  6871. for (count = 0; count < MI2S_MAX; count++) {
  6872. mutex_init(&mi2s_intf_conf[count].lock);
  6873. mi2s_intf_conf[count].ref_cnt = 0;
  6874. }
  6875. ret = of_property_read_u32_array(pdev->dev.of_node,
  6876. "qcom,msm-mi2s-master",
  6877. mi2s_master_slave, MI2S_MAX);
  6878. if (ret) {
  6879. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  6880. __func__);
  6881. } else {
  6882. for (count = 0; count < MI2S_MAX; count++) {
  6883. mi2s_intf_conf[count].msm_is_mi2s_master =
  6884. mi2s_master_slave[count];
  6885. }
  6886. }
  6887. }
  6888. static void msm_i2s_auxpcm_deinit(void)
  6889. {
  6890. int count = 0;
  6891. for (count = 0; count < MI2S_MAX; count++) {
  6892. mutex_destroy(&mi2s_intf_conf[count].lock);
  6893. mi2s_intf_conf[count].ref_cnt = 0;
  6894. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  6895. }
  6896. }
  6897. static int kona_ssr_enable(struct device *dev, void *data)
  6898. {
  6899. struct platform_device *pdev = to_platform_device(dev);
  6900. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6901. int ret = 0;
  6902. if (!card) {
  6903. dev_err(dev, "%s: card is NULL\n", __func__);
  6904. ret = -EINVAL;
  6905. goto err;
  6906. }
  6907. if (!strcmp(card->name, "kona-stub-snd-card")) {
  6908. /* TODO */
  6909. dev_dbg(dev, "%s: TODO \n", __func__);
  6910. }
  6911. snd_soc_card_change_online_state(card, 1);
  6912. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  6913. err:
  6914. return ret;
  6915. }
  6916. static void kona_ssr_disable(struct device *dev, void *data)
  6917. {
  6918. struct platform_device *pdev = to_platform_device(dev);
  6919. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6920. if (!card) {
  6921. dev_err(dev, "%s: card is NULL\n", __func__);
  6922. return;
  6923. }
  6924. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  6925. snd_soc_card_change_online_state(card, 0);
  6926. if (!strcmp(card->name, "kona-stub-snd-card")) {
  6927. /* TODO */
  6928. dev_dbg(dev, "%s: TODO \n", __func__);
  6929. }
  6930. }
  6931. static const struct snd_event_ops kona_ssr_ops = {
  6932. .enable = kona_ssr_enable,
  6933. .disable = kona_ssr_disable,
  6934. };
  6935. static int msm_audio_ssr_compare(struct device *dev, void *data)
  6936. {
  6937. struct device_node *node = data;
  6938. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  6939. __func__, dev->of_node, node);
  6940. return (dev->of_node && dev->of_node == node);
  6941. }
  6942. static int msm_audio_ssr_register(struct device *dev)
  6943. {
  6944. struct device_node *np = dev->of_node;
  6945. struct snd_event_clients *ssr_clients = NULL;
  6946. struct device_node *node = NULL;
  6947. int ret = 0;
  6948. int i = 0;
  6949. for (i = 0; ; i++) {
  6950. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  6951. if (!node)
  6952. break;
  6953. snd_event_mstr_add_client(&ssr_clients,
  6954. msm_audio_ssr_compare, node);
  6955. }
  6956. ret = snd_event_master_register(dev, &kona_ssr_ops,
  6957. ssr_clients, NULL);
  6958. if (!ret)
  6959. snd_event_notify(dev, SND_EVENT_UP);
  6960. return ret;
  6961. }
  6962. static int msm_asoc_machine_probe(struct platform_device *pdev)
  6963. {
  6964. struct snd_soc_card *card = NULL;
  6965. struct msm_asoc_mach_data *pdata = NULL;
  6966. const char *mbhc_audio_jack_type = NULL;
  6967. int ret = 0;
  6968. uint index = 0;
  6969. if (!pdev->dev.of_node) {
  6970. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  6971. return -EINVAL;
  6972. }
  6973. pdata = devm_kzalloc(&pdev->dev,
  6974. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  6975. if (!pdata)
  6976. return -ENOMEM;
  6977. card = populate_snd_card_dailinks(&pdev->dev);
  6978. if (!card) {
  6979. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  6980. ret = -EINVAL;
  6981. goto err;
  6982. }
  6983. card->dev = &pdev->dev;
  6984. platform_set_drvdata(pdev, card);
  6985. snd_soc_card_set_drvdata(card, pdata);
  6986. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  6987. if (ret) {
  6988. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  6989. __func__, ret);
  6990. goto err;
  6991. }
  6992. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  6993. if (ret) {
  6994. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  6995. __func__, ret);
  6996. goto err;
  6997. }
  6998. ret = msm_populate_dai_link_component_of_node(card);
  6999. if (ret) {
  7000. ret = -EPROBE_DEFER;
  7001. goto err;
  7002. }
  7003. ret = msm_init_aux_dev(pdev, card);
  7004. if (ret)
  7005. goto err;
  7006. ret = devm_snd_soc_register_card(&pdev->dev, card);
  7007. if (ret == -EPROBE_DEFER) {
  7008. if (codec_reg_done)
  7009. ret = -EINVAL;
  7010. goto err;
  7011. } else if (ret) {
  7012. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  7013. __func__, ret);
  7014. goto err;
  7015. }
  7016. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  7017. __func__, card->name);
  7018. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7019. "qcom,hph-en1-gpio", 0);
  7020. if (!pdata->hph_en1_gpio_p) {
  7021. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7022. __func__, "qcom,hph-en1-gpio",
  7023. pdev->dev.of_node->full_name);
  7024. }
  7025. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7026. "qcom,hph-en0-gpio", 0);
  7027. if (!pdata->hph_en0_gpio_p) {
  7028. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7029. __func__, "qcom,hph-en0-gpio",
  7030. pdev->dev.of_node->full_name);
  7031. }
  7032. ret = of_property_read_string(pdev->dev.of_node,
  7033. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  7034. if (ret) {
  7035. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  7036. __func__, "qcom,mbhc-audio-jack-type",
  7037. pdev->dev.of_node->full_name);
  7038. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  7039. } else {
  7040. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  7041. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7042. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  7043. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  7044. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7045. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  7046. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  7047. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7048. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  7049. } else {
  7050. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7051. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  7052. }
  7053. }
  7054. /*
  7055. * Parse US-Euro gpio info from DT. Report no error if us-euro
  7056. * entry is not found in DT file as some targets do not support
  7057. * US-Euro detection
  7058. */
  7059. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7060. "qcom,us-euro-gpios", 0);
  7061. if (!pdata->us_euro_gpio_p) {
  7062. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  7063. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  7064. } else {
  7065. dev_dbg(&pdev->dev, "%s detected\n",
  7066. "qcom,us-euro-gpios");
  7067. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  7068. }
  7069. if (wcd_mbhc_cfg.enable_usbc_analog)
  7070. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  7071. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  7072. "fsa4480-i2c-handle", 0);
  7073. if (!pdata->fsa_handle)
  7074. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  7075. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  7076. msm_i2s_auxpcm_init(pdev);
  7077. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7078. "qcom,cdc-dmic01-gpios",
  7079. 0);
  7080. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7081. "qcom,cdc-dmic23-gpios",
  7082. 0);
  7083. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7084. "qcom,cdc-dmic45-gpios",
  7085. 0);
  7086. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7087. "qcom,pri-mi2s-gpios", 0);
  7088. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7089. "qcom,sec-mi2s-gpios", 0);
  7090. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7091. "qcom,tert-mi2s-gpios", 0);
  7092. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7093. "qcom,quat-mi2s-gpios", 0);
  7094. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7095. "qcom,quin-mi2s-gpios", 0);
  7096. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7097. "qcom,sen-mi2s-gpios", 0);
  7098. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  7099. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  7100. ret = msm_audio_ssr_register(&pdev->dev);
  7101. if (ret)
  7102. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  7103. __func__, ret);
  7104. is_initial_boot = true;
  7105. return 0;
  7106. err:
  7107. devm_kfree(&pdev->dev, pdata);
  7108. return ret;
  7109. }
  7110. static int msm_asoc_machine_remove(struct platform_device *pdev)
  7111. {
  7112. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7113. snd_event_master_deregister(&pdev->dev);
  7114. snd_soc_unregister_card(card);
  7115. msm_i2s_auxpcm_deinit();
  7116. return 0;
  7117. }
  7118. static struct platform_driver kona_asoc_machine_driver = {
  7119. .driver = {
  7120. .name = DRV_NAME,
  7121. .owner = THIS_MODULE,
  7122. .pm = &snd_soc_pm_ops,
  7123. .of_match_table = kona_asoc_machine_of_match,
  7124. .suppress_bind_attrs = true,
  7125. },
  7126. .probe = msm_asoc_machine_probe,
  7127. .remove = msm_asoc_machine_remove,
  7128. };
  7129. module_platform_driver(kona_asoc_machine_driver);
  7130. MODULE_DESCRIPTION("ALSA SoC msm");
  7131. MODULE_LICENSE("GPL v2");
  7132. MODULE_ALIAS("platform:" DRV_NAME);
  7133. MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);