lahaina.c 229 KB

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