kona.c 224 KB

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