kona.c 224 KB

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