lahaina.c 225 KB

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