kona.c 231 KB

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