bengal.c 184 KB

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