qcs405.c 215 KB

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