kona.c 229 KB

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