lahaina.c 235 KB

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