lahaina.c 222 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837
  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. default:
  2416. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  2417. afe_port_id = -EINVAL;
  2418. }
  2419. return afe_port_id;
  2420. }
  2421. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  2422. {
  2423. u32 bit_per_sample = 0;
  2424. switch (bit_format) {
  2425. case SNDRV_PCM_FORMAT_S32_LE:
  2426. case SNDRV_PCM_FORMAT_S24_3LE:
  2427. case SNDRV_PCM_FORMAT_S24_LE:
  2428. bit_per_sample = 32;
  2429. break;
  2430. case SNDRV_PCM_FORMAT_S16_LE:
  2431. default:
  2432. bit_per_sample = 16;
  2433. break;
  2434. }
  2435. return bit_per_sample;
  2436. }
  2437. static void update_mi2s_clk_val(int dai_id, int stream)
  2438. {
  2439. u32 bit_per_sample = 0;
  2440. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2441. bit_per_sample =
  2442. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  2443. mi2s_clk[dai_id].clk_freq_in_hz =
  2444. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2445. } else {
  2446. bit_per_sample =
  2447. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  2448. mi2s_clk[dai_id].clk_freq_in_hz =
  2449. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2450. }
  2451. }
  2452. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  2453. {
  2454. int ret = 0;
  2455. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2456. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2457. int port_id = 0;
  2458. int index = cpu_dai->id;
  2459. port_id = msm_get_port_id(rtd->dai_link->id);
  2460. if (port_id < 0) {
  2461. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  2462. ret = port_id;
  2463. goto err;
  2464. }
  2465. if (enable) {
  2466. update_mi2s_clk_val(index, substream->stream);
  2467. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  2468. mi2s_clk[index].clk_freq_in_hz);
  2469. }
  2470. mi2s_clk[index].enable = enable;
  2471. ret = afe_set_lpass_clock_v2(port_id,
  2472. &mi2s_clk[index]);
  2473. if (ret < 0) {
  2474. dev_err(rtd->card->dev,
  2475. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  2476. __func__, port_id, ret);
  2477. goto err;
  2478. }
  2479. err:
  2480. return ret;
  2481. }
  2482. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  2483. {
  2484. int idx = 0;
  2485. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  2486. sizeof("WSA_CDC_DMA_RX_0")))
  2487. idx = WSA_CDC_DMA_RX_0;
  2488. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2489. sizeof("WSA_CDC_DMA_RX_0")))
  2490. idx = WSA_CDC_DMA_RX_1;
  2491. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2492. sizeof("RX_CDC_DMA_RX_0")))
  2493. idx = RX_CDC_DMA_RX_0;
  2494. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2495. sizeof("RX_CDC_DMA_RX_1")))
  2496. idx = RX_CDC_DMA_RX_1;
  2497. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2498. sizeof("RX_CDC_DMA_RX_2")))
  2499. idx = RX_CDC_DMA_RX_2;
  2500. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2501. sizeof("RX_CDC_DMA_RX_3")))
  2502. idx = RX_CDC_DMA_RX_3;
  2503. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2504. sizeof("RX_CDC_DMA_RX_5")))
  2505. idx = RX_CDC_DMA_RX_5;
  2506. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_6",
  2507. sizeof("RX_CDC_DMA_RX_6")))
  2508. idx = RX_CDC_DMA_RX_6;
  2509. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2510. sizeof("WSA_CDC_DMA_TX_0")))
  2511. idx = WSA_CDC_DMA_TX_0;
  2512. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2513. sizeof("WSA_CDC_DMA_TX_1")))
  2514. idx = WSA_CDC_DMA_TX_1;
  2515. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2516. sizeof("WSA_CDC_DMA_TX_2")))
  2517. idx = WSA_CDC_DMA_TX_2;
  2518. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2519. sizeof("TX_CDC_DMA_TX_0")))
  2520. idx = TX_CDC_DMA_TX_0;
  2521. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2522. sizeof("TX_CDC_DMA_TX_3")))
  2523. idx = TX_CDC_DMA_TX_3;
  2524. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2525. sizeof("TX_CDC_DMA_TX_4")))
  2526. idx = TX_CDC_DMA_TX_4;
  2527. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2528. sizeof("VA_CDC_DMA_TX_0")))
  2529. idx = VA_CDC_DMA_TX_0;
  2530. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2531. sizeof("VA_CDC_DMA_TX_1")))
  2532. idx = VA_CDC_DMA_TX_1;
  2533. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2534. sizeof("VA_CDC_DMA_TX_2")))
  2535. idx = VA_CDC_DMA_TX_2;
  2536. else {
  2537. pr_err("%s: unsupported channel: %s\n",
  2538. __func__, kcontrol->id.name);
  2539. return -EINVAL;
  2540. }
  2541. return idx;
  2542. }
  2543. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2544. struct snd_ctl_elem_value *ucontrol)
  2545. {
  2546. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2547. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2548. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2549. return ch_num;
  2550. }
  2551. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2552. cdc_dma_rx_cfg[ch_num].channels - 1);
  2553. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2554. return 0;
  2555. }
  2556. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2557. struct snd_ctl_elem_value *ucontrol)
  2558. {
  2559. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2560. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2561. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2562. return ch_num;
  2563. }
  2564. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2565. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2566. cdc_dma_rx_cfg[ch_num].channels);
  2567. return 1;
  2568. }
  2569. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2570. struct snd_ctl_elem_value *ucontrol)
  2571. {
  2572. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2573. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2574. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2575. return ch_num;
  2576. }
  2577. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2578. case SNDRV_PCM_FORMAT_S32_LE:
  2579. ucontrol->value.integer.value[0] = 3;
  2580. break;
  2581. case SNDRV_PCM_FORMAT_S24_3LE:
  2582. ucontrol->value.integer.value[0] = 2;
  2583. break;
  2584. case SNDRV_PCM_FORMAT_S24_LE:
  2585. ucontrol->value.integer.value[0] = 1;
  2586. break;
  2587. case SNDRV_PCM_FORMAT_S16_LE:
  2588. default:
  2589. ucontrol->value.integer.value[0] = 0;
  2590. break;
  2591. }
  2592. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2593. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2594. ucontrol->value.integer.value[0]);
  2595. return 0;
  2596. }
  2597. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2598. struct snd_ctl_elem_value *ucontrol)
  2599. {
  2600. int rc = 0;
  2601. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2602. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2603. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2604. return ch_num;
  2605. }
  2606. switch (ucontrol->value.integer.value[0]) {
  2607. case 3:
  2608. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2609. break;
  2610. case 2:
  2611. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2612. break;
  2613. case 1:
  2614. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2615. break;
  2616. case 0:
  2617. default:
  2618. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2619. break;
  2620. }
  2621. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2622. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2623. ucontrol->value.integer.value[0]);
  2624. return rc;
  2625. }
  2626. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2627. {
  2628. int sample_rate_val = 0;
  2629. switch (sample_rate) {
  2630. case SAMPLING_RATE_8KHZ:
  2631. sample_rate_val = 0;
  2632. break;
  2633. case SAMPLING_RATE_11P025KHZ:
  2634. sample_rate_val = 1;
  2635. break;
  2636. case SAMPLING_RATE_16KHZ:
  2637. sample_rate_val = 2;
  2638. break;
  2639. case SAMPLING_RATE_22P05KHZ:
  2640. sample_rate_val = 3;
  2641. break;
  2642. case SAMPLING_RATE_32KHZ:
  2643. sample_rate_val = 4;
  2644. break;
  2645. case SAMPLING_RATE_44P1KHZ:
  2646. sample_rate_val = 5;
  2647. break;
  2648. case SAMPLING_RATE_48KHZ:
  2649. sample_rate_val = 6;
  2650. break;
  2651. case SAMPLING_RATE_88P2KHZ:
  2652. sample_rate_val = 7;
  2653. break;
  2654. case SAMPLING_RATE_96KHZ:
  2655. sample_rate_val = 8;
  2656. break;
  2657. case SAMPLING_RATE_176P4KHZ:
  2658. sample_rate_val = 9;
  2659. break;
  2660. case SAMPLING_RATE_192KHZ:
  2661. sample_rate_val = 10;
  2662. break;
  2663. case SAMPLING_RATE_352P8KHZ:
  2664. sample_rate_val = 11;
  2665. break;
  2666. case SAMPLING_RATE_384KHZ:
  2667. sample_rate_val = 12;
  2668. break;
  2669. default:
  2670. sample_rate_val = 6;
  2671. break;
  2672. }
  2673. return sample_rate_val;
  2674. }
  2675. static int cdc_dma_get_sample_rate(int value)
  2676. {
  2677. int sample_rate = 0;
  2678. switch (value) {
  2679. case 0:
  2680. sample_rate = SAMPLING_RATE_8KHZ;
  2681. break;
  2682. case 1:
  2683. sample_rate = SAMPLING_RATE_11P025KHZ;
  2684. break;
  2685. case 2:
  2686. sample_rate = SAMPLING_RATE_16KHZ;
  2687. break;
  2688. case 3:
  2689. sample_rate = SAMPLING_RATE_22P05KHZ;
  2690. break;
  2691. case 4:
  2692. sample_rate = SAMPLING_RATE_32KHZ;
  2693. break;
  2694. case 5:
  2695. sample_rate = SAMPLING_RATE_44P1KHZ;
  2696. break;
  2697. case 6:
  2698. sample_rate = SAMPLING_RATE_48KHZ;
  2699. break;
  2700. case 7:
  2701. sample_rate = SAMPLING_RATE_88P2KHZ;
  2702. break;
  2703. case 8:
  2704. sample_rate = SAMPLING_RATE_96KHZ;
  2705. break;
  2706. case 9:
  2707. sample_rate = SAMPLING_RATE_176P4KHZ;
  2708. break;
  2709. case 10:
  2710. sample_rate = SAMPLING_RATE_192KHZ;
  2711. break;
  2712. case 11:
  2713. sample_rate = SAMPLING_RATE_352P8KHZ;
  2714. break;
  2715. case 12:
  2716. sample_rate = SAMPLING_RATE_384KHZ;
  2717. break;
  2718. default:
  2719. sample_rate = SAMPLING_RATE_48KHZ;
  2720. break;
  2721. }
  2722. return sample_rate;
  2723. }
  2724. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2725. struct snd_ctl_elem_value *ucontrol)
  2726. {
  2727. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2728. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2729. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2730. return ch_num;
  2731. }
  2732. ucontrol->value.enumerated.item[0] =
  2733. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2734. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2735. cdc_dma_rx_cfg[ch_num].sample_rate);
  2736. return 0;
  2737. }
  2738. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2739. struct snd_ctl_elem_value *ucontrol)
  2740. {
  2741. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2742. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2743. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2744. return ch_num;
  2745. }
  2746. cdc_dma_rx_cfg[ch_num].sample_rate =
  2747. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2748. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2749. __func__, ucontrol->value.enumerated.item[0],
  2750. cdc_dma_rx_cfg[ch_num].sample_rate);
  2751. return 0;
  2752. }
  2753. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2754. struct snd_ctl_elem_value *ucontrol)
  2755. {
  2756. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2757. if (ch_num < 0) {
  2758. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2759. return ch_num;
  2760. }
  2761. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2762. cdc_dma_tx_cfg[ch_num].channels);
  2763. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2764. return 0;
  2765. }
  2766. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2767. struct snd_ctl_elem_value *ucontrol)
  2768. {
  2769. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2770. if (ch_num < 0) {
  2771. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2772. return ch_num;
  2773. }
  2774. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2775. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2776. cdc_dma_tx_cfg[ch_num].channels);
  2777. return 1;
  2778. }
  2779. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2780. struct snd_ctl_elem_value *ucontrol)
  2781. {
  2782. int sample_rate_val;
  2783. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2784. if (ch_num < 0) {
  2785. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2786. return ch_num;
  2787. }
  2788. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2789. case SAMPLING_RATE_384KHZ:
  2790. sample_rate_val = 12;
  2791. break;
  2792. case SAMPLING_RATE_352P8KHZ:
  2793. sample_rate_val = 11;
  2794. break;
  2795. case SAMPLING_RATE_192KHZ:
  2796. sample_rate_val = 10;
  2797. break;
  2798. case SAMPLING_RATE_176P4KHZ:
  2799. sample_rate_val = 9;
  2800. break;
  2801. case SAMPLING_RATE_96KHZ:
  2802. sample_rate_val = 8;
  2803. break;
  2804. case SAMPLING_RATE_88P2KHZ:
  2805. sample_rate_val = 7;
  2806. break;
  2807. case SAMPLING_RATE_48KHZ:
  2808. sample_rate_val = 6;
  2809. break;
  2810. case SAMPLING_RATE_44P1KHZ:
  2811. sample_rate_val = 5;
  2812. break;
  2813. case SAMPLING_RATE_32KHZ:
  2814. sample_rate_val = 4;
  2815. break;
  2816. case SAMPLING_RATE_22P05KHZ:
  2817. sample_rate_val = 3;
  2818. break;
  2819. case SAMPLING_RATE_16KHZ:
  2820. sample_rate_val = 2;
  2821. break;
  2822. case SAMPLING_RATE_11P025KHZ:
  2823. sample_rate_val = 1;
  2824. break;
  2825. case SAMPLING_RATE_8KHZ:
  2826. sample_rate_val = 0;
  2827. break;
  2828. default:
  2829. sample_rate_val = 6;
  2830. break;
  2831. }
  2832. ucontrol->value.integer.value[0] = sample_rate_val;
  2833. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2834. cdc_dma_tx_cfg[ch_num].sample_rate);
  2835. return 0;
  2836. }
  2837. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2838. struct snd_ctl_elem_value *ucontrol)
  2839. {
  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 (ucontrol->value.integer.value[0]) {
  2846. case 12:
  2847. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2848. break;
  2849. case 11:
  2850. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2851. break;
  2852. case 10:
  2853. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2854. break;
  2855. case 9:
  2856. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2857. break;
  2858. case 8:
  2859. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2860. break;
  2861. case 7:
  2862. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2863. break;
  2864. case 6:
  2865. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2866. break;
  2867. case 5:
  2868. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2869. break;
  2870. case 4:
  2871. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2872. break;
  2873. case 3:
  2874. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2875. break;
  2876. case 2:
  2877. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2878. break;
  2879. case 1:
  2880. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2881. break;
  2882. case 0:
  2883. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2884. break;
  2885. default:
  2886. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2887. break;
  2888. }
  2889. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2890. __func__, ucontrol->value.integer.value[0],
  2891. cdc_dma_tx_cfg[ch_num].sample_rate);
  2892. return 0;
  2893. }
  2894. static int cdc_dma_tx_format_get(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 (cdc_dma_tx_cfg[ch_num].bit_format) {
  2903. case SNDRV_PCM_FORMAT_S32_LE:
  2904. ucontrol->value.integer.value[0] = 3;
  2905. break;
  2906. case SNDRV_PCM_FORMAT_S24_3LE:
  2907. ucontrol->value.integer.value[0] = 2;
  2908. break;
  2909. case SNDRV_PCM_FORMAT_S24_LE:
  2910. ucontrol->value.integer.value[0] = 1;
  2911. break;
  2912. case SNDRV_PCM_FORMAT_S16_LE:
  2913. default:
  2914. ucontrol->value.integer.value[0] = 0;
  2915. break;
  2916. }
  2917. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2918. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2919. ucontrol->value.integer.value[0]);
  2920. return 0;
  2921. }
  2922. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2923. struct snd_ctl_elem_value *ucontrol)
  2924. {
  2925. int rc = 0;
  2926. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2927. if (ch_num < 0) {
  2928. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2929. return ch_num;
  2930. }
  2931. switch (ucontrol->value.integer.value[0]) {
  2932. case 3:
  2933. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2934. break;
  2935. case 2:
  2936. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2937. break;
  2938. case 1:
  2939. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2940. break;
  2941. case 0:
  2942. default:
  2943. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2944. break;
  2945. }
  2946. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2947. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2948. ucontrol->value.integer.value[0]);
  2949. return rc;
  2950. }
  2951. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2952. {
  2953. int idx = 0;
  2954. switch (be_id) {
  2955. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2956. idx = WSA_CDC_DMA_RX_0;
  2957. break;
  2958. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2959. idx = WSA_CDC_DMA_TX_0;
  2960. break;
  2961. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2962. idx = WSA_CDC_DMA_RX_1;
  2963. break;
  2964. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2965. idx = WSA_CDC_DMA_TX_1;
  2966. break;
  2967. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2968. idx = WSA_CDC_DMA_TX_2;
  2969. break;
  2970. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2971. idx = RX_CDC_DMA_RX_0;
  2972. break;
  2973. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2974. idx = RX_CDC_DMA_RX_1;
  2975. break;
  2976. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2977. idx = RX_CDC_DMA_RX_2;
  2978. break;
  2979. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2980. idx = RX_CDC_DMA_RX_3;
  2981. break;
  2982. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2983. idx = RX_CDC_DMA_RX_5;
  2984. break;
  2985. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  2986. idx = RX_CDC_DMA_RX_6;
  2987. break;
  2988. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2989. idx = TX_CDC_DMA_TX_0;
  2990. break;
  2991. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2992. idx = TX_CDC_DMA_TX_3;
  2993. break;
  2994. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2995. idx = TX_CDC_DMA_TX_4;
  2996. break;
  2997. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2998. idx = VA_CDC_DMA_TX_0;
  2999. break;
  3000. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3001. idx = VA_CDC_DMA_TX_1;
  3002. break;
  3003. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3004. idx = VA_CDC_DMA_TX_2;
  3005. break;
  3006. default:
  3007. idx = RX_CDC_DMA_RX_0;
  3008. break;
  3009. }
  3010. return idx;
  3011. }
  3012. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  3013. struct snd_ctl_elem_value *ucontrol)
  3014. {
  3015. /*
  3016. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  3017. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  3018. * value.
  3019. */
  3020. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3021. case SAMPLING_RATE_96KHZ:
  3022. ucontrol->value.integer.value[0] = 5;
  3023. break;
  3024. case SAMPLING_RATE_88P2KHZ:
  3025. ucontrol->value.integer.value[0] = 4;
  3026. break;
  3027. case SAMPLING_RATE_48KHZ:
  3028. ucontrol->value.integer.value[0] = 3;
  3029. break;
  3030. case SAMPLING_RATE_44P1KHZ:
  3031. ucontrol->value.integer.value[0] = 2;
  3032. break;
  3033. case SAMPLING_RATE_16KHZ:
  3034. ucontrol->value.integer.value[0] = 1;
  3035. break;
  3036. case SAMPLING_RATE_8KHZ:
  3037. default:
  3038. ucontrol->value.integer.value[0] = 0;
  3039. break;
  3040. }
  3041. pr_debug("%s: sample rate = %d\n", __func__,
  3042. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3043. return 0;
  3044. }
  3045. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  3046. struct snd_ctl_elem_value *ucontrol)
  3047. {
  3048. switch (ucontrol->value.integer.value[0]) {
  3049. case 1:
  3050. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3051. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3052. break;
  3053. case 2:
  3054. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3055. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3056. break;
  3057. case 3:
  3058. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3059. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3060. break;
  3061. case 4:
  3062. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3063. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3064. break;
  3065. case 5:
  3066. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3067. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3068. break;
  3069. case 0:
  3070. default:
  3071. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3072. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3073. break;
  3074. }
  3075. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  3076. __func__,
  3077. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3078. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3079. ucontrol->value.enumerated.item[0]);
  3080. return 0;
  3081. }
  3082. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  3083. struct snd_ctl_elem_value *ucontrol)
  3084. {
  3085. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3086. case SAMPLING_RATE_96KHZ:
  3087. ucontrol->value.integer.value[0] = 5;
  3088. break;
  3089. case SAMPLING_RATE_88P2KHZ:
  3090. ucontrol->value.integer.value[0] = 4;
  3091. break;
  3092. case SAMPLING_RATE_48KHZ:
  3093. ucontrol->value.integer.value[0] = 3;
  3094. break;
  3095. case SAMPLING_RATE_44P1KHZ:
  3096. ucontrol->value.integer.value[0] = 2;
  3097. break;
  3098. case SAMPLING_RATE_16KHZ:
  3099. ucontrol->value.integer.value[0] = 1;
  3100. break;
  3101. case SAMPLING_RATE_8KHZ:
  3102. default:
  3103. ucontrol->value.integer.value[0] = 0;
  3104. break;
  3105. }
  3106. pr_debug("%s: sample rate rx = %d\n", __func__,
  3107. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3108. return 0;
  3109. }
  3110. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  3111. struct snd_ctl_elem_value *ucontrol)
  3112. {
  3113. switch (ucontrol->value.integer.value[0]) {
  3114. case 1:
  3115. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3116. break;
  3117. case 2:
  3118. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3119. break;
  3120. case 3:
  3121. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3122. break;
  3123. case 4:
  3124. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3125. break;
  3126. case 5:
  3127. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3128. break;
  3129. case 0:
  3130. default:
  3131. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3132. break;
  3133. }
  3134. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  3135. __func__,
  3136. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3137. ucontrol->value.enumerated.item[0]);
  3138. return 0;
  3139. }
  3140. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  3141. struct snd_ctl_elem_value *ucontrol)
  3142. {
  3143. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  3144. case SAMPLING_RATE_96KHZ:
  3145. ucontrol->value.integer.value[0] = 5;
  3146. break;
  3147. case SAMPLING_RATE_88P2KHZ:
  3148. ucontrol->value.integer.value[0] = 4;
  3149. break;
  3150. case SAMPLING_RATE_48KHZ:
  3151. ucontrol->value.integer.value[0] = 3;
  3152. break;
  3153. case SAMPLING_RATE_44P1KHZ:
  3154. ucontrol->value.integer.value[0] = 2;
  3155. break;
  3156. case SAMPLING_RATE_16KHZ:
  3157. ucontrol->value.integer.value[0] = 1;
  3158. break;
  3159. case SAMPLING_RATE_8KHZ:
  3160. default:
  3161. ucontrol->value.integer.value[0] = 0;
  3162. break;
  3163. }
  3164. pr_debug("%s: sample rate tx = %d\n", __func__,
  3165. slim_tx_cfg[SLIM_TX_7].sample_rate);
  3166. return 0;
  3167. }
  3168. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  3169. struct snd_ctl_elem_value *ucontrol)
  3170. {
  3171. switch (ucontrol->value.integer.value[0]) {
  3172. case 1:
  3173. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3174. break;
  3175. case 2:
  3176. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3177. break;
  3178. case 3:
  3179. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3180. break;
  3181. case 4:
  3182. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3183. break;
  3184. case 5:
  3185. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3186. break;
  3187. case 0:
  3188. default:
  3189. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3190. break;
  3191. }
  3192. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  3193. __func__,
  3194. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3195. ucontrol->value.enumerated.item[0]);
  3196. return 0;
  3197. }
  3198. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  3199. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3200. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3201. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3202. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3203. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  3204. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3205. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  3206. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3207. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  3208. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3209. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  3210. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3211. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  3212. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3213. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Channels", rx_cdc_dma_rx_6_chs,
  3214. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3215. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3216. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3217. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3218. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3219. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3220. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3221. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  3222. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3223. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  3224. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3225. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  3226. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3227. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3228. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3229. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3230. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3231. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  3232. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3233. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3234. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3235. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3236. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3237. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3238. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3239. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3240. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3241. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  3242. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3243. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  3244. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3245. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  3246. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3247. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3248. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3249. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3250. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3251. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  3252. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3253. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3254. wsa_cdc_dma_rx_0_sample_rate,
  3255. cdc_dma_rx_sample_rate_get,
  3256. cdc_dma_rx_sample_rate_put),
  3257. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3258. wsa_cdc_dma_rx_1_sample_rate,
  3259. cdc_dma_rx_sample_rate_get,
  3260. cdc_dma_rx_sample_rate_put),
  3261. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3262. wsa_cdc_dma_tx_0_sample_rate,
  3263. cdc_dma_tx_sample_rate_get,
  3264. cdc_dma_tx_sample_rate_put),
  3265. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3266. wsa_cdc_dma_tx_1_sample_rate,
  3267. cdc_dma_tx_sample_rate_get,
  3268. cdc_dma_tx_sample_rate_put),
  3269. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3270. wsa_cdc_dma_tx_2_sample_rate,
  3271. cdc_dma_tx_sample_rate_get,
  3272. cdc_dma_tx_sample_rate_put),
  3273. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  3274. tx_cdc_dma_tx_0_sample_rate,
  3275. cdc_dma_tx_sample_rate_get,
  3276. cdc_dma_tx_sample_rate_put),
  3277. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3278. tx_cdc_dma_tx_3_sample_rate,
  3279. cdc_dma_tx_sample_rate_get,
  3280. cdc_dma_tx_sample_rate_put),
  3281. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3282. tx_cdc_dma_tx_4_sample_rate,
  3283. cdc_dma_tx_sample_rate_get,
  3284. cdc_dma_tx_sample_rate_put),
  3285. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3286. va_cdc_dma_tx_0_sample_rate,
  3287. cdc_dma_tx_sample_rate_get,
  3288. cdc_dma_tx_sample_rate_put),
  3289. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3290. va_cdc_dma_tx_1_sample_rate,
  3291. cdc_dma_tx_sample_rate_get,
  3292. cdc_dma_tx_sample_rate_put),
  3293. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  3294. va_cdc_dma_tx_2_sample_rate,
  3295. cdc_dma_tx_sample_rate_get,
  3296. cdc_dma_tx_sample_rate_put),
  3297. };
  3298. static const struct snd_kcontrol_new msm_int_wcd9380_snd_controls[] = {
  3299. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc80_dma_rx_0_format,
  3300. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3301. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc80_dma_rx_1_format,
  3302. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3303. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc80_dma_rx_2_format,
  3304. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3305. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc80_dma_rx_3_format,
  3306. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3307. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc80_dma_rx_5_format,
  3308. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3309. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc80_dma_rx_6_format,
  3310. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3311. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3312. rx_cdc80_dma_rx_0_sample_rate,
  3313. cdc_dma_rx_sample_rate_get,
  3314. cdc_dma_rx_sample_rate_put),
  3315. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3316. rx_cdc80_dma_rx_1_sample_rate,
  3317. cdc_dma_rx_sample_rate_get,
  3318. cdc_dma_rx_sample_rate_put),
  3319. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3320. rx_cdc80_dma_rx_2_sample_rate,
  3321. cdc_dma_rx_sample_rate_get,
  3322. cdc_dma_rx_sample_rate_put),
  3323. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3324. rx_cdc80_dma_rx_3_sample_rate,
  3325. cdc_dma_rx_sample_rate_get,
  3326. cdc_dma_rx_sample_rate_put),
  3327. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3328. rx_cdc80_dma_rx_5_sample_rate,
  3329. cdc_dma_rx_sample_rate_get,
  3330. cdc_dma_rx_sample_rate_put),
  3331. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3332. rx_cdc80_dma_rx_6_sample_rate,
  3333. cdc_dma_rx_sample_rate_get,
  3334. cdc_dma_rx_sample_rate_put),
  3335. };
  3336. static const struct snd_kcontrol_new msm_int_wcd9385_snd_controls[] = {
  3337. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc85_dma_rx_0_format,
  3338. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3339. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc85_dma_rx_1_format,
  3340. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3341. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc85_dma_rx_2_format,
  3342. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3343. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc85_dma_rx_3_format,
  3344. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3345. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc85_dma_rx_5_format,
  3346. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3347. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc85_dma_rx_6_format,
  3348. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3349. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3350. rx_cdc85_dma_rx_0_sample_rate,
  3351. cdc_dma_rx_sample_rate_get,
  3352. cdc_dma_rx_sample_rate_put),
  3353. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3354. rx_cdc85_dma_rx_1_sample_rate,
  3355. cdc_dma_rx_sample_rate_get,
  3356. cdc_dma_rx_sample_rate_put),
  3357. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3358. rx_cdc85_dma_rx_2_sample_rate,
  3359. cdc_dma_rx_sample_rate_get,
  3360. cdc_dma_rx_sample_rate_put),
  3361. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3362. rx_cdc85_dma_rx_3_sample_rate,
  3363. cdc_dma_rx_sample_rate_get,
  3364. cdc_dma_rx_sample_rate_put),
  3365. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3366. rx_cdc85_dma_rx_5_sample_rate,
  3367. cdc_dma_rx_sample_rate_get,
  3368. cdc_dma_rx_sample_rate_put),
  3369. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3370. rx_cdc85_dma_rx_6_sample_rate,
  3371. cdc_dma_rx_sample_rate_get,
  3372. cdc_dma_rx_sample_rate_put),
  3373. };
  3374. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3375. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3376. usb_audio_rx_sample_rate_get,
  3377. usb_audio_rx_sample_rate_put),
  3378. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3379. usb_audio_tx_sample_rate_get,
  3380. usb_audio_tx_sample_rate_put),
  3381. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3382. tdm_rx_sample_rate_get,
  3383. tdm_rx_sample_rate_put),
  3384. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3385. tdm_rx_sample_rate_get,
  3386. tdm_rx_sample_rate_put),
  3387. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3388. tdm_rx_sample_rate_get,
  3389. tdm_rx_sample_rate_put),
  3390. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3391. tdm_rx_sample_rate_get,
  3392. tdm_rx_sample_rate_put),
  3393. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3394. tdm_rx_sample_rate_get,
  3395. tdm_rx_sample_rate_put),
  3396. SOC_ENUM_EXT("SEN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3397. tdm_rx_sample_rate_get,
  3398. tdm_rx_sample_rate_put),
  3399. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3400. tdm_tx_sample_rate_get,
  3401. tdm_tx_sample_rate_put),
  3402. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3403. tdm_tx_sample_rate_get,
  3404. tdm_tx_sample_rate_put),
  3405. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3406. tdm_tx_sample_rate_get,
  3407. tdm_tx_sample_rate_put),
  3408. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3409. tdm_tx_sample_rate_get,
  3410. tdm_tx_sample_rate_put),
  3411. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3412. tdm_tx_sample_rate_get,
  3413. tdm_tx_sample_rate_put),
  3414. SOC_ENUM_EXT("SEN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3415. tdm_tx_sample_rate_get,
  3416. tdm_tx_sample_rate_put),
  3417. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3418. aux_pcm_rx_sample_rate_get,
  3419. aux_pcm_rx_sample_rate_put),
  3420. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3421. aux_pcm_rx_sample_rate_get,
  3422. aux_pcm_rx_sample_rate_put),
  3423. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3424. aux_pcm_rx_sample_rate_get,
  3425. aux_pcm_rx_sample_rate_put),
  3426. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3427. aux_pcm_rx_sample_rate_get,
  3428. aux_pcm_rx_sample_rate_put),
  3429. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3430. aux_pcm_rx_sample_rate_get,
  3431. aux_pcm_rx_sample_rate_put),
  3432. SOC_ENUM_EXT("SEN_AUX_PCM_RX SampleRate", sen_aux_pcm_rx_sample_rate,
  3433. aux_pcm_rx_sample_rate_get,
  3434. aux_pcm_rx_sample_rate_put),
  3435. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3436. aux_pcm_tx_sample_rate_get,
  3437. aux_pcm_tx_sample_rate_put),
  3438. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3439. aux_pcm_tx_sample_rate_get,
  3440. aux_pcm_tx_sample_rate_put),
  3441. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3442. aux_pcm_tx_sample_rate_get,
  3443. aux_pcm_tx_sample_rate_put),
  3444. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3445. aux_pcm_tx_sample_rate_get,
  3446. aux_pcm_tx_sample_rate_put),
  3447. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3448. aux_pcm_tx_sample_rate_get,
  3449. aux_pcm_tx_sample_rate_put),
  3450. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3451. aux_pcm_tx_sample_rate_get,
  3452. aux_pcm_tx_sample_rate_put),
  3453. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3454. mi2s_rx_sample_rate_get,
  3455. mi2s_rx_sample_rate_put),
  3456. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3457. mi2s_rx_sample_rate_get,
  3458. mi2s_rx_sample_rate_put),
  3459. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3460. mi2s_rx_sample_rate_get,
  3461. mi2s_rx_sample_rate_put),
  3462. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3463. mi2s_rx_sample_rate_get,
  3464. mi2s_rx_sample_rate_put),
  3465. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3466. mi2s_rx_sample_rate_get,
  3467. mi2s_rx_sample_rate_put),
  3468. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3469. mi2s_rx_sample_rate_get,
  3470. mi2s_rx_sample_rate_put),
  3471. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3472. mi2s_tx_sample_rate_get,
  3473. mi2s_tx_sample_rate_put),
  3474. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3475. mi2s_tx_sample_rate_get,
  3476. mi2s_tx_sample_rate_put),
  3477. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3478. mi2s_tx_sample_rate_get,
  3479. mi2s_tx_sample_rate_put),
  3480. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3481. mi2s_tx_sample_rate_get,
  3482. mi2s_tx_sample_rate_put),
  3483. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3484. mi2s_tx_sample_rate_get,
  3485. mi2s_tx_sample_rate_put),
  3486. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3487. mi2s_tx_sample_rate_get,
  3488. mi2s_tx_sample_rate_put),
  3489. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3490. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3491. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3492. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3493. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3494. tdm_rx_format_get,
  3495. tdm_rx_format_put),
  3496. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3497. tdm_rx_format_get,
  3498. tdm_rx_format_put),
  3499. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3500. tdm_rx_format_get,
  3501. tdm_rx_format_put),
  3502. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3503. tdm_rx_format_get,
  3504. tdm_rx_format_put),
  3505. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3506. tdm_rx_format_get,
  3507. tdm_rx_format_put),
  3508. SOC_ENUM_EXT("SEN_TDM_RX_0 Format", tdm_rx_format,
  3509. tdm_rx_format_get,
  3510. tdm_rx_format_put),
  3511. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3512. tdm_tx_format_get,
  3513. tdm_tx_format_put),
  3514. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3515. tdm_tx_format_get,
  3516. tdm_tx_format_put),
  3517. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3518. tdm_tx_format_get,
  3519. tdm_tx_format_put),
  3520. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3521. tdm_tx_format_get,
  3522. tdm_tx_format_put),
  3523. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3524. tdm_tx_format_get,
  3525. tdm_tx_format_put),
  3526. SOC_ENUM_EXT("SEN_TDM_TX_0 Format", tdm_tx_format,
  3527. tdm_tx_format_get,
  3528. tdm_tx_format_put),
  3529. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3530. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3531. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3532. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3533. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3534. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3535. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3536. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3537. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3538. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3539. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3540. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3541. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3542. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3543. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3544. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3545. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3546. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3547. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3548. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3549. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3550. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3551. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3552. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3553. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3554. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3555. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3556. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3557. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3558. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3559. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3560. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3561. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3562. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3563. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3564. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3565. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3566. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3567. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3568. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3569. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3570. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3571. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3572. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3573. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3574. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3575. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3576. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3577. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3578. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3579. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3580. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3581. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3582. proxy_rx_ch_get, proxy_rx_ch_put),
  3583. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3584. tdm_rx_ch_get,
  3585. tdm_rx_ch_put),
  3586. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3587. tdm_rx_ch_get,
  3588. tdm_rx_ch_put),
  3589. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3590. tdm_rx_ch_get,
  3591. tdm_rx_ch_put),
  3592. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3593. tdm_rx_ch_get,
  3594. tdm_rx_ch_put),
  3595. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3596. tdm_rx_ch_get,
  3597. tdm_rx_ch_put),
  3598. SOC_ENUM_EXT("SEN_TDM_RX_0 Channels", tdm_rx_chs,
  3599. tdm_rx_ch_get,
  3600. tdm_rx_ch_put),
  3601. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3602. tdm_tx_ch_get,
  3603. tdm_tx_ch_put),
  3604. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3605. tdm_tx_ch_get,
  3606. tdm_tx_ch_put),
  3607. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3608. tdm_tx_ch_get,
  3609. tdm_tx_ch_put),
  3610. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3611. tdm_tx_ch_get,
  3612. tdm_tx_ch_put),
  3613. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3614. tdm_tx_ch_get,
  3615. tdm_tx_ch_put),
  3616. SOC_ENUM_EXT("SEN_TDM_TX_0 Channels", tdm_tx_chs,
  3617. tdm_tx_ch_get,
  3618. tdm_tx_ch_put),
  3619. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3620. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3621. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3622. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3623. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3624. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3625. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3626. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3627. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3628. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3629. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3630. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3631. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3632. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3633. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3634. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3635. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3636. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3637. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3638. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3639. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3640. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3641. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3642. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3643. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3644. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3645. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3646. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3647. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3648. ext_disp_rx_sample_rate_get,
  3649. ext_disp_rx_sample_rate_put),
  3650. SOC_ENUM_EXT("Display Port1 RX Channels", ext_disp_rx_chs,
  3651. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3652. SOC_ENUM_EXT("Display Port1 RX Bit Format", ext_disp_rx_format,
  3653. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3654. SOC_ENUM_EXT("Display Port1 RX SampleRate", ext_disp_rx_sample_rate,
  3655. ext_disp_rx_sample_rate_get,
  3656. ext_disp_rx_sample_rate_put),
  3657. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3658. msm_bt_sample_rate_get,
  3659. msm_bt_sample_rate_put),
  3660. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3661. msm_bt_sample_rate_rx_get,
  3662. msm_bt_sample_rate_rx_put),
  3663. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3664. msm_bt_sample_rate_tx_get,
  3665. msm_bt_sample_rate_tx_put),
  3666. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  3667. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  3668. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3669. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3670. SOC_SINGLE_MULTI_EXT("TDM Slot Map", SND_SOC_NOPM, 0, 255, 0,
  3671. TDM_MAX_SLOTS + MAX_PATH, NULL, tdm_slot_map_put),
  3672. };
  3673. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3674. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3675. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3676. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3677. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3678. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3679. aux_pcm_rx_sample_rate_get,
  3680. aux_pcm_rx_sample_rate_put),
  3681. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3682. aux_pcm_tx_sample_rate_get,
  3683. aux_pcm_tx_sample_rate_put),
  3684. };
  3685. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3686. {
  3687. int idx;
  3688. switch (be_id) {
  3689. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3690. idx = EXT_DISP_RX_IDX_DP;
  3691. break;
  3692. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3693. idx = EXT_DISP_RX_IDX_DP1;
  3694. break;
  3695. default:
  3696. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3697. idx = -EINVAL;
  3698. break;
  3699. }
  3700. return idx;
  3701. }
  3702. static int lahaina_send_island_va_config(int32_t be_id)
  3703. {
  3704. int rc = 0;
  3705. int port_id = 0xFFFF;
  3706. port_id = msm_get_port_id(be_id);
  3707. if (port_id < 0) {
  3708. pr_err("%s: Invalid island interface, be_id: %d\n",
  3709. __func__, be_id);
  3710. rc = -EINVAL;
  3711. } else {
  3712. /*
  3713. * send island mode config
  3714. * This should be the first configuration
  3715. */
  3716. rc = afe_send_port_island_mode(port_id);
  3717. if (rc)
  3718. pr_err("%s: afe send island mode failed %d\n",
  3719. __func__, rc);
  3720. }
  3721. return rc;
  3722. }
  3723. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3724. struct snd_pcm_hw_params *params)
  3725. {
  3726. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3727. struct snd_interval *rate = hw_param_interval(params,
  3728. SNDRV_PCM_HW_PARAM_RATE);
  3729. struct snd_interval *channels = hw_param_interval(params,
  3730. SNDRV_PCM_HW_PARAM_CHANNELS);
  3731. int idx = 0, rc = 0;
  3732. pr_debug("%s: dai_id= %d, format = %d, rate = %d\n",
  3733. __func__, dai_link->id, params_format(params),
  3734. params_rate(params));
  3735. switch (dai_link->id) {
  3736. case MSM_BACKEND_DAI_USB_RX:
  3737. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3738. usb_rx_cfg.bit_format);
  3739. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3740. channels->min = channels->max = usb_rx_cfg.channels;
  3741. break;
  3742. case MSM_BACKEND_DAI_USB_TX:
  3743. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3744. usb_tx_cfg.bit_format);
  3745. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3746. channels->min = channels->max = usb_tx_cfg.channels;
  3747. break;
  3748. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3749. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3750. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3751. if (idx < 0) {
  3752. pr_err("%s: Incorrect ext disp idx %d\n",
  3753. __func__, idx);
  3754. rc = idx;
  3755. goto done;
  3756. }
  3757. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3758. ext_disp_rx_cfg[idx].bit_format);
  3759. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3760. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3761. break;
  3762. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3763. channels->min = channels->max = proxy_rx_cfg.channels;
  3764. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3765. break;
  3766. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3767. channels->min = channels->max =
  3768. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3769. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3770. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3771. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3772. break;
  3773. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3774. channels->min = channels->max =
  3775. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3776. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3777. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3778. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3779. break;
  3780. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3781. channels->min = channels->max =
  3782. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3783. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3784. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3785. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3786. break;
  3787. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3788. channels->min = channels->max =
  3789. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3790. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3791. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3792. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3793. break;
  3794. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3795. channels->min = channels->max =
  3796. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3797. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3798. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3799. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3800. break;
  3801. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3802. channels->min = channels->max =
  3803. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3804. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3805. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3806. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3807. break;
  3808. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3809. channels->min = channels->max =
  3810. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3811. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3812. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3813. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3814. break;
  3815. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3816. channels->min = channels->max =
  3817. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3818. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3819. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3820. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3821. break;
  3822. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3823. channels->min = channels->max =
  3824. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3825. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3826. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3827. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3828. break;
  3829. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3830. channels->min = channels->max =
  3831. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3832. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3833. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3834. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3835. break;
  3836. case MSM_BACKEND_DAI_SEN_TDM_RX_0:
  3837. channels->min = channels->max =
  3838. tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3839. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3840. tdm_rx_cfg[TDM_SEN][TDM_0].bit_format);
  3841. rate->min = rate->max = tdm_rx_cfg[TDM_SEN][TDM_0].sample_rate;
  3842. break;
  3843. case MSM_BACKEND_DAI_SEN_TDM_TX_0:
  3844. channels->min = channels->max =
  3845. tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3846. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3847. tdm_tx_cfg[TDM_SEN][TDM_0].bit_format);
  3848. rate->min = rate->max = tdm_tx_cfg[TDM_SEN][TDM_0].sample_rate;
  3849. break;
  3850. case MSM_BACKEND_DAI_AUXPCM_RX:
  3851. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3852. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3853. rate->min = rate->max =
  3854. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3855. channels->min = channels->max =
  3856. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3857. break;
  3858. case MSM_BACKEND_DAI_AUXPCM_TX:
  3859. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3860. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3861. rate->min = rate->max =
  3862. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3863. channels->min = channels->max =
  3864. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3865. break;
  3866. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3867. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3868. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3869. rate->min = rate->max =
  3870. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3871. channels->min = channels->max =
  3872. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3873. break;
  3874. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3875. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3876. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3877. rate->min = rate->max =
  3878. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3879. channels->min = channels->max =
  3880. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3881. break;
  3882. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3883. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3884. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3885. rate->min = rate->max =
  3886. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3887. channels->min = channels->max =
  3888. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3889. break;
  3890. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3891. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3892. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3893. rate->min = rate->max =
  3894. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3895. channels->min = channels->max =
  3896. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3897. break;
  3898. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  3899. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3900. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  3901. rate->min = rate->max =
  3902. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  3903. channels->min = channels->max =
  3904. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  3905. break;
  3906. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  3907. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3908. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  3909. rate->min = rate->max =
  3910. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  3911. channels->min = channels->max =
  3912. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  3913. break;
  3914. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  3915. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3916. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  3917. rate->min = rate->max =
  3918. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  3919. channels->min = channels->max =
  3920. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  3921. break;
  3922. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  3923. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3924. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  3925. rate->min = rate->max =
  3926. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  3927. channels->min = channels->max =
  3928. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  3929. break;
  3930. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  3931. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3932. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  3933. rate->min = rate->max =
  3934. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  3935. channels->min = channels->max =
  3936. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  3937. break;
  3938. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  3939. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3940. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  3941. rate->min = rate->max =
  3942. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  3943. channels->min = channels->max =
  3944. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  3945. break;
  3946. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3947. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3948. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  3949. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  3950. channels->min = channels->max =
  3951. mi2s_rx_cfg[PRIM_MI2S].channels;
  3952. break;
  3953. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3954. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3955. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  3956. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  3957. channels->min = channels->max =
  3958. mi2s_tx_cfg[PRIM_MI2S].channels;
  3959. break;
  3960. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3961. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3962. mi2s_rx_cfg[SEC_MI2S].bit_format);
  3963. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  3964. channels->min = channels->max =
  3965. mi2s_rx_cfg[SEC_MI2S].channels;
  3966. break;
  3967. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3968. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3969. mi2s_tx_cfg[SEC_MI2S].bit_format);
  3970. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  3971. channels->min = channels->max =
  3972. mi2s_tx_cfg[SEC_MI2S].channels;
  3973. break;
  3974. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3975. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3976. mi2s_rx_cfg[TERT_MI2S].bit_format);
  3977. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  3978. channels->min = channels->max =
  3979. mi2s_rx_cfg[TERT_MI2S].channels;
  3980. break;
  3981. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3982. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3983. mi2s_tx_cfg[TERT_MI2S].bit_format);
  3984. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  3985. channels->min = channels->max =
  3986. mi2s_tx_cfg[TERT_MI2S].channels;
  3987. break;
  3988. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  3989. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3990. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  3991. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  3992. channels->min = channels->max =
  3993. mi2s_rx_cfg[QUAT_MI2S].channels;
  3994. break;
  3995. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  3996. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3997. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  3998. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  3999. channels->min = channels->max =
  4000. mi2s_tx_cfg[QUAT_MI2S].channels;
  4001. break;
  4002. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4003. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4004. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4005. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4006. channels->min = channels->max =
  4007. mi2s_rx_cfg[QUIN_MI2S].channels;
  4008. break;
  4009. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4010. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4011. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4012. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4013. channels->min = channels->max =
  4014. mi2s_tx_cfg[QUIN_MI2S].channels;
  4015. break;
  4016. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  4017. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4018. mi2s_rx_cfg[SEN_MI2S].bit_format);
  4019. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  4020. channels->min = channels->max =
  4021. mi2s_rx_cfg[SEN_MI2S].channels;
  4022. break;
  4023. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  4024. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4025. mi2s_tx_cfg[SEN_MI2S].bit_format);
  4026. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  4027. channels->min = channels->max =
  4028. mi2s_tx_cfg[SEN_MI2S].channels;
  4029. break;
  4030. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4031. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4032. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4033. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4034. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4035. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4036. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4037. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4038. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4039. cdc_dma_rx_cfg[idx].bit_format);
  4040. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4041. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4042. break;
  4043. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4044. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4045. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4046. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4047. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4048. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4049. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4050. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4051. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4052. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4053. cdc_dma_tx_cfg[idx].bit_format);
  4054. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4055. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4056. break;
  4057. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4058. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4059. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4060. SNDRV_PCM_FORMAT_S32_LE);
  4061. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4062. channels->min = channels->max = msm_vi_feed_tx_ch;
  4063. break;
  4064. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  4065. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4066. slim_rx_cfg[SLIM_RX_7].bit_format);
  4067. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  4068. channels->min = channels->max =
  4069. slim_rx_cfg[SLIM_RX_7].channels;
  4070. break;
  4071. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  4072. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4073. slim_tx_cfg[SLIM_TX_7].bit_format);
  4074. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  4075. channels->min = channels->max =
  4076. slim_tx_cfg[SLIM_TX_7].channels;
  4077. break;
  4078. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  4079. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  4080. channels->min = channels->max =
  4081. slim_tx_cfg[SLIM_TX_8].channels;
  4082. break;
  4083. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4084. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4085. afe_loopback_tx_cfg[idx].bit_format);
  4086. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  4087. channels->min = channels->max =
  4088. afe_loopback_tx_cfg[idx].channels;
  4089. break;
  4090. default:
  4091. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4092. break;
  4093. }
  4094. done:
  4095. return rc;
  4096. }
  4097. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4098. {
  4099. struct snd_soc_card *card = component->card;
  4100. struct msm_asoc_mach_data *pdata =
  4101. snd_soc_card_get_drvdata(card);
  4102. if (!pdata->fsa_handle)
  4103. return false;
  4104. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  4105. }
  4106. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4107. {
  4108. int value = 0;
  4109. bool ret = false;
  4110. struct snd_soc_card *card;
  4111. struct msm_asoc_mach_data *pdata;
  4112. if (!component) {
  4113. pr_err("%s component is NULL\n", __func__);
  4114. return false;
  4115. }
  4116. card = component->card;
  4117. pdata = snd_soc_card_get_drvdata(card);
  4118. if (!pdata)
  4119. return false;
  4120. if (wcd_mbhc_cfg.enable_usbc_analog)
  4121. return msm_usbc_swap_gnd_mic(component, active);
  4122. /* if usbc is not defined, swap using us_euro_gpio_p */
  4123. if (pdata->us_euro_gpio_p) {
  4124. value = msm_cdc_pinctrl_get_state(
  4125. pdata->us_euro_gpio_p);
  4126. if (value)
  4127. msm_cdc_pinctrl_select_sleep_state(
  4128. pdata->us_euro_gpio_p);
  4129. else
  4130. msm_cdc_pinctrl_select_active_state(
  4131. pdata->us_euro_gpio_p);
  4132. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  4133. __func__, value, !value);
  4134. ret = true;
  4135. }
  4136. return ret;
  4137. }
  4138. static int lahaina_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  4139. struct snd_pcm_hw_params *params)
  4140. {
  4141. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4142. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4143. int ret = 0;
  4144. int slot_width = TDM_SLOT_WIDTH_BITS;
  4145. int channels, slots = TDM_MAX_SLOTS;
  4146. unsigned int slot_mask, rate, clk_freq;
  4147. unsigned int *slot_offset;
  4148. struct tdm_dev_config *config;
  4149. unsigned int path_dir = 0, interface = 0, channel_interface = 0;
  4150. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  4151. if (cpu_dai->id < AFE_PORT_ID_TDM_PORT_RANGE_START) {
  4152. pr_err("%s: dai id 0x%x not supported\n",
  4153. __func__, cpu_dai->id);
  4154. return -EINVAL;
  4155. }
  4156. /* RX or TX */
  4157. path_dir = cpu_dai->id % MAX_PATH;
  4158. /* PRI, SEC, TERT, QUAT, QUIN, ... */
  4159. interface = (cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START)
  4160. / (MAX_PATH * TDM_PORT_MAX);
  4161. /* 0, 1, 2, .. 7 */
  4162. channel_interface =
  4163. ((cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START) / MAX_PATH)
  4164. % TDM_PORT_MAX;
  4165. pr_debug("%s: path dir: %u, interface %u, channel interface %u\n",
  4166. __func__, path_dir, interface, channel_interface);
  4167. config = ((struct tdm_dev_config *) tdm_cfg[interface]) +
  4168. (path_dir * TDM_PORT_MAX) + channel_interface;
  4169. slot_offset = config->tdm_slot_offset;
  4170. if (path_dir)
  4171. channels = tdm_tx_cfg[interface][channel_interface].channels;
  4172. else
  4173. channels = tdm_rx_cfg[interface][channel_interface].channels;
  4174. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4175. /*2 slot config - bits 0 and 1 set for the first two slots */
  4176. slot_mask = 0x0000FFFF >> (16 - slots);
  4177. pr_debug("%s: tdm rx slot_width %d slots %d slot_mask %x\n",
  4178. __func__, slot_width, slots, slot_mask);
  4179. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  4180. slots, slot_width);
  4181. if (ret < 0) {
  4182. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  4183. __func__, ret);
  4184. goto end;
  4185. }
  4186. pr_debug("%s: tdm rx channels: %d\n", __func__, channels);
  4187. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4188. 0, NULL, channels, slot_offset);
  4189. if (ret < 0) {
  4190. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  4191. __func__, ret);
  4192. goto end;
  4193. }
  4194. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4195. /*2 slot config - bits 0 and 1 set for the first two slots */
  4196. slot_mask = 0x0000FFFF >> (16 - slots);
  4197. pr_debug("%s: tdm tx slot_width %d slots %d slot_mask %x\n",
  4198. __func__, slot_width, slots, slot_mask);
  4199. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  4200. slots, slot_width);
  4201. if (ret < 0) {
  4202. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  4203. __func__, ret);
  4204. goto end;
  4205. }
  4206. pr_debug("%s: tdm tx channels: %d\n", __func__, channels);
  4207. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4208. channels, slot_offset, 0, NULL);
  4209. if (ret < 0) {
  4210. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  4211. __func__, ret);
  4212. goto end;
  4213. }
  4214. } else {
  4215. ret = -EINVAL;
  4216. pr_err("%s: invalid use case, err:%d\n",
  4217. __func__, ret);
  4218. goto end;
  4219. }
  4220. rate = params_rate(params);
  4221. clk_freq = rate * slot_width * slots;
  4222. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  4223. if (ret < 0)
  4224. pr_err("%s: failed to set tdm clk, err:%d\n",
  4225. __func__, ret);
  4226. end:
  4227. return ret;
  4228. }
  4229. static int msm_get_tdm_mode(u32 port_id)
  4230. {
  4231. int tdm_mode;
  4232. switch (port_id) {
  4233. case AFE_PORT_ID_PRIMARY_TDM_RX:
  4234. case AFE_PORT_ID_PRIMARY_TDM_TX:
  4235. tdm_mode = TDM_PRI;
  4236. break;
  4237. case AFE_PORT_ID_SECONDARY_TDM_RX:
  4238. case AFE_PORT_ID_SECONDARY_TDM_TX:
  4239. tdm_mode = TDM_SEC;
  4240. break;
  4241. case AFE_PORT_ID_TERTIARY_TDM_RX:
  4242. case AFE_PORT_ID_TERTIARY_TDM_TX:
  4243. tdm_mode = TDM_TERT;
  4244. break;
  4245. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  4246. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  4247. tdm_mode = TDM_QUAT;
  4248. break;
  4249. case AFE_PORT_ID_QUINARY_TDM_RX:
  4250. case AFE_PORT_ID_QUINARY_TDM_TX:
  4251. tdm_mode = TDM_QUIN;
  4252. break;
  4253. case AFE_PORT_ID_SENARY_TDM_RX:
  4254. case AFE_PORT_ID_SENARY_TDM_TX:
  4255. tdm_mode = TDM_SEN;
  4256. break;
  4257. default:
  4258. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  4259. tdm_mode = -EINVAL;
  4260. }
  4261. return tdm_mode;
  4262. }
  4263. static int lahaina_tdm_snd_startup(struct snd_pcm_substream *substream)
  4264. {
  4265. int ret = 0;
  4266. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4267. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4268. struct snd_soc_card *card = rtd->card;
  4269. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4270. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4271. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4272. ret = -EINVAL;
  4273. pr_err("%s: Invalid TDM interface %d\n",
  4274. __func__, ret);
  4275. return ret;
  4276. }
  4277. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4278. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4279. == 0) {
  4280. ret = msm_cdc_pinctrl_select_active_state(
  4281. pdata->mi2s_gpio_p[tdm_mode]);
  4282. if (ret) {
  4283. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  4284. __func__, ret);
  4285. goto done;
  4286. }
  4287. }
  4288. atomic_inc(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4289. }
  4290. done:
  4291. return ret;
  4292. }
  4293. static void lahaina_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  4294. {
  4295. int ret = 0;
  4296. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4297. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4298. struct snd_soc_card *card = rtd->card;
  4299. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4300. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4301. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4302. ret = -EINVAL;
  4303. pr_err("%s: Invalid TDM interface %d\n",
  4304. __func__, ret);
  4305. return;
  4306. }
  4307. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4308. atomic_dec(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4309. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4310. == 0) {
  4311. ret = msm_cdc_pinctrl_select_sleep_state(
  4312. pdata->mi2s_gpio_p[tdm_mode]);
  4313. if (ret)
  4314. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  4315. __func__, ret);
  4316. }
  4317. }
  4318. }
  4319. static int lahaina_aux_snd_startup(struct snd_pcm_substream *substream)
  4320. {
  4321. int ret = 0;
  4322. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4323. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4324. struct snd_soc_card *card = rtd->card;
  4325. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4326. u32 aux_mode = cpu_dai->id - 1;
  4327. if (aux_mode >= AUX_PCM_MAX) {
  4328. ret = -EINVAL;
  4329. pr_err("%s: Invalid AUX interface %d\n",
  4330. __func__, ret);
  4331. return ret;
  4332. }
  4333. if (pdata->mi2s_gpio_p[aux_mode]) {
  4334. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4335. == 0) {
  4336. ret = msm_cdc_pinctrl_select_active_state(
  4337. pdata->mi2s_gpio_p[aux_mode]);
  4338. if (ret) {
  4339. pr_err("%s: AUX GPIO pinctrl set active failed with %d\n",
  4340. __func__, ret);
  4341. goto done;
  4342. }
  4343. }
  4344. atomic_inc(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4345. }
  4346. done:
  4347. return ret;
  4348. }
  4349. static void lahaina_aux_snd_shutdown(struct snd_pcm_substream *substream)
  4350. {
  4351. int ret = 0;
  4352. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4353. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4354. struct snd_soc_card *card = rtd->card;
  4355. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4356. u32 aux_mode = cpu_dai->id - 1;
  4357. if (aux_mode >= AUX_PCM_MAX) {
  4358. pr_err("%s: Invalid AUX interface %d\n",
  4359. __func__, ret);
  4360. return;
  4361. }
  4362. if (pdata->mi2s_gpio_p[aux_mode]) {
  4363. atomic_dec(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4364. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4365. == 0) {
  4366. ret = msm_cdc_pinctrl_select_sleep_state(
  4367. pdata->mi2s_gpio_p[aux_mode]);
  4368. if (ret)
  4369. pr_err("%s: AUX GPIO pinctrl set sleep failed with %d\n",
  4370. __func__, ret);
  4371. }
  4372. }
  4373. }
  4374. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4375. {
  4376. int ret = 0;
  4377. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4378. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4379. switch (dai_link->id) {
  4380. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4381. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4382. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4383. ret = lahaina_send_island_va_config(dai_link->id);
  4384. if (ret)
  4385. pr_err("%s: send island va cfg failed, err: %d\n",
  4386. __func__, ret);
  4387. break;
  4388. }
  4389. return ret;
  4390. }
  4391. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4392. struct snd_pcm_hw_params *params)
  4393. {
  4394. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4395. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4396. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4397. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4398. int ret = 0;
  4399. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4400. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4401. u32 user_set_tx_ch = 0;
  4402. u32 user_set_rx_ch = 0;
  4403. u32 ch_id;
  4404. ret = snd_soc_dai_get_channel_map(codec_dai,
  4405. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4406. &rx_ch_cdc_dma);
  4407. if (ret < 0) {
  4408. pr_err("%s: failed to get codec chan map, err:%d\n",
  4409. __func__, ret);
  4410. goto err;
  4411. }
  4412. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4413. switch (dai_link->id) {
  4414. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4415. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4416. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4417. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4418. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4419. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4420. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4421. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4422. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4423. {
  4424. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4425. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4426. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4427. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4428. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4429. user_set_rx_ch, &rx_ch_cdc_dma);
  4430. if (ret < 0) {
  4431. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4432. __func__, ret);
  4433. goto err;
  4434. }
  4435. }
  4436. break;
  4437. }
  4438. } else {
  4439. switch (dai_link->id) {
  4440. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4441. {
  4442. user_set_tx_ch = msm_vi_feed_tx_ch;
  4443. }
  4444. break;
  4445. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4446. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4447. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4448. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4449. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4450. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4451. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4452. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4453. {
  4454. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4455. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4456. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4457. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4458. }
  4459. break;
  4460. }
  4461. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4462. &tx_ch_cdc_dma, 0, 0);
  4463. if (ret < 0) {
  4464. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4465. __func__, ret);
  4466. goto err;
  4467. }
  4468. }
  4469. err:
  4470. return ret;
  4471. }
  4472. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4473. {
  4474. (void)substream;
  4475. qos_client_active_cnt++;
  4476. if (qos_client_active_cnt == 1)
  4477. msm_audio_update_qos_request(MSM_LL_QOS_VALUE);
  4478. return 0;
  4479. }
  4480. static void msm_fe_qos_shutdown(struct snd_pcm_substream *substream)
  4481. {
  4482. (void)substream;
  4483. if (qos_client_active_cnt > 0)
  4484. qos_client_active_cnt--;
  4485. if (qos_client_active_cnt == 0)
  4486. msm_audio_update_qos_request(PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  4487. }
  4488. void mi2s_disable_audio_vote(struct snd_pcm_substream *substream)
  4489. {
  4490. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4491. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4492. int index = cpu_dai->id;
  4493. struct snd_soc_card *card = rtd->card;
  4494. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4495. int sample_rate = 0;
  4496. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4497. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4498. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4499. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4500. } else {
  4501. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4502. return;
  4503. }
  4504. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4505. if (pdata->lpass_audio_hw_vote != NULL) {
  4506. if (--pdata->core_audio_vote_count == 0) {
  4507. clk_disable_unprepare(
  4508. pdata->lpass_audio_hw_vote);
  4509. } else if (pdata->core_audio_vote_count < 0) {
  4510. pr_err("%s: audio vote mismatch\n", __func__);
  4511. pdata->core_audio_vote_count = 0;
  4512. }
  4513. } else {
  4514. pr_err("%s: Invalid lpass audio hw node\n", __func__);
  4515. }
  4516. }
  4517. }
  4518. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4519. {
  4520. int ret = 0;
  4521. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4522. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4523. int index = cpu_dai->id;
  4524. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4525. struct snd_soc_card *card = rtd->card;
  4526. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4527. int sample_rate = 0;
  4528. dev_dbg(rtd->card->dev,
  4529. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4530. __func__, substream->name, substream->stream,
  4531. cpu_dai->name, cpu_dai->id);
  4532. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4533. ret = -EINVAL;
  4534. dev_err(rtd->card->dev,
  4535. "%s: CPU DAI id (%d) out of range\n",
  4536. __func__, cpu_dai->id);
  4537. goto err;
  4538. }
  4539. /*
  4540. * Mutex protection in case the same MI2S
  4541. * interface using for both TX and RX so
  4542. * that the same clock won't be enable twice.
  4543. */
  4544. mutex_lock(&mi2s_intf_conf[index].lock);
  4545. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4546. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4547. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4548. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4549. } else {
  4550. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4551. ret = -EINVAL;
  4552. goto vote_err;
  4553. }
  4554. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4555. if (pdata->lpass_audio_hw_vote == NULL) {
  4556. dev_err(rtd->card->dev, "%s: Invalid lpass audio hw node\n",
  4557. __func__);
  4558. ret = -EINVAL;
  4559. goto vote_err;
  4560. }
  4561. if (pdata->core_audio_vote_count == 0) {
  4562. ret = clk_prepare_enable(pdata->lpass_audio_hw_vote);
  4563. if (ret < 0) {
  4564. dev_err(rtd->card->dev, "%s: audio vote error\n",
  4565. __func__);
  4566. goto vote_err;
  4567. }
  4568. }
  4569. pdata->core_audio_vote_count++;
  4570. }
  4571. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4572. /* Check if msm needs to provide the clock to the interface */
  4573. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4574. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4575. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4576. }
  4577. ret = msm_mi2s_set_sclk(substream, true);
  4578. if (ret < 0) {
  4579. dev_err(rtd->card->dev,
  4580. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4581. __func__, ret);
  4582. goto clean_up;
  4583. }
  4584. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4585. if (ret < 0) {
  4586. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4587. __func__, index, ret);
  4588. goto clk_off;
  4589. }
  4590. if (pdata->mi2s_gpio_p[index]) {
  4591. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4592. == 0) {
  4593. ret = msm_cdc_pinctrl_select_active_state(
  4594. pdata->mi2s_gpio_p[index]);
  4595. if (ret) {
  4596. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4597. __func__, ret);
  4598. goto clk_off;
  4599. }
  4600. }
  4601. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4602. }
  4603. }
  4604. clk_off:
  4605. if (ret < 0)
  4606. msm_mi2s_set_sclk(substream, false);
  4607. clean_up:
  4608. if (ret < 0) {
  4609. mi2s_intf_conf[index].ref_cnt--;
  4610. mi2s_disable_audio_vote(substream);
  4611. }
  4612. vote_err:
  4613. mutex_unlock(&mi2s_intf_conf[index].lock);
  4614. err:
  4615. return ret;
  4616. }
  4617. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4618. {
  4619. int ret = 0;
  4620. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4621. int index = rtd->cpu_dai->id;
  4622. struct snd_soc_card *card = rtd->card;
  4623. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4624. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4625. substream->name, substream->stream);
  4626. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4627. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4628. return;
  4629. }
  4630. mutex_lock(&mi2s_intf_conf[index].lock);
  4631. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4632. if (pdata->mi2s_gpio_p[index]) {
  4633. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4634. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4635. == 0) {
  4636. ret = msm_cdc_pinctrl_select_sleep_state(
  4637. pdata->mi2s_gpio_p[index]);
  4638. if (ret)
  4639. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4640. __func__, ret);
  4641. }
  4642. }
  4643. ret = msm_mi2s_set_sclk(substream, false);
  4644. if (ret < 0)
  4645. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4646. __func__, index, ret);
  4647. }
  4648. mi2s_disable_audio_vote(substream);
  4649. mutex_unlock(&mi2s_intf_conf[index].lock);
  4650. }
  4651. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4652. struct snd_pcm_hw_params *params)
  4653. {
  4654. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4655. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4656. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4657. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4658. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4659. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4660. int ret = 0;
  4661. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4662. codec_dai->name, codec_dai->id);
  4663. ret = snd_soc_dai_get_channel_map(codec_dai,
  4664. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4665. if (ret) {
  4666. dev_err(rtd->dev,
  4667. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4668. __func__, ret);
  4669. goto err;
  4670. }
  4671. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4672. __func__, tx_ch_cnt, dai_link->id);
  4673. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4674. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4675. if (ret)
  4676. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4677. __func__, ret);
  4678. err:
  4679. return ret;
  4680. }
  4681. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4682. struct snd_pcm_hw_params *params)
  4683. {
  4684. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4685. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4686. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4687. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4688. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4689. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4690. int ret = 0;
  4691. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4692. codec_dai->name, codec_dai->id);
  4693. ret = snd_soc_dai_get_channel_map(codec_dai,
  4694. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4695. if (ret) {
  4696. dev_err(rtd->dev,
  4697. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4698. __func__, ret);
  4699. goto err;
  4700. }
  4701. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4702. __func__, tx_ch_cnt, dai_link->id);
  4703. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4704. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4705. if (ret)
  4706. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4707. __func__, ret);
  4708. err:
  4709. return ret;
  4710. }
  4711. static struct snd_soc_ops lahaina_aux_be_ops = {
  4712. .startup = lahaina_aux_snd_startup,
  4713. .shutdown = lahaina_aux_snd_shutdown
  4714. };
  4715. static struct snd_soc_ops lahaina_tdm_be_ops = {
  4716. .hw_params = lahaina_tdm_snd_hw_params,
  4717. .startup = lahaina_tdm_snd_startup,
  4718. .shutdown = lahaina_tdm_snd_shutdown
  4719. };
  4720. static struct snd_soc_ops msm_mi2s_be_ops = {
  4721. .startup = msm_mi2s_snd_startup,
  4722. .shutdown = msm_mi2s_snd_shutdown,
  4723. };
  4724. static struct snd_soc_ops msm_fe_qos_ops = {
  4725. .prepare = msm_fe_qos_prepare,
  4726. .shutdown = msm_fe_qos_shutdown,
  4727. };
  4728. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4729. .startup = msm_snd_cdc_dma_startup,
  4730. .hw_params = msm_snd_cdc_dma_hw_params,
  4731. };
  4732. static struct snd_soc_ops msm_wcn_ops = {
  4733. .hw_params = msm_wcn_hw_params,
  4734. };
  4735. static struct snd_soc_ops msm_wcn_ops_lito = {
  4736. .hw_params = msm_wcn_hw_params_lito,
  4737. };
  4738. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4739. struct snd_kcontrol *kcontrol, int event)
  4740. {
  4741. struct msm_asoc_mach_data *pdata = NULL;
  4742. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4743. int ret = 0;
  4744. u32 dmic_idx;
  4745. int *dmic_gpio_cnt;
  4746. struct device_node *dmic_gpio;
  4747. char *wname;
  4748. wname = strpbrk(w->name, "012345");
  4749. if (!wname) {
  4750. dev_err(component->dev, "%s: widget not found\n", __func__);
  4751. return -EINVAL;
  4752. }
  4753. ret = kstrtouint(wname, 10, &dmic_idx);
  4754. if (ret < 0) {
  4755. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4756. __func__);
  4757. return -EINVAL;
  4758. }
  4759. pdata = snd_soc_card_get_drvdata(component->card);
  4760. switch (dmic_idx) {
  4761. case 0:
  4762. case 1:
  4763. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4764. dmic_gpio = pdata->dmic01_gpio_p;
  4765. break;
  4766. case 2:
  4767. case 3:
  4768. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4769. dmic_gpio = pdata->dmic23_gpio_p;
  4770. break;
  4771. case 4:
  4772. case 5:
  4773. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4774. dmic_gpio = pdata->dmic45_gpio_p;
  4775. break;
  4776. default:
  4777. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4778. __func__);
  4779. return -EINVAL;
  4780. }
  4781. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4782. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4783. switch (event) {
  4784. case SND_SOC_DAPM_PRE_PMU:
  4785. (*dmic_gpio_cnt)++;
  4786. if (*dmic_gpio_cnt == 1) {
  4787. ret = msm_cdc_pinctrl_select_active_state(
  4788. dmic_gpio);
  4789. if (ret < 0) {
  4790. pr_err("%s: gpio set cannot be activated %sd",
  4791. __func__, "dmic_gpio");
  4792. return ret;
  4793. }
  4794. }
  4795. break;
  4796. case SND_SOC_DAPM_POST_PMD:
  4797. (*dmic_gpio_cnt)--;
  4798. if (*dmic_gpio_cnt == 0) {
  4799. ret = msm_cdc_pinctrl_select_sleep_state(
  4800. dmic_gpio);
  4801. if (ret < 0) {
  4802. pr_err("%s: gpio set cannot be de-activated %sd",
  4803. __func__, "dmic_gpio");
  4804. return ret;
  4805. }
  4806. }
  4807. break;
  4808. default:
  4809. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  4810. return -EINVAL;
  4811. }
  4812. return 0;
  4813. }
  4814. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  4815. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  4816. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  4817. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  4818. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  4819. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  4820. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  4821. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  4822. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  4823. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  4824. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  4825. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  4826. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  4827. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  4828. };
  4829. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4830. {
  4831. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4832. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  4833. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4834. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4835. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4836. }
  4837. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  4838. {
  4839. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4840. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  4841. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4842. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4843. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4844. }
  4845. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  4846. const char *name,
  4847. struct snd_info_entry *parent)
  4848. {
  4849. struct snd_info_entry *entry;
  4850. entry = snd_info_create_module_entry(mod, name, parent);
  4851. if (!entry)
  4852. return NULL;
  4853. entry->mode = S_IFDIR | 0555;
  4854. if (snd_info_register(entry) < 0) {
  4855. snd_info_free_entry(entry);
  4856. return NULL;
  4857. }
  4858. return entry;
  4859. }
  4860. static void *def_wcd_mbhc_cal(void)
  4861. {
  4862. void *wcd_mbhc_cal;
  4863. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  4864. u16 *btn_high;
  4865. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  4866. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  4867. if (!wcd_mbhc_cal)
  4868. return NULL;
  4869. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  4870. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  4871. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  4872. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  4873. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  4874. btn_high[0] = 75;
  4875. btn_high[1] = 150;
  4876. btn_high[2] = 237;
  4877. btn_high[3] = 500;
  4878. btn_high[4] = 500;
  4879. btn_high[5] = 500;
  4880. btn_high[6] = 500;
  4881. btn_high[7] = 500;
  4882. return wcd_mbhc_cal;
  4883. }
  4884. /* Digital audio interface glue - connects codec <---> CPU */
  4885. static struct snd_soc_dai_link msm_common_dai_links[] = {
  4886. /* FrontEnd DAI Links */
  4887. {/* hw:x,0 */
  4888. .name = MSM_DAILINK_NAME(Media1),
  4889. .stream_name = "MultiMedia1",
  4890. .dynamic = 1,
  4891. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4892. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4893. #endif /* CONFIG_AUDIO_QGKI */
  4894. .dpcm_playback = 1,
  4895. .dpcm_capture = 1,
  4896. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4897. SND_SOC_DPCM_TRIGGER_POST},
  4898. .ignore_suspend = 1,
  4899. /* this dainlink has playback support */
  4900. .ignore_pmdown_time = 1,
  4901. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  4902. SND_SOC_DAILINK_REG(multimedia1),
  4903. },
  4904. {/* hw:x,1 */
  4905. .name = MSM_DAILINK_NAME(Media2),
  4906. .stream_name = "MultiMedia2",
  4907. .dynamic = 1,
  4908. .dpcm_playback = 1,
  4909. .dpcm_capture = 1,
  4910. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4911. SND_SOC_DPCM_TRIGGER_POST},
  4912. .ignore_suspend = 1,
  4913. /* this dainlink has playback support */
  4914. .ignore_pmdown_time = 1,
  4915. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  4916. SND_SOC_DAILINK_REG(multimedia2),
  4917. },
  4918. {/* hw:x,2 */
  4919. .name = "VoiceMMode1",
  4920. .stream_name = "VoiceMMode1",
  4921. .dynamic = 1,
  4922. .dpcm_playback = 1,
  4923. .dpcm_capture = 1,
  4924. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4925. SND_SOC_DPCM_TRIGGER_POST},
  4926. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4927. .ignore_suspend = 1,
  4928. .ignore_pmdown_time = 1,
  4929. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  4930. SND_SOC_DAILINK_REG(voicemmode1),
  4931. },
  4932. {/* hw:x,3 */
  4933. .name = "MSM VoIP",
  4934. .stream_name = "VoIP",
  4935. .dynamic = 1,
  4936. .dpcm_playback = 1,
  4937. .dpcm_capture = 1,
  4938. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4939. SND_SOC_DPCM_TRIGGER_POST},
  4940. .ignore_suspend = 1,
  4941. /* this dainlink has playback support */
  4942. .ignore_pmdown_time = 1,
  4943. .id = MSM_FRONTEND_DAI_VOIP,
  4944. SND_SOC_DAILINK_REG(msmvoip),
  4945. },
  4946. {/* hw:x,4 */
  4947. .name = MSM_DAILINK_NAME(ULL),
  4948. .stream_name = "MultiMedia3",
  4949. .dynamic = 1,
  4950. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4951. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4952. #endif /* CONFIG_AUDIO_QGKI */
  4953. .dpcm_playback = 1,
  4954. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4955. SND_SOC_DPCM_TRIGGER_POST},
  4956. .ignore_suspend = 1,
  4957. /* this dainlink has playback support */
  4958. .ignore_pmdown_time = 1,
  4959. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  4960. SND_SOC_DAILINK_REG(multimedia3),
  4961. },
  4962. {/* hw:x,5 */
  4963. .name = "MSM AFE-PCM RX",
  4964. .stream_name = "AFE-PROXY RX",
  4965. .dpcm_playback = 1,
  4966. .ignore_suspend = 1,
  4967. /* this dainlink has playback support */
  4968. .ignore_pmdown_time = 1,
  4969. SND_SOC_DAILINK_REG(afepcm_rx),
  4970. },
  4971. {/* hw:x,6 */
  4972. .name = "MSM AFE-PCM TX",
  4973. .stream_name = "AFE-PROXY TX",
  4974. .dpcm_capture = 1,
  4975. .ignore_suspend = 1,
  4976. SND_SOC_DAILINK_REG(afepcm_tx),
  4977. },
  4978. {/* hw:x,7 */
  4979. .name = MSM_DAILINK_NAME(Compress1),
  4980. .stream_name = "Compress1",
  4981. .dynamic = 1,
  4982. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4983. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  4984. #endif /* CONFIG_AUDIO_QGKI */
  4985. .dpcm_playback = 1,
  4986. .dpcm_capture = 1,
  4987. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4988. SND_SOC_DPCM_TRIGGER_POST},
  4989. .ignore_suspend = 1,
  4990. .ignore_pmdown_time = 1,
  4991. /* this dainlink has playback support */
  4992. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  4993. SND_SOC_DAILINK_REG(multimedia4),
  4994. },
  4995. /* Hostless PCM purpose */
  4996. {/* hw:x,8 */
  4997. .name = "AUXPCM Hostless",
  4998. .stream_name = "AUXPCM Hostless",
  4999. .dynamic = 1,
  5000. .dpcm_playback = 1,
  5001. .dpcm_capture = 1,
  5002. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5003. SND_SOC_DPCM_TRIGGER_POST},
  5004. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5005. .ignore_suspend = 1,
  5006. /* this dainlink has playback support */
  5007. .ignore_pmdown_time = 1,
  5008. SND_SOC_DAILINK_REG(auxpcm_hostless),
  5009. },
  5010. {/* hw:x,9 */
  5011. .name = MSM_DAILINK_NAME(LowLatency),
  5012. .stream_name = "MultiMedia5",
  5013. .dynamic = 1,
  5014. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5015. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5016. #endif /* CONFIG_AUDIO_QGKI */
  5017. .dpcm_playback = 1,
  5018. .dpcm_capture = 1,
  5019. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5020. SND_SOC_DPCM_TRIGGER_POST},
  5021. .ignore_suspend = 1,
  5022. /* this dainlink has playback support */
  5023. .ignore_pmdown_time = 1,
  5024. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  5025. .ops = &msm_fe_qos_ops,
  5026. SND_SOC_DAILINK_REG(multimedia5),
  5027. },
  5028. {/* hw:x,10 */
  5029. .name = "Listen 1 Audio Service",
  5030. .stream_name = "Listen 1 Audio Service",
  5031. .dynamic = 1,
  5032. .dpcm_capture = 1,
  5033. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5034. SND_SOC_DPCM_TRIGGER_POST },
  5035. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5036. .ignore_suspend = 1,
  5037. .id = MSM_FRONTEND_DAI_LSM1,
  5038. SND_SOC_DAILINK_REG(listen1),
  5039. },
  5040. /* Multiple Tunnel instances */
  5041. {/* hw:x,11 */
  5042. .name = MSM_DAILINK_NAME(Compress2),
  5043. .stream_name = "Compress2",
  5044. .dynamic = 1,
  5045. .dpcm_playback = 1,
  5046. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5047. SND_SOC_DPCM_TRIGGER_POST},
  5048. .ignore_suspend = 1,
  5049. .ignore_pmdown_time = 1,
  5050. /* this dainlink has playback support */
  5051. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  5052. SND_SOC_DAILINK_REG(multimedia7),
  5053. },
  5054. {/* hw:x,12 */
  5055. .name = MSM_DAILINK_NAME(MultiMedia10),
  5056. .stream_name = "MultiMedia10",
  5057. .dynamic = 1,
  5058. .dpcm_playback = 1,
  5059. .dpcm_capture = 1,
  5060. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5061. SND_SOC_DPCM_TRIGGER_POST},
  5062. .ignore_suspend = 1,
  5063. .ignore_pmdown_time = 1,
  5064. /* this dainlink has playback support */
  5065. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5066. SND_SOC_DAILINK_REG(multimedia10),
  5067. },
  5068. {/* hw:x,13 */
  5069. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  5070. .stream_name = "MM_NOIRQ",
  5071. .dynamic = 1,
  5072. .dpcm_playback = 1,
  5073. .dpcm_capture = 1,
  5074. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5075. SND_SOC_DPCM_TRIGGER_POST},
  5076. .ignore_suspend = 1,
  5077. .ignore_pmdown_time = 1,
  5078. /* this dainlink has playback support */
  5079. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  5080. .ops = &msm_fe_qos_ops,
  5081. SND_SOC_DAILINK_REG(multimedia8),
  5082. },
  5083. /* HDMI Hostless */
  5084. {/* hw:x,14 */
  5085. .name = "HDMI_RX_HOSTLESS",
  5086. .stream_name = "HDMI_RX_HOSTLESS",
  5087. .dynamic = 1,
  5088. .dpcm_playback = 1,
  5089. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5090. SND_SOC_DPCM_TRIGGER_POST},
  5091. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5092. .ignore_suspend = 1,
  5093. .ignore_pmdown_time = 1,
  5094. SND_SOC_DAILINK_REG(hdmi_rx_hostless),
  5095. },
  5096. {/* hw:x,15 */
  5097. .name = "VoiceMMode2",
  5098. .stream_name = "VoiceMMode2",
  5099. .dynamic = 1,
  5100. .dpcm_playback = 1,
  5101. .dpcm_capture = 1,
  5102. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5103. SND_SOC_DPCM_TRIGGER_POST},
  5104. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5105. .ignore_suspend = 1,
  5106. .ignore_pmdown_time = 1,
  5107. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5108. SND_SOC_DAILINK_REG(voicemmode2),
  5109. },
  5110. /* LSM FE */
  5111. {/* hw:x,16 */
  5112. .name = "Listen 2 Audio Service",
  5113. .stream_name = "Listen 2 Audio Service",
  5114. .dynamic = 1,
  5115. .dpcm_capture = 1,
  5116. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5117. SND_SOC_DPCM_TRIGGER_POST },
  5118. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5119. .ignore_suspend = 1,
  5120. .id = MSM_FRONTEND_DAI_LSM2,
  5121. SND_SOC_DAILINK_REG(listen2),
  5122. },
  5123. {/* hw:x,17 */
  5124. .name = "Listen 3 Audio Service",
  5125. .stream_name = "Listen 3 Audio Service",
  5126. .dynamic = 1,
  5127. .dpcm_capture = 1,
  5128. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5129. SND_SOC_DPCM_TRIGGER_POST },
  5130. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5131. .ignore_suspend = 1,
  5132. .id = MSM_FRONTEND_DAI_LSM3,
  5133. SND_SOC_DAILINK_REG(listen3),
  5134. },
  5135. {/* hw:x,18 */
  5136. .name = "Listen 4 Audio Service",
  5137. .stream_name = "Listen 4 Audio Service",
  5138. .dynamic = 1,
  5139. .dpcm_capture = 1,
  5140. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5141. SND_SOC_DPCM_TRIGGER_POST },
  5142. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5143. .ignore_suspend = 1,
  5144. .id = MSM_FRONTEND_DAI_LSM4,
  5145. SND_SOC_DAILINK_REG(listen4),
  5146. },
  5147. {/* hw:x,19 */
  5148. .name = "Listen 5 Audio Service",
  5149. .stream_name = "Listen 5 Audio Service",
  5150. .dynamic = 1,
  5151. .dpcm_capture = 1,
  5152. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5153. SND_SOC_DPCM_TRIGGER_POST },
  5154. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5155. .ignore_suspend = 1,
  5156. .id = MSM_FRONTEND_DAI_LSM5,
  5157. SND_SOC_DAILINK_REG(listen5),
  5158. },
  5159. {/* hw:x,20 */
  5160. .name = "Listen 6 Audio Service",
  5161. .stream_name = "Listen 6 Audio Service",
  5162. .dynamic = 1,
  5163. .dpcm_capture = 1,
  5164. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5165. SND_SOC_DPCM_TRIGGER_POST },
  5166. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5167. .ignore_suspend = 1,
  5168. .id = MSM_FRONTEND_DAI_LSM6,
  5169. SND_SOC_DAILINK_REG(listen6),
  5170. },
  5171. {/* hw:x,21 */
  5172. .name = "Listen 7 Audio Service",
  5173. .stream_name = "Listen 7 Audio Service",
  5174. .dynamic = 1,
  5175. .dpcm_capture = 1,
  5176. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5177. SND_SOC_DPCM_TRIGGER_POST },
  5178. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5179. .ignore_suspend = 1,
  5180. .id = MSM_FRONTEND_DAI_LSM7,
  5181. SND_SOC_DAILINK_REG(listen7),
  5182. },
  5183. {/* hw:x,22 */
  5184. .name = "Listen 8 Audio Service",
  5185. .stream_name = "Listen 8 Audio Service",
  5186. .dynamic = 1,
  5187. .dpcm_capture = 1,
  5188. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5189. SND_SOC_DPCM_TRIGGER_POST },
  5190. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5191. .ignore_suspend = 1,
  5192. .id = MSM_FRONTEND_DAI_LSM8,
  5193. SND_SOC_DAILINK_REG(listen8),
  5194. },
  5195. {/* hw:x,23 */
  5196. .name = MSM_DAILINK_NAME(Media9),
  5197. .stream_name = "MultiMedia9",
  5198. .dynamic = 1,
  5199. .dpcm_playback = 1,
  5200. .dpcm_capture = 1,
  5201. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5202. SND_SOC_DPCM_TRIGGER_POST},
  5203. .ignore_suspend = 1,
  5204. /* this dainlink has playback support */
  5205. .ignore_pmdown_time = 1,
  5206. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5207. SND_SOC_DAILINK_REG(multimedia9),
  5208. },
  5209. {/* hw:x,24 */
  5210. .name = MSM_DAILINK_NAME(Compress4),
  5211. .stream_name = "Compress4",
  5212. .dynamic = 1,
  5213. .dpcm_playback = 1,
  5214. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5215. SND_SOC_DPCM_TRIGGER_POST},
  5216. .ignore_suspend = 1,
  5217. .ignore_pmdown_time = 1,
  5218. /* this dainlink has playback support */
  5219. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5220. SND_SOC_DAILINK_REG(multimedia11),
  5221. },
  5222. {/* hw:x,25 */
  5223. .name = MSM_DAILINK_NAME(Compress5),
  5224. .stream_name = "Compress5",
  5225. .dynamic = 1,
  5226. .dpcm_playback = 1,
  5227. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5228. SND_SOC_DPCM_TRIGGER_POST},
  5229. .ignore_suspend = 1,
  5230. .ignore_pmdown_time = 1,
  5231. /* this dainlink has playback support */
  5232. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5233. SND_SOC_DAILINK_REG(multimedia12),
  5234. },
  5235. {/* hw:x,26 */
  5236. .name = MSM_DAILINK_NAME(Compress6),
  5237. .stream_name = "Compress6",
  5238. .dynamic = 1,
  5239. .dpcm_playback = 1,
  5240. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5241. SND_SOC_DPCM_TRIGGER_POST},
  5242. .ignore_suspend = 1,
  5243. .ignore_pmdown_time = 1,
  5244. /* this dainlink has playback support */
  5245. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5246. SND_SOC_DAILINK_REG(multimedia13),
  5247. },
  5248. {/* hw:x,27 */
  5249. .name = MSM_DAILINK_NAME(Compress7),
  5250. .stream_name = "Compress7",
  5251. .dynamic = 1,
  5252. .dpcm_playback = 1,
  5253. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5254. SND_SOC_DPCM_TRIGGER_POST},
  5255. .ignore_suspend = 1,
  5256. .ignore_pmdown_time = 1,
  5257. /* this dainlink has playback support */
  5258. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5259. SND_SOC_DAILINK_REG(multimedia14),
  5260. },
  5261. {/* hw:x,28 */
  5262. .name = MSM_DAILINK_NAME(Compress8),
  5263. .stream_name = "Compress8",
  5264. .dynamic = 1,
  5265. .dpcm_playback = 1,
  5266. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5267. SND_SOC_DPCM_TRIGGER_POST},
  5268. .ignore_suspend = 1,
  5269. .ignore_pmdown_time = 1,
  5270. /* this dainlink has playback support */
  5271. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5272. SND_SOC_DAILINK_REG(multimedia15),
  5273. },
  5274. {/* hw:x,29 */
  5275. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5276. .stream_name = "MM_NOIRQ_2",
  5277. .dynamic = 1,
  5278. .dpcm_playback = 1,
  5279. .dpcm_capture = 1,
  5280. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5281. SND_SOC_DPCM_TRIGGER_POST},
  5282. .ignore_suspend = 1,
  5283. .ignore_pmdown_time = 1,
  5284. /* this dainlink has playback support */
  5285. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5286. .ops = &msm_fe_qos_ops,
  5287. SND_SOC_DAILINK_REG(multimedia16),
  5288. },
  5289. {/* hw:x,30 */
  5290. .name = "CDC_DMA Hostless",
  5291. .stream_name = "CDC_DMA Hostless",
  5292. .dynamic = 1,
  5293. .dpcm_playback = 1,
  5294. .dpcm_capture = 1,
  5295. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5296. SND_SOC_DPCM_TRIGGER_POST},
  5297. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5298. .ignore_suspend = 1,
  5299. /* this dailink has playback support */
  5300. .ignore_pmdown_time = 1,
  5301. SND_SOC_DAILINK_REG(cdcdma_hostless),
  5302. },
  5303. {/* hw:x,31 */
  5304. .name = "TX3_CDC_DMA Hostless",
  5305. .stream_name = "TX3_CDC_DMA Hostless",
  5306. .dynamic = 1,
  5307. .dpcm_capture = 1,
  5308. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5309. SND_SOC_DPCM_TRIGGER_POST},
  5310. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5311. .ignore_suspend = 1,
  5312. SND_SOC_DAILINK_REG(tx3_cdcdma_hostless),
  5313. },
  5314. {/* hw:x,32 */
  5315. .name = "Tertiary MI2S TX_Hostless",
  5316. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5317. .dynamic = 1,
  5318. .dpcm_capture = 1,
  5319. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5320. SND_SOC_DPCM_TRIGGER_POST},
  5321. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5322. .ignore_suspend = 1,
  5323. .ignore_pmdown_time = 1,
  5324. SND_SOC_DAILINK_REG(tert_mi2s_tx_hostless),
  5325. },
  5326. };
  5327. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5328. {/* hw:x,33 */
  5329. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5330. .stream_name = "WSA CDC DMA0 Capture",
  5331. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5332. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5333. .ignore_suspend = 1,
  5334. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5335. .ops = &msm_cdc_dma_be_ops,
  5336. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture),
  5337. },
  5338. };
  5339. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5340. {/* hw:x,34 */
  5341. .name = MSM_DAILINK_NAME(ASM Loopback),
  5342. .stream_name = "MultiMedia6",
  5343. .dynamic = 1,
  5344. .dpcm_playback = 1,
  5345. .dpcm_capture = 1,
  5346. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5347. SND_SOC_DPCM_TRIGGER_POST},
  5348. .ignore_suspend = 1,
  5349. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5350. .ignore_pmdown_time = 1,
  5351. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5352. SND_SOC_DAILINK_REG(multimedia6),
  5353. },
  5354. {/* hw:x,35 */
  5355. .name = "USB Audio Hostless",
  5356. .stream_name = "USB Audio Hostless",
  5357. .dynamic = 1,
  5358. .dpcm_playback = 1,
  5359. .dpcm_capture = 1,
  5360. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5361. SND_SOC_DPCM_TRIGGER_POST},
  5362. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5363. .ignore_suspend = 1,
  5364. .ignore_pmdown_time = 1,
  5365. SND_SOC_DAILINK_REG(usbaudio_hostless),
  5366. },
  5367. {/* hw:x,36 */
  5368. .name = "SLIMBUS_7 Hostless",
  5369. .stream_name = "SLIMBUS_7 Hostless",
  5370. .dynamic = 1,
  5371. .dpcm_capture = 1,
  5372. .dpcm_playback = 1,
  5373. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5374. SND_SOC_DPCM_TRIGGER_POST},
  5375. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5376. .ignore_suspend = 1,
  5377. .ignore_pmdown_time = 1,
  5378. SND_SOC_DAILINK_REG(slimbus7_hostless),
  5379. },
  5380. {/* hw:x,37 */
  5381. .name = "Compress Capture",
  5382. .stream_name = "Compress9",
  5383. .dynamic = 1,
  5384. .dpcm_capture = 1,
  5385. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5386. SND_SOC_DPCM_TRIGGER_POST},
  5387. .ignore_suspend = 1,
  5388. .ignore_pmdown_time = 1,
  5389. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5390. SND_SOC_DAILINK_REG(multimedia17),
  5391. },
  5392. {/* hw:x,38 */
  5393. .name = "SLIMBUS_8 Hostless",
  5394. .stream_name = "SLIMBUS_8 Hostless",
  5395. .dynamic = 1,
  5396. .dpcm_capture = 1,
  5397. .dpcm_playback = 1,
  5398. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5399. SND_SOC_DPCM_TRIGGER_POST},
  5400. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5401. .ignore_suspend = 1,
  5402. .ignore_pmdown_time = 1,
  5403. SND_SOC_DAILINK_REG(slimbus8_hostless),
  5404. },
  5405. {/* hw:x,39 */
  5406. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5407. .stream_name = "TX CDC DMA5 Capture",
  5408. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5409. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5410. .ignore_suspend = 1,
  5411. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5412. .ops = &msm_cdc_dma_be_ops,
  5413. SND_SOC_DAILINK_REG(tx_cdcdma5_tx),
  5414. },
  5415. {/* hw:x,40 */
  5416. .name = MSM_DAILINK_NAME(Media31),
  5417. .stream_name = "MultiMedia31",
  5418. .dynamic = 1,
  5419. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5420. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5421. #endif /* CONFIG_AUDIO_QGKI */
  5422. .dpcm_playback = 1,
  5423. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5424. SND_SOC_DPCM_TRIGGER_POST},
  5425. .ignore_suspend = 1,
  5426. /* this dainlink has playback support */
  5427. .ignore_pmdown_time = 1,
  5428. .id = MSM_FRONTEND_DAI_MULTIMEDIA31,
  5429. SND_SOC_DAILINK_REG(multimedia31),
  5430. },
  5431. {/* hw:x,41 */
  5432. .name = MSM_DAILINK_NAME(Media32),
  5433. .stream_name = "MultiMedia32",
  5434. .dynamic = 1,
  5435. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5436. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5437. #endif /* CONFIG_AUDIO_QGKI */
  5438. .dpcm_playback = 1,
  5439. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5440. SND_SOC_DPCM_TRIGGER_POST},
  5441. .ignore_suspend = 1,
  5442. /* this dainlink has playback support */
  5443. .ignore_pmdown_time = 1,
  5444. .id = MSM_FRONTEND_DAI_MULTIMEDIA32,
  5445. SND_SOC_DAILINK_REG(multimedia32),
  5446. },
  5447. {/* hw:x,42 */
  5448. .name = "MSM AFE-PCM TX1",
  5449. .stream_name = "AFE-PROXY TX1",
  5450. .dpcm_capture = 1,
  5451. .ignore_suspend = 1,
  5452. SND_SOC_DAILINK_REG(afepcm_tx1),
  5453. },
  5454. };
  5455. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5456. /* Backend AFE DAI Links */
  5457. {
  5458. .name = LPASS_BE_AFE_PCM_RX,
  5459. .stream_name = "AFE Playback",
  5460. .no_pcm = 1,
  5461. .dpcm_playback = 1,
  5462. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5463. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5464. /* this dainlink has playback support */
  5465. .ignore_pmdown_time = 1,
  5466. .ignore_suspend = 1,
  5467. SND_SOC_DAILINK_REG(afe_pcm_rx),
  5468. },
  5469. {
  5470. .name = LPASS_BE_AFE_PCM_TX,
  5471. .stream_name = "AFE Capture",
  5472. .no_pcm = 1,
  5473. .dpcm_capture = 1,
  5474. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5475. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5476. .ignore_suspend = 1,
  5477. SND_SOC_DAILINK_REG(afe_pcm_tx),
  5478. },
  5479. /* Incall Record Uplink BACK END DAI Link */
  5480. {
  5481. .name = LPASS_BE_INCALL_RECORD_TX,
  5482. .stream_name = "Voice Uplink Capture",
  5483. .no_pcm = 1,
  5484. .dpcm_capture = 1,
  5485. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5486. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5487. .ignore_suspend = 1,
  5488. SND_SOC_DAILINK_REG(incall_record_tx),
  5489. },
  5490. /* Incall Record Downlink BACK END DAI Link */
  5491. {
  5492. .name = LPASS_BE_INCALL_RECORD_RX,
  5493. .stream_name = "Voice Downlink Capture",
  5494. .no_pcm = 1,
  5495. .dpcm_capture = 1,
  5496. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5497. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5498. .ignore_suspend = 1,
  5499. SND_SOC_DAILINK_REG(incall_record_rx),
  5500. },
  5501. /* Incall Music BACK END DAI Link */
  5502. {
  5503. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5504. .stream_name = "Voice Farend Playback",
  5505. .no_pcm = 1,
  5506. .dpcm_playback = 1,
  5507. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5508. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5509. .ignore_suspend = 1,
  5510. .ignore_pmdown_time = 1,
  5511. SND_SOC_DAILINK_REG(voice_playback_tx),
  5512. },
  5513. /* Incall Music 2 BACK END DAI Link */
  5514. {
  5515. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5516. .stream_name = "Voice2 Farend Playback",
  5517. .no_pcm = 1,
  5518. .dpcm_playback = 1,
  5519. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5520. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5521. .ignore_suspend = 1,
  5522. .ignore_pmdown_time = 1,
  5523. SND_SOC_DAILINK_REG(voice2_playback_tx),
  5524. },
  5525. /* Proxy Tx BACK END DAI Link */
  5526. {
  5527. .name = LPASS_BE_PROXY_TX,
  5528. .stream_name = "Proxy Capture",
  5529. .no_pcm = 1,
  5530. .dpcm_capture = 1,
  5531. .id = MSM_BACKEND_DAI_PROXY_TX,
  5532. .ignore_suspend = 1,
  5533. SND_SOC_DAILINK_REG(proxy_tx),
  5534. },
  5535. /* Proxy Rx BACK END DAI Link */
  5536. {
  5537. .name = LPASS_BE_PROXY_RX,
  5538. .stream_name = "Proxy Playback",
  5539. .no_pcm = 1,
  5540. .dpcm_playback = 1,
  5541. .id = MSM_BACKEND_DAI_PROXY_RX,
  5542. .ignore_pmdown_time = 1,
  5543. .ignore_suspend = 1,
  5544. SND_SOC_DAILINK_REG(proxy_rx),
  5545. },
  5546. {
  5547. .name = LPASS_BE_USB_AUDIO_RX,
  5548. .stream_name = "USB Audio Playback",
  5549. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5550. .dynamic_be = 1,
  5551. #endif /* CONFIG_AUDIO_QGKI */
  5552. .no_pcm = 1,
  5553. .dpcm_playback = 1,
  5554. .id = MSM_BACKEND_DAI_USB_RX,
  5555. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5556. .ignore_pmdown_time = 1,
  5557. .ignore_suspend = 1,
  5558. SND_SOC_DAILINK_REG(usb_audio_rx),
  5559. },
  5560. {
  5561. .name = LPASS_BE_USB_AUDIO_TX,
  5562. .stream_name = "USB Audio Capture",
  5563. .no_pcm = 1,
  5564. .dpcm_capture = 1,
  5565. .id = MSM_BACKEND_DAI_USB_TX,
  5566. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5567. .ignore_suspend = 1,
  5568. SND_SOC_DAILINK_REG(usb_audio_tx),
  5569. },
  5570. {
  5571. .name = LPASS_BE_PRI_TDM_RX_0,
  5572. .stream_name = "Primary TDM0 Playback",
  5573. .no_pcm = 1,
  5574. .dpcm_playback = 1,
  5575. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5576. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5577. .ops = &lahaina_tdm_be_ops,
  5578. .ignore_suspend = 1,
  5579. .ignore_pmdown_time = 1,
  5580. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  5581. },
  5582. {
  5583. .name = LPASS_BE_PRI_TDM_TX_0,
  5584. .stream_name = "Primary TDM0 Capture",
  5585. .no_pcm = 1,
  5586. .dpcm_capture = 1,
  5587. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5588. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5589. .ops = &lahaina_tdm_be_ops,
  5590. .ignore_suspend = 1,
  5591. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  5592. },
  5593. {
  5594. .name = LPASS_BE_SEC_TDM_RX_0,
  5595. .stream_name = "Secondary TDM0 Playback",
  5596. .no_pcm = 1,
  5597. .dpcm_playback = 1,
  5598. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5599. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5600. .ops = &lahaina_tdm_be_ops,
  5601. .ignore_suspend = 1,
  5602. .ignore_pmdown_time = 1,
  5603. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  5604. },
  5605. {
  5606. .name = LPASS_BE_SEC_TDM_TX_0,
  5607. .stream_name = "Secondary TDM0 Capture",
  5608. .no_pcm = 1,
  5609. .dpcm_capture = 1,
  5610. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5611. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5612. .ops = &lahaina_tdm_be_ops,
  5613. .ignore_suspend = 1,
  5614. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  5615. },
  5616. {
  5617. .name = LPASS_BE_TERT_TDM_RX_0,
  5618. .stream_name = "Tertiary TDM0 Playback",
  5619. .no_pcm = 1,
  5620. .dpcm_playback = 1,
  5621. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5622. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5623. .ops = &lahaina_tdm_be_ops,
  5624. .ignore_suspend = 1,
  5625. .ignore_pmdown_time = 1,
  5626. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  5627. },
  5628. {
  5629. .name = LPASS_BE_TERT_TDM_TX_0,
  5630. .stream_name = "Tertiary TDM0 Capture",
  5631. .no_pcm = 1,
  5632. .dpcm_capture = 1,
  5633. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5634. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5635. .ops = &lahaina_tdm_be_ops,
  5636. .ignore_suspend = 1,
  5637. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  5638. },
  5639. {
  5640. .name = LPASS_BE_QUAT_TDM_RX_0,
  5641. .stream_name = "Quaternary TDM0 Playback",
  5642. .no_pcm = 1,
  5643. .dpcm_playback = 1,
  5644. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5645. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5646. .ops = &lahaina_tdm_be_ops,
  5647. .ignore_suspend = 1,
  5648. .ignore_pmdown_time = 1,
  5649. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  5650. },
  5651. {
  5652. .name = LPASS_BE_QUAT_TDM_TX_0,
  5653. .stream_name = "Quaternary TDM0 Capture",
  5654. .no_pcm = 1,
  5655. .dpcm_capture = 1,
  5656. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5657. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5658. .ops = &lahaina_tdm_be_ops,
  5659. .ignore_suspend = 1,
  5660. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  5661. },
  5662. {
  5663. .name = LPASS_BE_QUIN_TDM_RX_0,
  5664. .stream_name = "Quinary TDM0 Playback",
  5665. .no_pcm = 1,
  5666. .dpcm_playback = 1,
  5667. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5668. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5669. .ops = &lahaina_tdm_be_ops,
  5670. .ignore_suspend = 1,
  5671. .ignore_pmdown_time = 1,
  5672. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  5673. },
  5674. {
  5675. .name = LPASS_BE_QUIN_TDM_TX_0,
  5676. .stream_name = "Quinary TDM0 Capture",
  5677. .no_pcm = 1,
  5678. .dpcm_capture = 1,
  5679. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5680. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5681. .ops = &lahaina_tdm_be_ops,
  5682. .ignore_suspend = 1,
  5683. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  5684. },
  5685. {
  5686. .name = LPASS_BE_SEN_TDM_RX_0,
  5687. .stream_name = "Senary TDM0 Playback",
  5688. .no_pcm = 1,
  5689. .dpcm_playback = 1,
  5690. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5691. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5692. .ops = &lahaina_tdm_be_ops,
  5693. .ignore_suspend = 1,
  5694. .ignore_pmdown_time = 1,
  5695. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  5696. },
  5697. {
  5698. .name = LPASS_BE_SEN_TDM_TX_0,
  5699. .stream_name = "Senary TDM0 Capture",
  5700. .no_pcm = 1,
  5701. .dpcm_capture = 1,
  5702. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5703. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5704. .ops = &lahaina_tdm_be_ops,
  5705. .ignore_suspend = 1,
  5706. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  5707. },
  5708. };
  5709. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5710. {
  5711. .name = LPASS_BE_SLIMBUS_7_RX,
  5712. .stream_name = "Slimbus7 Playback",
  5713. .no_pcm = 1,
  5714. .dpcm_playback = 1,
  5715. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5716. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5717. .init = &msm_wcn_init,
  5718. .ops = &msm_wcn_ops,
  5719. /* dai link has playback support */
  5720. .ignore_pmdown_time = 1,
  5721. .ignore_suspend = 1,
  5722. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5723. },
  5724. {
  5725. .name = LPASS_BE_SLIMBUS_7_TX,
  5726. .stream_name = "Slimbus7 Capture",
  5727. .no_pcm = 1,
  5728. .dpcm_capture = 1,
  5729. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5730. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5731. .ops = &msm_wcn_ops,
  5732. .ignore_suspend = 1,
  5733. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5734. },
  5735. };
  5736. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5737. {
  5738. .name = LPASS_BE_SLIMBUS_7_RX,
  5739. .stream_name = "Slimbus7 Playback",
  5740. .no_pcm = 1,
  5741. .dpcm_playback = 1,
  5742. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5743. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5744. .init = &msm_wcn_init_lito,
  5745. .ops = &msm_wcn_ops_lito,
  5746. /* dai link has playback support */
  5747. .ignore_pmdown_time = 1,
  5748. .ignore_suspend = 1,
  5749. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5750. },
  5751. {
  5752. .name = LPASS_BE_SLIMBUS_7_TX,
  5753. .stream_name = "Slimbus7 Capture",
  5754. .no_pcm = 1,
  5755. .dpcm_capture = 1,
  5756. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5757. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5758. .ops = &msm_wcn_ops_lito,
  5759. .ignore_suspend = 1,
  5760. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5761. },
  5762. {
  5763. .name = LPASS_BE_SLIMBUS_8_TX,
  5764. .stream_name = "Slimbus8 Capture",
  5765. .no_pcm = 1,
  5766. .dpcm_capture = 1,
  5767. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5768. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5769. .ops = &msm_wcn_ops_lito,
  5770. .ignore_suspend = 1,
  5771. SND_SOC_DAILINK_REG(slimbus_8_tx),
  5772. },
  5773. };
  5774. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5775. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  5776. /* DISP PORT BACK END DAI Link */
  5777. {
  5778. .name = LPASS_BE_DISPLAY_PORT,
  5779. .stream_name = "Display Port Playback",
  5780. .no_pcm = 1,
  5781. .dpcm_playback = 1,
  5782. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  5783. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5784. .ignore_pmdown_time = 1,
  5785. .ignore_suspend = 1,
  5786. SND_SOC_DAILINK_REG(display_port),
  5787. },
  5788. /* DISP PORT 1 BACK END DAI Link */
  5789. {
  5790. .name = LPASS_BE_DISPLAY_PORT1,
  5791. .stream_name = "Display Port1 Playback",
  5792. .no_pcm = 1,
  5793. .dpcm_playback = 1,
  5794. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  5795. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5796. .ignore_pmdown_time = 1,
  5797. .ignore_suspend = 1,
  5798. SND_SOC_DAILINK_REG(display_port1),
  5799. },
  5800. };
  5801. #endif
  5802. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  5803. {
  5804. .name = LPASS_BE_PRI_MI2S_RX,
  5805. .stream_name = "Primary MI2S Playback",
  5806. .no_pcm = 1,
  5807. .dpcm_playback = 1,
  5808. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  5809. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5810. .ops = &msm_mi2s_be_ops,
  5811. .ignore_suspend = 1,
  5812. .ignore_pmdown_time = 1,
  5813. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  5814. },
  5815. {
  5816. .name = LPASS_BE_PRI_MI2S_TX,
  5817. .stream_name = "Primary MI2S Capture",
  5818. .no_pcm = 1,
  5819. .dpcm_capture = 1,
  5820. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  5821. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5822. .ops = &msm_mi2s_be_ops,
  5823. .ignore_suspend = 1,
  5824. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  5825. },
  5826. {
  5827. .name = LPASS_BE_SEC_MI2S_RX,
  5828. .stream_name = "Secondary MI2S Playback",
  5829. .no_pcm = 1,
  5830. .dpcm_playback = 1,
  5831. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  5832. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5833. .ops = &msm_mi2s_be_ops,
  5834. .ignore_suspend = 1,
  5835. .ignore_pmdown_time = 1,
  5836. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  5837. },
  5838. {
  5839. .name = LPASS_BE_SEC_MI2S_TX,
  5840. .stream_name = "Secondary MI2S Capture",
  5841. .no_pcm = 1,
  5842. .dpcm_capture = 1,
  5843. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  5844. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5845. .ops = &msm_mi2s_be_ops,
  5846. .ignore_suspend = 1,
  5847. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  5848. },
  5849. {
  5850. .name = LPASS_BE_TERT_MI2S_RX,
  5851. .stream_name = "Tertiary MI2S Playback",
  5852. .no_pcm = 1,
  5853. .dpcm_playback = 1,
  5854. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  5855. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5856. .ops = &msm_mi2s_be_ops,
  5857. .ignore_suspend = 1,
  5858. .ignore_pmdown_time = 1,
  5859. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  5860. },
  5861. {
  5862. .name = LPASS_BE_TERT_MI2S_TX,
  5863. .stream_name = "Tertiary MI2S Capture",
  5864. .no_pcm = 1,
  5865. .dpcm_capture = 1,
  5866. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  5867. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5868. .ops = &msm_mi2s_be_ops,
  5869. .ignore_suspend = 1,
  5870. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  5871. },
  5872. {
  5873. .name = LPASS_BE_QUAT_MI2S_RX,
  5874. .stream_name = "Quaternary MI2S Playback",
  5875. .no_pcm = 1,
  5876. .dpcm_playback = 1,
  5877. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  5878. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5879. .ops = &msm_mi2s_be_ops,
  5880. .ignore_suspend = 1,
  5881. .ignore_pmdown_time = 1,
  5882. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  5883. },
  5884. {
  5885. .name = LPASS_BE_QUAT_MI2S_TX,
  5886. .stream_name = "Quaternary MI2S Capture",
  5887. .no_pcm = 1,
  5888. .dpcm_capture = 1,
  5889. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  5890. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5891. .ops = &msm_mi2s_be_ops,
  5892. .ignore_suspend = 1,
  5893. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  5894. },
  5895. {
  5896. .name = LPASS_BE_QUIN_MI2S_RX,
  5897. .stream_name = "Quinary MI2S Playback",
  5898. .no_pcm = 1,
  5899. .dpcm_playback = 1,
  5900. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  5901. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5902. .ops = &msm_mi2s_be_ops,
  5903. .ignore_suspend = 1,
  5904. .ignore_pmdown_time = 1,
  5905. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  5906. },
  5907. {
  5908. .name = LPASS_BE_QUIN_MI2S_TX,
  5909. .stream_name = "Quinary MI2S Capture",
  5910. .no_pcm = 1,
  5911. .dpcm_capture = 1,
  5912. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  5913. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5914. .ops = &msm_mi2s_be_ops,
  5915. .ignore_suspend = 1,
  5916. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  5917. },
  5918. {
  5919. .name = LPASS_BE_SENARY_MI2S_RX,
  5920. .stream_name = "Senary MI2S Playback",
  5921. .no_pcm = 1,
  5922. .dpcm_playback = 1,
  5923. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  5924. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5925. .ops = &msm_mi2s_be_ops,
  5926. .ignore_suspend = 1,
  5927. .ignore_pmdown_time = 1,
  5928. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  5929. },
  5930. {
  5931. .name = LPASS_BE_SENARY_MI2S_TX,
  5932. .stream_name = "Senary MI2S Capture",
  5933. .no_pcm = 1,
  5934. .dpcm_capture = 1,
  5935. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  5936. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5937. .ops = &msm_mi2s_be_ops,
  5938. .ignore_suspend = 1,
  5939. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  5940. },
  5941. };
  5942. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  5943. /* Primary AUX PCM Backend DAI Links */
  5944. {
  5945. .name = LPASS_BE_AUXPCM_RX,
  5946. .stream_name = "AUX PCM Playback",
  5947. .no_pcm = 1,
  5948. .dpcm_playback = 1,
  5949. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  5950. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5951. .ops = &lahaina_aux_be_ops,
  5952. .ignore_pmdown_time = 1,
  5953. .ignore_suspend = 1,
  5954. SND_SOC_DAILINK_REG(auxpcm_rx),
  5955. },
  5956. {
  5957. .name = LPASS_BE_AUXPCM_TX,
  5958. .stream_name = "AUX PCM Capture",
  5959. .no_pcm = 1,
  5960. .dpcm_capture = 1,
  5961. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  5962. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5963. .ops = &lahaina_aux_be_ops,
  5964. .ignore_suspend = 1,
  5965. SND_SOC_DAILINK_REG(auxpcm_tx),
  5966. },
  5967. /* Secondary AUX PCM Backend DAI Links */
  5968. {
  5969. .name = LPASS_BE_SEC_AUXPCM_RX,
  5970. .stream_name = "Sec AUX PCM Playback",
  5971. .no_pcm = 1,
  5972. .dpcm_playback = 1,
  5973. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  5974. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5975. .ops = &lahaina_aux_be_ops,
  5976. .ignore_pmdown_time = 1,
  5977. .ignore_suspend = 1,
  5978. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  5979. },
  5980. {
  5981. .name = LPASS_BE_SEC_AUXPCM_TX,
  5982. .stream_name = "Sec AUX PCM Capture",
  5983. .no_pcm = 1,
  5984. .dpcm_capture = 1,
  5985. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  5986. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5987. .ops = &lahaina_aux_be_ops,
  5988. .ignore_suspend = 1,
  5989. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  5990. },
  5991. /* Tertiary AUX PCM Backend DAI Links */
  5992. {
  5993. .name = LPASS_BE_TERT_AUXPCM_RX,
  5994. .stream_name = "Tert AUX PCM Playback",
  5995. .no_pcm = 1,
  5996. .dpcm_playback = 1,
  5997. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  5998. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5999. .ops = &lahaina_aux_be_ops,
  6000. .ignore_suspend = 1,
  6001. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  6002. },
  6003. {
  6004. .name = LPASS_BE_TERT_AUXPCM_TX,
  6005. .stream_name = "Tert AUX PCM Capture",
  6006. .no_pcm = 1,
  6007. .dpcm_capture = 1,
  6008. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  6009. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6010. .ops = &lahaina_aux_be_ops,
  6011. .ignore_suspend = 1,
  6012. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  6013. },
  6014. /* Quaternary AUX PCM Backend DAI Links */
  6015. {
  6016. .name = LPASS_BE_QUAT_AUXPCM_RX,
  6017. .stream_name = "Quat AUX PCM Playback",
  6018. .no_pcm = 1,
  6019. .dpcm_playback = 1,
  6020. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  6021. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6022. .ops = &lahaina_aux_be_ops,
  6023. .ignore_suspend = 1,
  6024. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  6025. },
  6026. {
  6027. .name = LPASS_BE_QUAT_AUXPCM_TX,
  6028. .stream_name = "Quat AUX PCM Capture",
  6029. .no_pcm = 1,
  6030. .dpcm_capture = 1,
  6031. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  6032. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6033. .ops = &lahaina_aux_be_ops,
  6034. .ignore_suspend = 1,
  6035. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  6036. },
  6037. /* Quinary AUX PCM Backend DAI Links */
  6038. {
  6039. .name = LPASS_BE_QUIN_AUXPCM_RX,
  6040. .stream_name = "Quin AUX PCM Playback",
  6041. .no_pcm = 1,
  6042. .dpcm_playback = 1,
  6043. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  6044. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6045. .ops = &lahaina_aux_be_ops,
  6046. .ignore_suspend = 1,
  6047. SND_SOC_DAILINK_REG(quin_auxpcm_rx),
  6048. },
  6049. {
  6050. .name = LPASS_BE_QUIN_AUXPCM_TX,
  6051. .stream_name = "Quin AUX PCM Capture",
  6052. .no_pcm = 1,
  6053. .dpcm_capture = 1,
  6054. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  6055. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6056. .ops = &lahaina_aux_be_ops,
  6057. .ignore_suspend = 1,
  6058. SND_SOC_DAILINK_REG(quin_auxpcm_tx),
  6059. },
  6060. /* Senary AUX PCM Backend DAI Links */
  6061. {
  6062. .name = LPASS_BE_SEN_AUXPCM_RX,
  6063. .stream_name = "Sen AUX PCM Playback",
  6064. .no_pcm = 1,
  6065. .dpcm_playback = 1,
  6066. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  6067. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6068. .ops = &lahaina_aux_be_ops,
  6069. .ignore_suspend = 1,
  6070. SND_SOC_DAILINK_REG(sen_auxpcm_rx),
  6071. },
  6072. {
  6073. .name = LPASS_BE_SEN_AUXPCM_TX,
  6074. .stream_name = "Sen AUX PCM Capture",
  6075. .no_pcm = 1,
  6076. .dpcm_capture = 1,
  6077. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  6078. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6079. .ops = &lahaina_aux_be_ops,
  6080. .ignore_suspend = 1,
  6081. SND_SOC_DAILINK_REG(sen_auxpcm_tx),
  6082. },
  6083. };
  6084. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  6085. /* WSA CDC DMA Backend DAI Links */
  6086. {
  6087. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  6088. .stream_name = "WSA CDC DMA0 Playback",
  6089. .no_pcm = 1,
  6090. .dpcm_playback = 1,
  6091. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  6092. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6093. .ignore_pmdown_time = 1,
  6094. .ignore_suspend = 1,
  6095. .ops = &msm_cdc_dma_be_ops,
  6096. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  6097. .init = &msm_int_audrx_init,
  6098. },
  6099. {
  6100. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  6101. .stream_name = "WSA CDC DMA1 Playback",
  6102. .no_pcm = 1,
  6103. .dpcm_playback = 1,
  6104. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  6105. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6106. .ignore_pmdown_time = 1,
  6107. .ignore_suspend = 1,
  6108. .ops = &msm_cdc_dma_be_ops,
  6109. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  6110. },
  6111. {
  6112. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  6113. .stream_name = "WSA CDC DMA1 Capture",
  6114. .no_pcm = 1,
  6115. .dpcm_capture = 1,
  6116. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  6117. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6118. .ignore_suspend = 1,
  6119. .ops = &msm_cdc_dma_be_ops,
  6120. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  6121. },
  6122. };
  6123. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6124. /* RX CDC DMA Backend DAI Links */
  6125. {
  6126. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6127. .stream_name = "RX CDC DMA0 Playback",
  6128. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6129. .dynamic_be = 1,
  6130. #endif /* CONFIG_AUDIO_QGKI */
  6131. .no_pcm = 1,
  6132. .dpcm_playback = 1,
  6133. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6134. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6135. .ignore_pmdown_time = 1,
  6136. .ignore_suspend = 1,
  6137. .ops = &msm_cdc_dma_be_ops,
  6138. SND_SOC_DAILINK_REG(rx_dma_rx0),
  6139. .init = &msm_aux_codec_init,
  6140. },
  6141. {
  6142. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6143. .stream_name = "RX CDC DMA1 Playback",
  6144. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6145. .dynamic_be = 1,
  6146. #endif /* CONFIG_AUDIO_QGKI */
  6147. .no_pcm = 1,
  6148. .dpcm_playback = 1,
  6149. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6150. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6151. .ignore_pmdown_time = 1,
  6152. .ignore_suspend = 1,
  6153. .ops = &msm_cdc_dma_be_ops,
  6154. SND_SOC_DAILINK_REG(rx_dma_rx1),
  6155. },
  6156. {
  6157. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6158. .stream_name = "RX CDC DMA2 Playback",
  6159. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6160. .dynamic_be = 1,
  6161. #endif /* CONFIG_AUDIO_QGKI */
  6162. .no_pcm = 1,
  6163. .dpcm_playback = 1,
  6164. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6165. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6166. .ignore_pmdown_time = 1,
  6167. .ignore_suspend = 1,
  6168. .ops = &msm_cdc_dma_be_ops,
  6169. SND_SOC_DAILINK_REG(rx_dma_rx2),
  6170. },
  6171. {
  6172. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6173. .stream_name = "RX CDC DMA3 Playback",
  6174. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6175. .dynamic_be = 1,
  6176. #endif /* CONFIG_AUDIO_QGKI */
  6177. .no_pcm = 1,
  6178. .dpcm_playback = 1,
  6179. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6180. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6181. .ignore_pmdown_time = 1,
  6182. .ignore_suspend = 1,
  6183. .ops = &msm_cdc_dma_be_ops,
  6184. SND_SOC_DAILINK_REG(rx_dma_rx3),
  6185. },
  6186. {
  6187. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  6188. .stream_name = "RX CDC DMA6 Playback",
  6189. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6190. .dynamic_be = 1,
  6191. #endif /* CONFIG_AUDIO_QGKI */
  6192. .no_pcm = 1,
  6193. .dpcm_playback = 1,
  6194. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_6,
  6195. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6196. .ignore_pmdown_time = 1,
  6197. .ignore_suspend = 1,
  6198. .ops = &msm_cdc_dma_be_ops,
  6199. SND_SOC_DAILINK_REG(rx_dma_rx6),
  6200. },
  6201. /* TX CDC DMA Backend DAI Links */
  6202. {
  6203. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6204. .stream_name = "TX CDC DMA3 Capture",
  6205. .no_pcm = 1,
  6206. .dpcm_capture = 1,
  6207. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6208. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6209. .ignore_suspend = 1,
  6210. .ops = &msm_cdc_dma_be_ops,
  6211. SND_SOC_DAILINK_REG(tx_dma_tx3),
  6212. },
  6213. {
  6214. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6215. .stream_name = "TX CDC DMA4 Capture",
  6216. .no_pcm = 1,
  6217. .dpcm_capture = 1,
  6218. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6219. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6220. .ignore_suspend = 1,
  6221. .ops = &msm_cdc_dma_be_ops,
  6222. SND_SOC_DAILINK_REG(tx_dma_tx4),
  6223. },
  6224. };
  6225. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6226. {
  6227. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6228. .stream_name = "VA CDC DMA0 Capture",
  6229. .no_pcm = 1,
  6230. .dpcm_capture = 1,
  6231. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6232. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6233. .ignore_suspend = 1,
  6234. .ops = &msm_cdc_dma_be_ops,
  6235. SND_SOC_DAILINK_REG(va_dma_tx0),
  6236. },
  6237. {
  6238. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6239. .stream_name = "VA CDC DMA1 Capture",
  6240. .no_pcm = 1,
  6241. .dpcm_capture = 1,
  6242. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6243. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6244. .ignore_suspend = 1,
  6245. .ops = &msm_cdc_dma_be_ops,
  6246. SND_SOC_DAILINK_REG(va_dma_tx1),
  6247. },
  6248. {
  6249. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6250. .stream_name = "VA CDC DMA2 Capture",
  6251. .no_pcm = 1,
  6252. .dpcm_capture = 1,
  6253. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6254. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6255. .ignore_suspend = 1,
  6256. .ops = &msm_cdc_dma_be_ops,
  6257. SND_SOC_DAILINK_REG(va_dma_tx2),
  6258. },
  6259. };
  6260. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6261. {
  6262. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6263. .stream_name = "AFE Loopback Capture",
  6264. .no_pcm = 1,
  6265. .dpcm_capture = 1,
  6266. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6267. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6268. .ignore_pmdown_time = 1,
  6269. .ignore_suspend = 1,
  6270. SND_SOC_DAILINK_REG(afe_loopback_tx),
  6271. },
  6272. };
  6273. static struct snd_soc_dai_link msm_lahaina_dai_links[
  6274. ARRAY_SIZE(msm_common_dai_links) +
  6275. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6276. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6277. ARRAY_SIZE(msm_common_be_dai_links) +
  6278. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6279. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6280. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6281. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6282. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6283. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6284. ARRAY_SIZE(ext_disp_be_dai_link) +
  6285. #endif
  6286. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6287. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6288. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6289. static int msm_populate_dai_link_component_of_node(
  6290. struct snd_soc_card *card)
  6291. {
  6292. int i, j, index, ret = 0;
  6293. struct device *cdev = card->dev;
  6294. struct snd_soc_dai_link *dai_link = card->dai_link;
  6295. struct device_node *np = NULL;
  6296. int codecs_enabled = 0;
  6297. struct snd_soc_dai_link_component *codecs_comp = NULL;
  6298. if (!cdev) {
  6299. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6300. return -ENODEV;
  6301. }
  6302. for (i = 0; i < card->num_links; i++) {
  6303. if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node)
  6304. continue;
  6305. /* populate platform_of_node for snd card dai links */
  6306. if (dai_link[i].platforms->name &&
  6307. !dai_link[i].platforms->of_node) {
  6308. index = of_property_match_string(cdev->of_node,
  6309. "asoc-platform-names",
  6310. dai_link[i].platforms->name);
  6311. if (index < 0) {
  6312. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6313. __func__, dai_link[i].platforms->name);
  6314. ret = index;
  6315. goto err;
  6316. }
  6317. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6318. index);
  6319. if (!np) {
  6320. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6321. __func__, dai_link[i].platforms->name,
  6322. index);
  6323. ret = -ENODEV;
  6324. goto err;
  6325. }
  6326. dai_link[i].platforms->of_node = np;
  6327. dai_link[i].platforms->name = NULL;
  6328. }
  6329. /* populate cpu_of_node for snd card dai links */
  6330. if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) {
  6331. index = of_property_match_string(cdev->of_node,
  6332. "asoc-cpu-names",
  6333. dai_link[i].cpus->dai_name);
  6334. if (index >= 0) {
  6335. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6336. index);
  6337. if (!np) {
  6338. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6339. __func__,
  6340. dai_link[i].cpus->dai_name);
  6341. ret = -ENODEV;
  6342. goto err;
  6343. }
  6344. dai_link[i].cpus->of_node = np;
  6345. dai_link[i].cpus->dai_name = NULL;
  6346. }
  6347. }
  6348. /* populate codec_of_node for snd card dai links */
  6349. if (dai_link[i].num_codecs > 0) {
  6350. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6351. if (dai_link[i].codecs[j].of_node ||
  6352. !dai_link[i].codecs[j].name)
  6353. continue;
  6354. index = of_property_match_string(cdev->of_node,
  6355. "asoc-codec-names",
  6356. dai_link[i].codecs[j].name);
  6357. if (index < 0)
  6358. continue;
  6359. np = of_parse_phandle(cdev->of_node,
  6360. "asoc-codec",
  6361. index);
  6362. if (!np) {
  6363. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6364. __func__,
  6365. dai_link[i].codecs[j].name);
  6366. ret = -ENODEV;
  6367. goto err;
  6368. }
  6369. dai_link[i].codecs[j].of_node = np;
  6370. dai_link[i].codecs[j].name = NULL;
  6371. }
  6372. }
  6373. }
  6374. /* In multi-codec scenario, check if codecs are enabled for this platform */
  6375. for (i = 0; i < card->num_links; i++) {
  6376. codecs_enabled = 0;
  6377. if (dai_link[i].num_codecs > 1) {
  6378. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6379. if (!dai_link[i].codecs[j].of_node)
  6380. continue;
  6381. np = dai_link[i].codecs[j].of_node;
  6382. if (!of_device_is_available(np)) {
  6383. dev_err(cdev, "%s: codec is disabled: %s\n",
  6384. __func__,
  6385. np->full_name);
  6386. dai_link[i].codecs[j].of_node = NULL;
  6387. continue;
  6388. }
  6389. codecs_enabled++;
  6390. }
  6391. if (codecs_enabled > 0 &&
  6392. codecs_enabled < dai_link[i].num_codecs) {
  6393. codecs_comp = devm_kzalloc(cdev,
  6394. sizeof(struct snd_soc_dai_link_component)
  6395. * codecs_enabled, GFP_KERNEL);
  6396. if (!codecs_comp) {
  6397. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  6398. __func__, dai_link[i].name);
  6399. ret = -ENOMEM;
  6400. goto err;
  6401. }
  6402. index = 0;
  6403. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6404. if(dai_link[i].codecs[j].of_node) {
  6405. codecs_comp[index].of_node =
  6406. dai_link[i].codecs[j].of_node;
  6407. codecs_comp[index].dai_name =
  6408. dai_link[i].codecs[j].dai_name;
  6409. codecs_comp[index].name = NULL;
  6410. index++;
  6411. }
  6412. }
  6413. dai_link[i].codecs = codecs_comp;
  6414. dai_link[i].num_codecs = codecs_enabled;
  6415. }
  6416. }
  6417. }
  6418. err:
  6419. return ret;
  6420. }
  6421. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6422. {
  6423. int ret = -EINVAL;
  6424. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6425. if (!component) {
  6426. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6427. return ret;
  6428. }
  6429. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6430. ARRAY_SIZE(msm_snd_controls));
  6431. if (ret < 0) {
  6432. dev_err(component->dev,
  6433. "%s: add_codec_controls failed, err = %d\n",
  6434. __func__, ret);
  6435. return ret;
  6436. }
  6437. return ret;
  6438. }
  6439. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6440. struct snd_pcm_hw_params *params)
  6441. {
  6442. return 0;
  6443. }
  6444. static struct snd_soc_ops msm_stub_be_ops = {
  6445. .hw_params = msm_snd_stub_hw_params,
  6446. };
  6447. struct snd_soc_card snd_soc_card_stub_msm = {
  6448. .name = "lahaina-stub-snd-card",
  6449. };
  6450. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6451. /* FrontEnd DAI Links */
  6452. {
  6453. .name = "MSMSTUB Media1",
  6454. .stream_name = "MultiMedia1",
  6455. .dynamic = 1,
  6456. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6457. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6458. #endif /* CONFIG_AUDIO_QGKI */
  6459. .dpcm_playback = 1,
  6460. .dpcm_capture = 1,
  6461. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6462. SND_SOC_DPCM_TRIGGER_POST},
  6463. .ignore_suspend = 1,
  6464. /* this dainlink has playback support */
  6465. .ignore_pmdown_time = 1,
  6466. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  6467. SND_SOC_DAILINK_REG(multimedia1),
  6468. },
  6469. };
  6470. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6471. /* Backend DAI Links */
  6472. {
  6473. .name = LPASS_BE_AUXPCM_RX,
  6474. .stream_name = "AUX PCM Playback",
  6475. .no_pcm = 1,
  6476. .dpcm_playback = 1,
  6477. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6478. .init = &msm_audrx_stub_init,
  6479. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6480. .ignore_pmdown_time = 1,
  6481. .ignore_suspend = 1,
  6482. .ops = &msm_stub_be_ops,
  6483. SND_SOC_DAILINK_REG(auxpcm_rx),
  6484. },
  6485. {
  6486. .name = LPASS_BE_AUXPCM_TX,
  6487. .stream_name = "AUX PCM Capture",
  6488. .no_pcm = 1,
  6489. .dpcm_capture = 1,
  6490. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6491. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6492. .ignore_suspend = 1,
  6493. .ops = &msm_stub_be_ops,
  6494. SND_SOC_DAILINK_REG(auxpcm_tx),
  6495. },
  6496. };
  6497. static struct snd_soc_dai_link msm_stub_dai_links[
  6498. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6499. ARRAY_SIZE(msm_stub_be_dai_links)];
  6500. static const struct of_device_id lahaina_asoc_machine_of_match[] = {
  6501. { .compatible = "qcom,lahaina-asoc-snd",
  6502. .data = "codec"},
  6503. { .compatible = "qcom,lahaina-asoc-snd-stub",
  6504. .data = "stub_codec"},
  6505. {},
  6506. };
  6507. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6508. {
  6509. struct snd_soc_card *card = NULL;
  6510. struct snd_soc_dai_link *dailink = NULL;
  6511. int len_1 = 0;
  6512. int len_2 = 0;
  6513. int total_links = 0;
  6514. int rc = 0;
  6515. u32 mi2s_audio_intf = 0;
  6516. u32 auxpcm_audio_intf = 0;
  6517. u32 val = 0;
  6518. u32 wcn_btfm_intf = 0;
  6519. const struct of_device_id *match;
  6520. match = of_match_node(lahaina_asoc_machine_of_match, dev->of_node);
  6521. if (!match) {
  6522. dev_err(dev, "%s: No DT match found for sound card\n",
  6523. __func__);
  6524. return NULL;
  6525. }
  6526. if (!strcmp(match->data, "codec")) {
  6527. card = &snd_soc_card_lahaina_msm;
  6528. memcpy(msm_lahaina_dai_links + total_links,
  6529. msm_common_dai_links,
  6530. sizeof(msm_common_dai_links));
  6531. total_links += ARRAY_SIZE(msm_common_dai_links);
  6532. memcpy(msm_lahaina_dai_links + total_links,
  6533. msm_bolero_fe_dai_links,
  6534. sizeof(msm_bolero_fe_dai_links));
  6535. total_links +=
  6536. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6537. memcpy(msm_lahaina_dai_links + total_links,
  6538. msm_common_misc_fe_dai_links,
  6539. sizeof(msm_common_misc_fe_dai_links));
  6540. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6541. memcpy(msm_lahaina_dai_links + total_links,
  6542. msm_common_be_dai_links,
  6543. sizeof(msm_common_be_dai_links));
  6544. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6545. memcpy(msm_lahaina_dai_links + total_links,
  6546. msm_rx_tx_cdc_dma_be_dai_links,
  6547. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6548. total_links +=
  6549. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6550. memcpy(msm_lahaina_dai_links + total_links,
  6551. msm_wsa_cdc_dma_be_dai_links,
  6552. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6553. total_links +=
  6554. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6555. memcpy(msm_lahaina_dai_links + total_links,
  6556. msm_va_cdc_dma_be_dai_links,
  6557. sizeof(msm_va_cdc_dma_be_dai_links));
  6558. total_links +=
  6559. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6560. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6561. &mi2s_audio_intf);
  6562. if (rc) {
  6563. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6564. __func__);
  6565. } else {
  6566. if (mi2s_audio_intf) {
  6567. memcpy(msm_lahaina_dai_links + total_links,
  6568. msm_mi2s_be_dai_links,
  6569. sizeof(msm_mi2s_be_dai_links));
  6570. total_links +=
  6571. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6572. }
  6573. }
  6574. rc = of_property_read_u32(dev->of_node,
  6575. "qcom,auxpcm-audio-intf",
  6576. &auxpcm_audio_intf);
  6577. if (rc) {
  6578. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6579. __func__);
  6580. } else {
  6581. if (auxpcm_audio_intf) {
  6582. memcpy(msm_lahaina_dai_links + total_links,
  6583. msm_auxpcm_be_dai_links,
  6584. sizeof(msm_auxpcm_be_dai_links));
  6585. total_links +=
  6586. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6587. }
  6588. }
  6589. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6590. rc = of_property_read_u32(dev->of_node,
  6591. "qcom,ext-disp-audio-rx", &val);
  6592. if (!rc && val) {
  6593. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6594. __func__);
  6595. memcpy(msm_lahaina_dai_links + total_links,
  6596. ext_disp_be_dai_link,
  6597. sizeof(ext_disp_be_dai_link));
  6598. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6599. }
  6600. #endif
  6601. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6602. if (!rc && val) {
  6603. dev_dbg(dev, "%s(): WCN BT support present\n",
  6604. __func__);
  6605. memcpy(msm_lahaina_dai_links + total_links,
  6606. msm_wcn_be_dai_links,
  6607. sizeof(msm_wcn_be_dai_links));
  6608. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6609. }
  6610. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6611. &val);
  6612. if (!rc && val) {
  6613. memcpy(msm_lahaina_dai_links + total_links,
  6614. msm_afe_rxtx_lb_be_dai_link,
  6615. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6616. total_links +=
  6617. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6618. }
  6619. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6620. &wcn_btfm_intf);
  6621. if (rc) {
  6622. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6623. __func__);
  6624. } else {
  6625. if (wcn_btfm_intf) {
  6626. memcpy(msm_lahaina_dai_links + total_links,
  6627. msm_wcn_btfm_be_dai_links,
  6628. sizeof(msm_wcn_btfm_be_dai_links));
  6629. total_links +=
  6630. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6631. }
  6632. }
  6633. dailink = msm_lahaina_dai_links;
  6634. } else if(!strcmp(match->data, "stub_codec")) {
  6635. card = &snd_soc_card_stub_msm;
  6636. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6637. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6638. memcpy(msm_stub_dai_links,
  6639. msm_stub_fe_dai_links,
  6640. sizeof(msm_stub_fe_dai_links));
  6641. memcpy(msm_stub_dai_links + len_1,
  6642. msm_stub_be_dai_links,
  6643. sizeof(msm_stub_be_dai_links));
  6644. dailink = msm_stub_dai_links;
  6645. total_links = len_2;
  6646. }
  6647. if (card) {
  6648. card->dai_link = dailink;
  6649. card->num_links = total_links;
  6650. }
  6651. return card;
  6652. }
  6653. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  6654. {
  6655. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6656. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6657. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6658. SPKR_L_BOOST, SPKR_L_VI};
  6659. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6660. SPKR_R_BOOST, SPKR_R_VI};
  6661. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  6662. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  6663. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6664. struct snd_soc_component *component = NULL;
  6665. struct snd_soc_dapm_context *dapm = NULL;
  6666. struct snd_card *card = NULL;
  6667. struct snd_info_entry *entry = NULL;
  6668. struct msm_asoc_mach_data *pdata =
  6669. snd_soc_card_get_drvdata(rtd->card);
  6670. int ret = 0;
  6671. if (pdata->wsa_max_devs > 0) {
  6672. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  6673. if (!component) {
  6674. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  6675. return -EINVAL;
  6676. }
  6677. dapm = snd_soc_component_get_dapm(component);
  6678. wsa883x_set_channel_map(component, &spkleft_ports[0],
  6679. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6680. &ch_rate[0], &spkleft_port_types[0]);
  6681. if (dapm->component) {
  6682. snd_soc_dapm_ignore_suspend(dapm, "spkrLeft IN");
  6683. snd_soc_dapm_ignore_suspend(dapm, "spkrLeft SPKR");
  6684. }
  6685. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  6686. component);
  6687. }
  6688. /* If current platform has more than one WSA */
  6689. if (pdata->wsa_max_devs > 1) {
  6690. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  6691. if (!component) {
  6692. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  6693. return -EINVAL;
  6694. }
  6695. dapm = snd_soc_component_get_dapm(component);
  6696. wsa883x_set_channel_map(component, &spkright_ports[0],
  6697. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6698. &ch_rate[0], &spkright_port_types[0]);
  6699. if (dapm->component) {
  6700. snd_soc_dapm_ignore_suspend(dapm, "spkrRight IN");
  6701. snd_soc_dapm_ignore_suspend(dapm, "spkrRight SPKR");
  6702. }
  6703. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  6704. component);
  6705. }
  6706. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  6707. if (!component) {
  6708. pr_err("%s: could not find component for bolero_codec\n",
  6709. __func__);
  6710. return ret;
  6711. }
  6712. dapm = snd_soc_component_get_dapm(component);
  6713. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  6714. ARRAY_SIZE(msm_int_snd_controls));
  6715. if (ret < 0) {
  6716. pr_err("%s: add_component_controls failed: %d\n",
  6717. __func__, ret);
  6718. return ret;
  6719. }
  6720. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  6721. ARRAY_SIZE(msm_common_snd_controls));
  6722. if (ret < 0) {
  6723. pr_err("%s: add common snd controls failed: %d\n",
  6724. __func__, ret);
  6725. return ret;
  6726. }
  6727. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  6728. ARRAY_SIZE(msm_int_dapm_widgets));
  6729. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  6730. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  6731. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  6732. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  6733. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  6734. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  6735. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  6736. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  6737. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  6738. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  6739. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  6740. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  6741. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  6742. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  6743. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  6744. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  6745. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  6746. snd_soc_dapm_sync(dapm);
  6747. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map), sm_port_map);
  6748. card = rtd->card->snd_card;
  6749. if (!pdata->codec_root) {
  6750. entry = msm_snd_info_create_subdir(card->module, "codecs",
  6751. card->proc_root);
  6752. if (!entry) {
  6753. pr_debug("%s: Cannot create codecs module entry\n",
  6754. __func__);
  6755. ret = 0;
  6756. goto err;
  6757. }
  6758. pdata->codec_root = entry;
  6759. }
  6760. bolero_info_create_codec_entry(pdata->codec_root, component);
  6761. bolero_register_wake_irq(component, false);
  6762. codec_reg_done = true;
  6763. err:
  6764. return ret;
  6765. }
  6766. static int msm_aux_codec_init(struct snd_soc_pcm_runtime *rtd)
  6767. {
  6768. struct snd_soc_component *component = NULL;
  6769. struct snd_soc_dapm_context *dapm = NULL;
  6770. int ret = 0;
  6771. int codec_variant = -1;
  6772. void *mbhc_calibration;
  6773. struct snd_info_entry *entry;
  6774. struct snd_card *card = NULL;
  6775. struct msm_asoc_mach_data *pdata;
  6776. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  6777. if (!component) {
  6778. pr_err("%s component is NULL\n", __func__);
  6779. return -EINVAL;
  6780. }
  6781. dapm = snd_soc_component_get_dapm(component);
  6782. card = component->card->snd_card;
  6783. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  6784. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  6785. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  6786. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  6787. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  6788. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  6789. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  6790. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  6791. snd_soc_dapm_sync(dapm);
  6792. pdata = snd_soc_card_get_drvdata(component->card);
  6793. if (!pdata->codec_root) {
  6794. entry = msm_snd_info_create_subdir(card->module, "codecs",
  6795. card->proc_root);
  6796. if (!entry) {
  6797. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  6798. __func__);
  6799. ret = 0;
  6800. goto mbhc_cfg_cal;
  6801. }
  6802. pdata->codec_root = entry;
  6803. }
  6804. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  6805. codec_variant = wcd938x_get_codec_variant(component);
  6806. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  6807. if (codec_variant == WCD9380)
  6808. ret = snd_soc_add_component_controls(component,
  6809. msm_int_wcd9380_snd_controls,
  6810. ARRAY_SIZE(msm_int_wcd9380_snd_controls));
  6811. else if (codec_variant == WCD9385)
  6812. ret = snd_soc_add_component_controls(component,
  6813. msm_int_wcd9385_snd_controls,
  6814. ARRAY_SIZE(msm_int_wcd9385_snd_controls));
  6815. if (ret < 0) {
  6816. dev_err(component->dev, "%s: add codec specific snd controls failed: %d\n",
  6817. __func__, ret);
  6818. return ret;
  6819. }
  6820. mbhc_cfg_cal:
  6821. mbhc_calibration = def_wcd_mbhc_cal();
  6822. if (!mbhc_calibration)
  6823. return -ENOMEM;
  6824. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6825. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6826. if (ret) {
  6827. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6828. __func__, ret);
  6829. goto err_hs_detect;
  6830. }
  6831. return 0;
  6832. err_hs_detect:
  6833. kfree(mbhc_calibration);
  6834. return ret;
  6835. }
  6836. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  6837. {
  6838. int count = 0;
  6839. u32 mi2s_master_slave[MI2S_MAX];
  6840. int ret = 0;
  6841. for (count = 0; count < MI2S_MAX; count++) {
  6842. mutex_init(&mi2s_intf_conf[count].lock);
  6843. mi2s_intf_conf[count].ref_cnt = 0;
  6844. }
  6845. ret = of_property_read_u32_array(pdev->dev.of_node,
  6846. "qcom,msm-mi2s-master",
  6847. mi2s_master_slave, MI2S_MAX);
  6848. if (ret) {
  6849. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  6850. __func__);
  6851. } else {
  6852. for (count = 0; count < MI2S_MAX; count++) {
  6853. mi2s_intf_conf[count].msm_is_mi2s_master =
  6854. mi2s_master_slave[count];
  6855. }
  6856. }
  6857. }
  6858. static void msm_i2s_auxpcm_deinit(void)
  6859. {
  6860. int count = 0;
  6861. for (count = 0; count < MI2S_MAX; count++) {
  6862. mutex_destroy(&mi2s_intf_conf[count].lock);
  6863. mi2s_intf_conf[count].ref_cnt = 0;
  6864. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  6865. }
  6866. }
  6867. static int lahaina_ssr_enable(struct device *dev, void *data)
  6868. {
  6869. struct platform_device *pdev = to_platform_device(dev);
  6870. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6871. int ret = 0;
  6872. if (!card) {
  6873. dev_err(dev, "%s: card is NULL\n", __func__);
  6874. ret = -EINVAL;
  6875. goto err;
  6876. }
  6877. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  6878. /* TODO */
  6879. dev_dbg(dev, "%s: TODO \n", __func__);
  6880. }
  6881. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6882. snd_soc_card_change_online_state(card, 1);
  6883. #endif /* CONFIG_AUDIO_QGKI */
  6884. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  6885. err:
  6886. return ret;
  6887. }
  6888. static void lahaina_ssr_disable(struct device *dev, void *data)
  6889. {
  6890. struct platform_device *pdev = to_platform_device(dev);
  6891. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6892. if (!card) {
  6893. dev_err(dev, "%s: card is NULL\n", __func__);
  6894. return;
  6895. }
  6896. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  6897. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6898. snd_soc_card_change_online_state(card, 0);
  6899. #endif /* CONFIG_AUDIO_QGKI */
  6900. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  6901. /* TODO */
  6902. dev_dbg(dev, "%s: TODO \n", __func__);
  6903. }
  6904. }
  6905. static const struct snd_event_ops lahaina_ssr_ops = {
  6906. .enable = lahaina_ssr_enable,
  6907. .disable = lahaina_ssr_disable,
  6908. };
  6909. static int msm_audio_ssr_compare(struct device *dev, void *data)
  6910. {
  6911. struct device_node *node = data;
  6912. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  6913. __func__, dev->of_node, node);
  6914. return (dev->of_node && dev->of_node == node);
  6915. }
  6916. static int msm_audio_ssr_register(struct device *dev)
  6917. {
  6918. struct device_node *np = dev->of_node;
  6919. struct snd_event_clients *ssr_clients = NULL;
  6920. struct device_node *node = NULL;
  6921. int ret = 0;
  6922. int i = 0;
  6923. for (i = 0; ; i++) {
  6924. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  6925. if (!node)
  6926. break;
  6927. snd_event_mstr_add_client(&ssr_clients,
  6928. msm_audio_ssr_compare, node);
  6929. }
  6930. ret = snd_event_master_register(dev, &lahaina_ssr_ops,
  6931. ssr_clients, NULL);
  6932. if (!ret)
  6933. snd_event_notify(dev, SND_EVENT_UP);
  6934. return ret;
  6935. }
  6936. static int msm_asoc_machine_probe(struct platform_device *pdev)
  6937. {
  6938. struct snd_soc_card *card = NULL;
  6939. struct msm_asoc_mach_data *pdata = NULL;
  6940. const char *mbhc_audio_jack_type = NULL;
  6941. int ret = 0;
  6942. uint index = 0;
  6943. struct clk *lpass_audio_hw_vote = NULL;
  6944. if (!pdev->dev.of_node) {
  6945. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  6946. return -EINVAL;
  6947. }
  6948. pdata = devm_kzalloc(&pdev->dev,
  6949. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  6950. if (!pdata)
  6951. return -ENOMEM;
  6952. of_property_read_u32(pdev->dev.of_node,
  6953. "qcom,lito-is-v2-enabled",
  6954. &pdata->lito_v2_enabled);
  6955. card = populate_snd_card_dailinks(&pdev->dev);
  6956. if (!card) {
  6957. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  6958. ret = -EINVAL;
  6959. goto err;
  6960. }
  6961. card->dev = &pdev->dev;
  6962. platform_set_drvdata(pdev, card);
  6963. snd_soc_card_set_drvdata(card, pdata);
  6964. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  6965. if (ret) {
  6966. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  6967. __func__, ret);
  6968. goto err;
  6969. }
  6970. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  6971. if (ret) {
  6972. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  6973. __func__, ret);
  6974. goto err;
  6975. }
  6976. ret = msm_populate_dai_link_component_of_node(card);
  6977. if (ret) {
  6978. ret = -EPROBE_DEFER;
  6979. goto err;
  6980. }
  6981. /* Get maximum WSA device count for this platform */
  6982. ret = of_property_read_u32(pdev->dev.of_node,
  6983. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  6984. if (ret) {
  6985. dev_info(&pdev->dev,
  6986. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6987. __func__, pdev->dev.of_node->full_name, ret);
  6988. pdata->wsa_max_devs = 0;
  6989. }
  6990. ret = devm_snd_soc_register_card(&pdev->dev, card);
  6991. if (ret == -EPROBE_DEFER) {
  6992. if (codec_reg_done)
  6993. ret = -EINVAL;
  6994. goto err;
  6995. } else if (ret) {
  6996. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  6997. __func__, ret);
  6998. goto err;
  6999. }
  7000. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  7001. __func__, card->name);
  7002. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7003. "qcom,hph-en1-gpio", 0);
  7004. if (!pdata->hph_en1_gpio_p) {
  7005. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7006. __func__, "qcom,hph-en1-gpio",
  7007. pdev->dev.of_node->full_name);
  7008. }
  7009. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7010. "qcom,hph-en0-gpio", 0);
  7011. if (!pdata->hph_en0_gpio_p) {
  7012. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7013. __func__, "qcom,hph-en0-gpio",
  7014. pdev->dev.of_node->full_name);
  7015. }
  7016. ret = of_property_read_string(pdev->dev.of_node,
  7017. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  7018. if (ret) {
  7019. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  7020. __func__, "qcom,mbhc-audio-jack-type",
  7021. pdev->dev.of_node->full_name);
  7022. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  7023. } else {
  7024. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  7025. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7026. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  7027. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  7028. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7029. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  7030. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  7031. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7032. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  7033. } else {
  7034. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7035. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  7036. }
  7037. }
  7038. /*
  7039. * Parse US-Euro gpio info from DT. Report no error if us-euro
  7040. * entry is not found in DT file as some targets do not support
  7041. * US-Euro detection
  7042. */
  7043. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7044. "qcom,us-euro-gpios", 0);
  7045. if (!pdata->us_euro_gpio_p) {
  7046. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  7047. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  7048. } else {
  7049. dev_dbg(&pdev->dev, "%s detected\n",
  7050. "qcom,us-euro-gpios");
  7051. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  7052. }
  7053. if (wcd_mbhc_cfg.enable_usbc_analog)
  7054. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  7055. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  7056. "fsa4480-i2c-handle", 0);
  7057. if (!pdata->fsa_handle)
  7058. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  7059. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  7060. msm_i2s_auxpcm_init(pdev);
  7061. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7062. "qcom,cdc-dmic01-gpios",
  7063. 0);
  7064. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7065. "qcom,cdc-dmic23-gpios",
  7066. 0);
  7067. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7068. "qcom,cdc-dmic45-gpios",
  7069. 0);
  7070. if (pdata->dmic01_gpio_p)
  7071. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  7072. if (pdata->dmic23_gpio_p)
  7073. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  7074. if (pdata->dmic45_gpio_p)
  7075. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  7076. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7077. "qcom,pri-mi2s-gpios", 0);
  7078. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7079. "qcom,sec-mi2s-gpios", 0);
  7080. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7081. "qcom,tert-mi2s-gpios", 0);
  7082. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7083. "qcom,quat-mi2s-gpios", 0);
  7084. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7085. "qcom,quin-mi2s-gpios", 0);
  7086. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7087. "qcom,sen-mi2s-gpios", 0);
  7088. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  7089. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  7090. /* Register LPASS audio hw vote */
  7091. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  7092. if (IS_ERR(lpass_audio_hw_vote)) {
  7093. ret = PTR_ERR(lpass_audio_hw_vote);
  7094. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  7095. __func__, "lpass_audio_hw_vote", ret);
  7096. lpass_audio_hw_vote = NULL;
  7097. ret = 0;
  7098. }
  7099. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  7100. pdata->core_audio_vote_count = 0;
  7101. ret = msm_audio_ssr_register(&pdev->dev);
  7102. if (ret)
  7103. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  7104. __func__, ret);
  7105. is_initial_boot = true;
  7106. /* Add QoS request for audio tasks */
  7107. msm_audio_add_qos_request();
  7108. return 0;
  7109. err:
  7110. devm_kfree(&pdev->dev, pdata);
  7111. return ret;
  7112. }
  7113. static int msm_asoc_machine_remove(struct platform_device *pdev)
  7114. {
  7115. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7116. snd_event_master_deregister(&pdev->dev);
  7117. snd_soc_unregister_card(card);
  7118. msm_i2s_auxpcm_deinit();
  7119. msm_audio_remove_qos_request();
  7120. return 0;
  7121. }
  7122. static struct platform_driver lahaina_asoc_machine_driver = {
  7123. .driver = {
  7124. .name = DRV_NAME,
  7125. .owner = THIS_MODULE,
  7126. .pm = &snd_soc_pm_ops,
  7127. .of_match_table = lahaina_asoc_machine_of_match,
  7128. .suppress_bind_attrs = true,
  7129. },
  7130. .probe = msm_asoc_machine_probe,
  7131. .remove = msm_asoc_machine_remove,
  7132. };
  7133. module_platform_driver(lahaina_asoc_machine_driver);
  7134. MODULE_DESCRIPTION("ALSA SoC msm");
  7135. MODULE_LICENSE("GPL v2");
  7136. MODULE_ALIAS("platform:" DRV_NAME);
  7137. MODULE_DEVICE_TABLE(of, lahaina_asoc_machine_of_match);