lahaina.c 229 KB

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