kona.c 220 KB

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