msm-dai-q6-v2.c 393 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/device.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/bitops.h>
  9. #include <linux/slab.h>
  10. #include <linux/clk.h>
  11. #include <linux/of_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/pcm_params.h>
  16. #include <dsp/apr_audio-v2.h>
  17. #include <dsp/q6afe-v2.h>
  18. #include <dsp/sp_params.h>
  19. #include <dsp/q6core.h>
  20. #include "msm-dai-q6-v2.h"
  21. #include <asoc/core.h>
  22. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  23. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  24. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  25. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  26. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  27. #define MSM_DAI_SEN_AUXPCM_DT_DEV_ID 6
  28. #define MSM_DAI_TWS_CHANNEL_MODE_ONE 1
  29. #define MSM_DAI_TWS_CHANNEL_MODE_TWO 2
  30. #define MSM_DAI_LC3_CHANNEL_MODE_ONE 1
  31. #define MSM_DAI_LC3_CHANNEL_MODE_TWO 2
  32. #define spdif_clock_value(rate) (2*rate*32*2)
  33. #define CHANNEL_STATUS_SIZE 24
  34. #define CHANNEL_STATUS_MASK_INIT 0x0
  35. #define CHANNEL_STATUS_MASK 0x4
  36. #define PREEMPH_MASK 0x38
  37. #define PREEMPH_SHIFT 3
  38. #define GET_PREEMPH(b) ((b & PREEMPH_MASK) >> PREEMPH_SHIFT)
  39. #define AFE_API_VERSION_CLOCK_SET 1
  40. #define MSM_DAI_SYSFS_ENTRY_MAX_LEN 64
  41. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  42. SNDRV_PCM_FMTBIT_S24_LE | \
  43. SNDRV_PCM_FMTBIT_S32_LE)
  44. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id);
  45. enum {
  46. ENC_FMT_NONE,
  47. DEC_FMT_NONE = ENC_FMT_NONE,
  48. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  49. DEC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  50. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  51. DEC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  52. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  53. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  54. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  55. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  56. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  57. DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  58. DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
  59. ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  60. DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  61. ENC_FMT_LC3 = ASM_MEDIA_FMT_LC3,
  62. };
  63. enum {
  64. SPKR_1,
  65. SPKR_2,
  66. };
  67. static const struct afe_clk_set lpass_clk_set_default = {
  68. AFE_API_VERSION_CLOCK_SET,
  69. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  70. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  71. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  72. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  73. 0,
  74. };
  75. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  76. AFE_API_VERSION_I2S_CONFIG,
  77. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  78. 0,
  79. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  80. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  81. Q6AFE_LPASS_MODE_CLK1_VALID,
  82. 0,
  83. };
  84. enum {
  85. STATUS_PORT_STARTED, /* track if AFE port has started */
  86. /* track AFE Tx port status for bi-directional transfers */
  87. STATUS_TX_PORT,
  88. /* track AFE Rx port status for bi-directional transfers */
  89. STATUS_RX_PORT,
  90. STATUS_MAX
  91. };
  92. enum {
  93. RATE_8KHZ,
  94. RATE_16KHZ,
  95. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  96. };
  97. enum {
  98. IDX_PRIMARY_TDM_RX_0,
  99. IDX_PRIMARY_TDM_RX_1,
  100. IDX_PRIMARY_TDM_RX_2,
  101. IDX_PRIMARY_TDM_RX_3,
  102. IDX_PRIMARY_TDM_RX_4,
  103. IDX_PRIMARY_TDM_RX_5,
  104. IDX_PRIMARY_TDM_RX_6,
  105. IDX_PRIMARY_TDM_RX_7,
  106. IDX_PRIMARY_TDM_TX_0,
  107. IDX_PRIMARY_TDM_TX_1,
  108. IDX_PRIMARY_TDM_TX_2,
  109. IDX_PRIMARY_TDM_TX_3,
  110. IDX_PRIMARY_TDM_TX_4,
  111. IDX_PRIMARY_TDM_TX_5,
  112. IDX_PRIMARY_TDM_TX_6,
  113. IDX_PRIMARY_TDM_TX_7,
  114. IDX_SECONDARY_TDM_RX_0,
  115. IDX_SECONDARY_TDM_RX_1,
  116. IDX_SECONDARY_TDM_RX_2,
  117. IDX_SECONDARY_TDM_RX_3,
  118. IDX_SECONDARY_TDM_RX_4,
  119. IDX_SECONDARY_TDM_RX_5,
  120. IDX_SECONDARY_TDM_RX_6,
  121. IDX_SECONDARY_TDM_RX_7,
  122. IDX_SECONDARY_TDM_TX_0,
  123. IDX_SECONDARY_TDM_TX_1,
  124. IDX_SECONDARY_TDM_TX_2,
  125. IDX_SECONDARY_TDM_TX_3,
  126. IDX_SECONDARY_TDM_TX_4,
  127. IDX_SECONDARY_TDM_TX_5,
  128. IDX_SECONDARY_TDM_TX_6,
  129. IDX_SECONDARY_TDM_TX_7,
  130. IDX_TERTIARY_TDM_RX_0,
  131. IDX_TERTIARY_TDM_RX_1,
  132. IDX_TERTIARY_TDM_RX_2,
  133. IDX_TERTIARY_TDM_RX_3,
  134. IDX_TERTIARY_TDM_RX_4,
  135. IDX_TERTIARY_TDM_RX_5,
  136. IDX_TERTIARY_TDM_RX_6,
  137. IDX_TERTIARY_TDM_RX_7,
  138. IDX_TERTIARY_TDM_TX_0,
  139. IDX_TERTIARY_TDM_TX_1,
  140. IDX_TERTIARY_TDM_TX_2,
  141. IDX_TERTIARY_TDM_TX_3,
  142. IDX_TERTIARY_TDM_TX_4,
  143. IDX_TERTIARY_TDM_TX_5,
  144. IDX_TERTIARY_TDM_TX_6,
  145. IDX_TERTIARY_TDM_TX_7,
  146. IDX_QUATERNARY_TDM_RX_0,
  147. IDX_QUATERNARY_TDM_RX_1,
  148. IDX_QUATERNARY_TDM_RX_2,
  149. IDX_QUATERNARY_TDM_RX_3,
  150. IDX_QUATERNARY_TDM_RX_4,
  151. IDX_QUATERNARY_TDM_RX_5,
  152. IDX_QUATERNARY_TDM_RX_6,
  153. IDX_QUATERNARY_TDM_RX_7,
  154. IDX_QUATERNARY_TDM_TX_0,
  155. IDX_QUATERNARY_TDM_TX_1,
  156. IDX_QUATERNARY_TDM_TX_2,
  157. IDX_QUATERNARY_TDM_TX_3,
  158. IDX_QUATERNARY_TDM_TX_4,
  159. IDX_QUATERNARY_TDM_TX_5,
  160. IDX_QUATERNARY_TDM_TX_6,
  161. IDX_QUATERNARY_TDM_TX_7,
  162. IDX_QUINARY_TDM_RX_0,
  163. IDX_QUINARY_TDM_RX_1,
  164. IDX_QUINARY_TDM_RX_2,
  165. IDX_QUINARY_TDM_RX_3,
  166. IDX_QUINARY_TDM_RX_4,
  167. IDX_QUINARY_TDM_RX_5,
  168. IDX_QUINARY_TDM_RX_6,
  169. IDX_QUINARY_TDM_RX_7,
  170. IDX_QUINARY_TDM_TX_0,
  171. IDX_QUINARY_TDM_TX_1,
  172. IDX_QUINARY_TDM_TX_2,
  173. IDX_QUINARY_TDM_TX_3,
  174. IDX_QUINARY_TDM_TX_4,
  175. IDX_QUINARY_TDM_TX_5,
  176. IDX_QUINARY_TDM_TX_6,
  177. IDX_QUINARY_TDM_TX_7,
  178. IDX_SENARY_TDM_RX_0,
  179. IDX_SENARY_TDM_RX_1,
  180. IDX_SENARY_TDM_RX_2,
  181. IDX_SENARY_TDM_RX_3,
  182. IDX_SENARY_TDM_RX_4,
  183. IDX_SENARY_TDM_RX_5,
  184. IDX_SENARY_TDM_RX_6,
  185. IDX_SENARY_TDM_RX_7,
  186. IDX_SENARY_TDM_TX_0,
  187. IDX_SENARY_TDM_TX_1,
  188. IDX_SENARY_TDM_TX_2,
  189. IDX_SENARY_TDM_TX_3,
  190. IDX_SENARY_TDM_TX_4,
  191. IDX_SENARY_TDM_TX_5,
  192. IDX_SENARY_TDM_TX_6,
  193. IDX_SENARY_TDM_TX_7,
  194. IDX_TDM_MAX,
  195. };
  196. enum {
  197. IDX_GROUP_PRIMARY_TDM_RX,
  198. IDX_GROUP_PRIMARY_TDM_TX,
  199. IDX_GROUP_SECONDARY_TDM_RX,
  200. IDX_GROUP_SECONDARY_TDM_TX,
  201. IDX_GROUP_TERTIARY_TDM_RX,
  202. IDX_GROUP_TERTIARY_TDM_TX,
  203. IDX_GROUP_QUATERNARY_TDM_RX,
  204. IDX_GROUP_QUATERNARY_TDM_TX,
  205. IDX_GROUP_QUINARY_TDM_RX,
  206. IDX_GROUP_QUINARY_TDM_TX,
  207. IDX_GROUP_SENARY_TDM_RX,
  208. IDX_GROUP_SENARY_TDM_TX,
  209. IDX_GROUP_TDM_MAX,
  210. };
  211. struct msm_dai_q6_dai_data {
  212. DECLARE_BITMAP(status_mask, STATUS_MAX);
  213. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  214. u32 rate;
  215. u32 channels;
  216. u32 bitwidth;
  217. u32 cal_mode;
  218. u32 afe_rx_in_channels;
  219. u16 afe_rx_in_bitformat;
  220. u32 afe_tx_out_channels;
  221. u16 afe_tx_out_bitformat;
  222. struct afe_enc_config enc_config;
  223. struct afe_dec_config dec_config;
  224. struct afe_ttp_config ttp_config;
  225. union afe_port_config port_config;
  226. u16 vi_feed_mono;
  227. u32 xt_logging_disable;
  228. };
  229. struct msm_dai_q6_spdif_dai_data {
  230. DECLARE_BITMAP(status_mask, STATUS_MAX);
  231. u32 rate;
  232. u32 channels;
  233. u32 bitwidth;
  234. u16 port_id;
  235. struct afe_spdif_port_config spdif_port;
  236. struct afe_event_fmt_update fmt_event;
  237. struct kobject *kobj;
  238. };
  239. struct msm_dai_q6_spdif_event_msg {
  240. struct afe_port_mod_evt_rsp_hdr evt_hdr;
  241. struct afe_event_fmt_update fmt_event;
  242. };
  243. struct msm_dai_q6_mi2s_dai_config {
  244. u16 pdata_mi2s_lines;
  245. struct msm_dai_q6_dai_data mi2s_dai_data;
  246. };
  247. struct msm_dai_q6_mi2s_dai_data {
  248. u32 is_island_dai;
  249. struct msm_dai_q6_mi2s_dai_config tx_dai;
  250. struct msm_dai_q6_mi2s_dai_config rx_dai;
  251. };
  252. struct msm_dai_q6_meta_mi2s_dai_data {
  253. DECLARE_BITMAP(status_mask, STATUS_MAX);
  254. u16 num_member_ports;
  255. u16 member_port_id[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  256. u16 channel_mode[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  257. u32 rate;
  258. u32 channels;
  259. u32 bitwidth;
  260. union afe_port_config port_config;
  261. };
  262. struct msm_dai_q6_cdc_dma_dai_data {
  263. DECLARE_BITMAP(status_mask, STATUS_MAX);
  264. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  265. u32 rate;
  266. u32 channels;
  267. u32 bitwidth;
  268. u32 is_island_dai;
  269. u32 xt_logging_disable;
  270. union afe_port_config port_config;
  271. u32 cdc_dma_data_align;
  272. };
  273. struct msm_dai_q6_auxpcm_dai_data {
  274. /* BITMAP to track Rx and Tx port usage count */
  275. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  276. struct mutex rlock; /* auxpcm dev resource lock */
  277. u16 rx_pid; /* AUXPCM RX AFE port ID */
  278. u16 tx_pid; /* AUXPCM TX AFE port ID */
  279. u16 afe_clk_ver;
  280. u32 is_island_dai;
  281. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  282. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  283. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  284. };
  285. struct msm_dai_q6_tdm_dai_data {
  286. DECLARE_BITMAP(status_mask, STATUS_MAX);
  287. u32 rate;
  288. u32 channels;
  289. u32 bitwidth;
  290. u32 num_group_ports;
  291. u32 is_island_dai;
  292. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  293. union afe_port_group_config group_cfg; /* hold tdm group config */
  294. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  295. struct afe_param_id_tdm_lane_cfg lane_cfg; /* hold tdm lane config */
  296. };
  297. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  298. * 0: linear PCM
  299. * 1: non-linear PCM
  300. * 2: PCM data in IEC 60968 container
  301. * 3: compressed data in IEC 60958 container
  302. * 9: DSD over PCM (DoP) with marker byte
  303. */
  304. static const char *const mi2s_format[] = {
  305. "LPCM",
  306. "Compr",
  307. "LPCM-60958",
  308. "Compr-60958",
  309. "NA4",
  310. "NA5",
  311. "NA6",
  312. "NA7",
  313. "NA8",
  314. "DSD_DOP_W_MARKER",
  315. "NATIVE_DSD_DATA"
  316. };
  317. static const char *const mi2s_vi_feed_mono[] = {
  318. "Left",
  319. "Right",
  320. };
  321. static const struct soc_enum mi2s_config_enum[] = {
  322. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mi2s_format), mi2s_format),
  323. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  324. };
  325. static const char *const cdc_dma_format[] = {
  326. "UNPACKED",
  327. "PACKED_16B",
  328. };
  329. static const struct soc_enum cdc_dma_config_enum[] = {
  330. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  331. };
  332. static const char *const sb_format[] = {
  333. "UNPACKED",
  334. "PACKED_16B",
  335. "DSD_DOP",
  336. };
  337. static const struct soc_enum sb_config_enum[] = {
  338. SOC_ENUM_SINGLE_EXT(3, sb_format),
  339. };
  340. static const char * const xt_logging_disable_text[] = {
  341. "FALSE",
  342. "TRUE",
  343. };
  344. static const struct soc_enum xt_logging_disable_enum[] = {
  345. SOC_ENUM_SINGLE_EXT(2, xt_logging_disable_text),
  346. };
  347. static const char *const tdm_data_format[] = {
  348. "LPCM",
  349. "Compr",
  350. "Gen Compr"
  351. };
  352. static const char *const tdm_header_type[] = {
  353. "Invalid",
  354. "Default",
  355. "Entertainment",
  356. };
  357. static const struct soc_enum tdm_config_enum[] = {
  358. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  359. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  360. };
  361. static DEFINE_MUTEX(tdm_mutex);
  362. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  363. static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = {
  364. AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX,
  365. 0x0,
  366. };
  367. /* cache of group cfg per parent node */
  368. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  369. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  370. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  371. 0,
  372. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  373. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  374. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  375. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  376. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  377. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  378. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  379. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  380. 8,
  381. 48000,
  382. 32,
  383. 8,
  384. 32,
  385. 0xFF,
  386. };
  387. static u32 num_tdm_group_ports;
  388. static struct afe_clk_set tdm_clk_set = {
  389. AFE_API_VERSION_CLOCK_SET,
  390. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  391. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  392. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  393. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  394. 0,
  395. };
  396. static int msm_dai_q6_get_tdm_clk_ref(u16 id)
  397. {
  398. switch (id) {
  399. case IDX_GROUP_PRIMARY_TDM_RX:
  400. case IDX_GROUP_PRIMARY_TDM_TX:
  401. return atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_RX]) +
  402. atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_TX]);
  403. case IDX_GROUP_SECONDARY_TDM_RX:
  404. case IDX_GROUP_SECONDARY_TDM_TX:
  405. return atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_RX]) +
  406. atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_TX]);
  407. case IDX_GROUP_TERTIARY_TDM_RX:
  408. case IDX_GROUP_TERTIARY_TDM_TX:
  409. return atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_RX]) +
  410. atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_TX]);
  411. case IDX_GROUP_QUATERNARY_TDM_RX:
  412. case IDX_GROUP_QUATERNARY_TDM_TX:
  413. return atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_RX]) +
  414. atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_TX]);
  415. case IDX_GROUP_QUINARY_TDM_RX:
  416. case IDX_GROUP_QUINARY_TDM_TX:
  417. return atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_RX]) +
  418. atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_TX]);
  419. case IDX_GROUP_SENARY_TDM_RX:
  420. case IDX_GROUP_SENARY_TDM_TX:
  421. return atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_RX]) +
  422. atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_TX]);
  423. default: return -EINVAL;
  424. }
  425. }
  426. int msm_dai_q6_get_group_idx(u16 id)
  427. {
  428. switch (id) {
  429. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  430. case AFE_PORT_ID_PRIMARY_TDM_RX:
  431. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  432. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  433. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  434. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  435. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  436. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  437. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  438. return IDX_GROUP_PRIMARY_TDM_RX;
  439. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  440. case AFE_PORT_ID_PRIMARY_TDM_TX:
  441. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  442. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  443. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  444. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  445. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  446. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  447. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  448. return IDX_GROUP_PRIMARY_TDM_TX;
  449. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  450. case AFE_PORT_ID_SECONDARY_TDM_RX:
  451. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  452. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  453. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  454. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  455. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  456. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  457. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  458. return IDX_GROUP_SECONDARY_TDM_RX;
  459. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  460. case AFE_PORT_ID_SECONDARY_TDM_TX:
  461. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  462. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  463. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  464. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  465. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  466. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  467. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  468. return IDX_GROUP_SECONDARY_TDM_TX;
  469. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  470. case AFE_PORT_ID_TERTIARY_TDM_RX:
  471. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  472. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  473. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  474. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  475. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  476. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  477. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  478. return IDX_GROUP_TERTIARY_TDM_RX;
  479. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  480. case AFE_PORT_ID_TERTIARY_TDM_TX:
  481. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  482. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  483. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  484. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  485. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  486. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  487. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  488. return IDX_GROUP_TERTIARY_TDM_TX;
  489. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  490. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  491. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  492. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  493. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  494. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  495. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  496. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  497. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  498. return IDX_GROUP_QUATERNARY_TDM_RX;
  499. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  500. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  501. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  502. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  503. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  504. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  505. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  506. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  507. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  508. return IDX_GROUP_QUATERNARY_TDM_TX;
  509. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  510. case AFE_PORT_ID_QUINARY_TDM_RX:
  511. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  512. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  513. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  514. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  515. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  516. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  517. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  518. return IDX_GROUP_QUINARY_TDM_RX;
  519. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  520. case AFE_PORT_ID_QUINARY_TDM_TX:
  521. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  522. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  523. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  524. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  525. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  526. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  527. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  528. return IDX_GROUP_QUINARY_TDM_TX;
  529. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  530. case AFE_PORT_ID_SENARY_TDM_RX:
  531. case AFE_PORT_ID_SENARY_TDM_RX_1:
  532. case AFE_PORT_ID_SENARY_TDM_RX_2:
  533. case AFE_PORT_ID_SENARY_TDM_RX_3:
  534. case AFE_PORT_ID_SENARY_TDM_RX_4:
  535. case AFE_PORT_ID_SENARY_TDM_RX_5:
  536. case AFE_PORT_ID_SENARY_TDM_RX_6:
  537. case AFE_PORT_ID_SENARY_TDM_RX_7:
  538. return IDX_GROUP_SENARY_TDM_RX;
  539. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  540. case AFE_PORT_ID_SENARY_TDM_TX:
  541. case AFE_PORT_ID_SENARY_TDM_TX_1:
  542. case AFE_PORT_ID_SENARY_TDM_TX_2:
  543. case AFE_PORT_ID_SENARY_TDM_TX_3:
  544. case AFE_PORT_ID_SENARY_TDM_TX_4:
  545. case AFE_PORT_ID_SENARY_TDM_TX_5:
  546. case AFE_PORT_ID_SENARY_TDM_TX_6:
  547. case AFE_PORT_ID_SENARY_TDM_TX_7:
  548. return IDX_GROUP_SENARY_TDM_TX;
  549. default: return -EINVAL;
  550. }
  551. }
  552. int msm_dai_q6_get_port_idx(u16 id)
  553. {
  554. switch (id) {
  555. case AFE_PORT_ID_PRIMARY_TDM_RX:
  556. return IDX_PRIMARY_TDM_RX_0;
  557. case AFE_PORT_ID_PRIMARY_TDM_TX:
  558. return IDX_PRIMARY_TDM_TX_0;
  559. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  560. return IDX_PRIMARY_TDM_RX_1;
  561. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  562. return IDX_PRIMARY_TDM_TX_1;
  563. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  564. return IDX_PRIMARY_TDM_RX_2;
  565. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  566. return IDX_PRIMARY_TDM_TX_2;
  567. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  568. return IDX_PRIMARY_TDM_RX_3;
  569. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  570. return IDX_PRIMARY_TDM_TX_3;
  571. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  572. return IDX_PRIMARY_TDM_RX_4;
  573. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  574. return IDX_PRIMARY_TDM_TX_4;
  575. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  576. return IDX_PRIMARY_TDM_RX_5;
  577. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  578. return IDX_PRIMARY_TDM_TX_5;
  579. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  580. return IDX_PRIMARY_TDM_RX_6;
  581. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  582. return IDX_PRIMARY_TDM_TX_6;
  583. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  584. return IDX_PRIMARY_TDM_RX_7;
  585. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  586. return IDX_PRIMARY_TDM_TX_7;
  587. case AFE_PORT_ID_SECONDARY_TDM_RX:
  588. return IDX_SECONDARY_TDM_RX_0;
  589. case AFE_PORT_ID_SECONDARY_TDM_TX:
  590. return IDX_SECONDARY_TDM_TX_0;
  591. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  592. return IDX_SECONDARY_TDM_RX_1;
  593. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  594. return IDX_SECONDARY_TDM_TX_1;
  595. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  596. return IDX_SECONDARY_TDM_RX_2;
  597. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  598. return IDX_SECONDARY_TDM_TX_2;
  599. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  600. return IDX_SECONDARY_TDM_RX_3;
  601. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  602. return IDX_SECONDARY_TDM_TX_3;
  603. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  604. return IDX_SECONDARY_TDM_RX_4;
  605. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  606. return IDX_SECONDARY_TDM_TX_4;
  607. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  608. return IDX_SECONDARY_TDM_RX_5;
  609. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  610. return IDX_SECONDARY_TDM_TX_5;
  611. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  612. return IDX_SECONDARY_TDM_RX_6;
  613. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  614. return IDX_SECONDARY_TDM_TX_6;
  615. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  616. return IDX_SECONDARY_TDM_RX_7;
  617. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  618. return IDX_SECONDARY_TDM_TX_7;
  619. case AFE_PORT_ID_TERTIARY_TDM_RX:
  620. return IDX_TERTIARY_TDM_RX_0;
  621. case AFE_PORT_ID_TERTIARY_TDM_TX:
  622. return IDX_TERTIARY_TDM_TX_0;
  623. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  624. return IDX_TERTIARY_TDM_RX_1;
  625. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  626. return IDX_TERTIARY_TDM_TX_1;
  627. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  628. return IDX_TERTIARY_TDM_RX_2;
  629. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  630. return IDX_TERTIARY_TDM_TX_2;
  631. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  632. return IDX_TERTIARY_TDM_RX_3;
  633. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  634. return IDX_TERTIARY_TDM_TX_3;
  635. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  636. return IDX_TERTIARY_TDM_RX_4;
  637. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  638. return IDX_TERTIARY_TDM_TX_4;
  639. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  640. return IDX_TERTIARY_TDM_RX_5;
  641. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  642. return IDX_TERTIARY_TDM_TX_5;
  643. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  644. return IDX_TERTIARY_TDM_RX_6;
  645. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  646. return IDX_TERTIARY_TDM_TX_6;
  647. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  648. return IDX_TERTIARY_TDM_RX_7;
  649. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  650. return IDX_TERTIARY_TDM_TX_7;
  651. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  652. return IDX_QUATERNARY_TDM_RX_0;
  653. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  654. return IDX_QUATERNARY_TDM_TX_0;
  655. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  656. return IDX_QUATERNARY_TDM_RX_1;
  657. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  658. return IDX_QUATERNARY_TDM_TX_1;
  659. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  660. return IDX_QUATERNARY_TDM_RX_2;
  661. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  662. return IDX_QUATERNARY_TDM_TX_2;
  663. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  664. return IDX_QUATERNARY_TDM_RX_3;
  665. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  666. return IDX_QUATERNARY_TDM_TX_3;
  667. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  668. return IDX_QUATERNARY_TDM_RX_4;
  669. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  670. return IDX_QUATERNARY_TDM_TX_4;
  671. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  672. return IDX_QUATERNARY_TDM_RX_5;
  673. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  674. return IDX_QUATERNARY_TDM_TX_5;
  675. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  676. return IDX_QUATERNARY_TDM_RX_6;
  677. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  678. return IDX_QUATERNARY_TDM_TX_6;
  679. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  680. return IDX_QUATERNARY_TDM_RX_7;
  681. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  682. return IDX_QUATERNARY_TDM_TX_7;
  683. case AFE_PORT_ID_QUINARY_TDM_RX:
  684. return IDX_QUINARY_TDM_RX_0;
  685. case AFE_PORT_ID_QUINARY_TDM_TX:
  686. return IDX_QUINARY_TDM_TX_0;
  687. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  688. return IDX_QUINARY_TDM_RX_1;
  689. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  690. return IDX_QUINARY_TDM_TX_1;
  691. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  692. return IDX_QUINARY_TDM_RX_2;
  693. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  694. return IDX_QUINARY_TDM_TX_2;
  695. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  696. return IDX_QUINARY_TDM_RX_3;
  697. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  698. return IDX_QUINARY_TDM_TX_3;
  699. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  700. return IDX_QUINARY_TDM_RX_4;
  701. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  702. return IDX_QUINARY_TDM_TX_4;
  703. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  704. return IDX_QUINARY_TDM_RX_5;
  705. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  706. return IDX_QUINARY_TDM_TX_5;
  707. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  708. return IDX_QUINARY_TDM_RX_6;
  709. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  710. return IDX_QUINARY_TDM_TX_6;
  711. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  712. return IDX_QUINARY_TDM_RX_7;
  713. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  714. return IDX_QUINARY_TDM_TX_7;
  715. case AFE_PORT_ID_SENARY_TDM_RX:
  716. return IDX_SENARY_TDM_RX_0;
  717. case AFE_PORT_ID_SENARY_TDM_TX:
  718. return IDX_SENARY_TDM_TX_0;
  719. case AFE_PORT_ID_SENARY_TDM_RX_1:
  720. return IDX_SENARY_TDM_RX_1;
  721. case AFE_PORT_ID_SENARY_TDM_TX_1:
  722. return IDX_SENARY_TDM_TX_1;
  723. case AFE_PORT_ID_SENARY_TDM_RX_2:
  724. return IDX_SENARY_TDM_RX_2;
  725. case AFE_PORT_ID_SENARY_TDM_TX_2:
  726. return IDX_SENARY_TDM_TX_2;
  727. case AFE_PORT_ID_SENARY_TDM_RX_3:
  728. return IDX_SENARY_TDM_RX_3;
  729. case AFE_PORT_ID_SENARY_TDM_TX_3:
  730. return IDX_SENARY_TDM_TX_3;
  731. case AFE_PORT_ID_SENARY_TDM_RX_4:
  732. return IDX_SENARY_TDM_RX_4;
  733. case AFE_PORT_ID_SENARY_TDM_TX_4:
  734. return IDX_SENARY_TDM_TX_4;
  735. case AFE_PORT_ID_SENARY_TDM_RX_5:
  736. return IDX_SENARY_TDM_RX_5;
  737. case AFE_PORT_ID_SENARY_TDM_TX_5:
  738. return IDX_SENARY_TDM_TX_5;
  739. case AFE_PORT_ID_SENARY_TDM_RX_6:
  740. return IDX_SENARY_TDM_RX_6;
  741. case AFE_PORT_ID_SENARY_TDM_TX_6:
  742. return IDX_SENARY_TDM_TX_6;
  743. case AFE_PORT_ID_SENARY_TDM_RX_7:
  744. return IDX_SENARY_TDM_RX_7;
  745. case AFE_PORT_ID_SENARY_TDM_TX_7:
  746. return IDX_SENARY_TDM_TX_7;
  747. default: return -EINVAL;
  748. }
  749. }
  750. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  751. {
  752. /* Max num of slots is bits per frame divided
  753. * by bits per sample which is 16
  754. */
  755. switch (frame_rate) {
  756. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  757. return 0;
  758. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  759. return 1;
  760. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  761. return 2;
  762. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  763. return 4;
  764. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  765. return 8;
  766. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  767. return 16;
  768. default:
  769. pr_err("%s Invalid bits per frame %d\n",
  770. __func__, frame_rate);
  771. return 0;
  772. }
  773. }
  774. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  775. {
  776. struct snd_soc_dapm_route intercon;
  777. struct snd_soc_dapm_context *dapm;
  778. if (!dai) {
  779. pr_err("%s: Invalid params dai\n", __func__);
  780. return -EINVAL;
  781. }
  782. if (!dai->driver) {
  783. pr_err("%s: Invalid params dai driver\n", __func__);
  784. return -EINVAL;
  785. }
  786. dapm = snd_soc_component_get_dapm(dai->component);
  787. memset(&intercon, 0, sizeof(intercon));
  788. if (dai->driver->playback.stream_name &&
  789. dai->driver->playback.aif_name) {
  790. dev_dbg(dai->dev, "%s: add route for widget %s",
  791. __func__, dai->driver->playback.stream_name);
  792. intercon.source = dai->driver->playback.aif_name;
  793. intercon.sink = dai->driver->playback.stream_name;
  794. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  795. __func__, intercon.source, intercon.sink);
  796. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  797. snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
  798. }
  799. if (dai->driver->capture.stream_name &&
  800. dai->driver->capture.aif_name) {
  801. dev_dbg(dai->dev, "%s: add route for widget %s",
  802. __func__, dai->driver->capture.stream_name);
  803. intercon.sink = dai->driver->capture.aif_name;
  804. intercon.source = dai->driver->capture.stream_name;
  805. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  806. __func__, intercon.source, intercon.sink);
  807. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  808. snd_soc_dapm_ignore_suspend(dapm, intercon.source);
  809. }
  810. return 0;
  811. }
  812. static int msm_dai_q6_auxpcm_hw_params(
  813. struct snd_pcm_substream *substream,
  814. struct snd_pcm_hw_params *params,
  815. struct snd_soc_dai *dai)
  816. {
  817. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  818. dev_get_drvdata(dai->dev);
  819. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  820. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  821. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  822. int rc = 0, slot_mapping_copy_len = 0;
  823. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  824. params_rate(params) != 16000)) {
  825. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  826. __func__, params_channels(params), params_rate(params));
  827. return -EINVAL;
  828. }
  829. mutex_lock(&aux_dai_data->rlock);
  830. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  831. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  832. /* AUXPCM DAI in use */
  833. if (dai_data->rate != params_rate(params)) {
  834. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  835. __func__);
  836. rc = -EINVAL;
  837. }
  838. mutex_unlock(&aux_dai_data->rlock);
  839. return rc;
  840. }
  841. dai_data->channels = params_channels(params);
  842. dai_data->rate = params_rate(params);
  843. if (dai_data->rate == 8000) {
  844. dai_data->port_config.pcm.pcm_cfg_minor_version =
  845. AFE_API_VERSION_PCM_CONFIG;
  846. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  847. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  848. dai_data->port_config.pcm.frame_setting =
  849. auxpcm_pdata->mode_8k.frame;
  850. dai_data->port_config.pcm.quantype =
  851. auxpcm_pdata->mode_8k.quant;
  852. dai_data->port_config.pcm.ctrl_data_out_enable =
  853. auxpcm_pdata->mode_8k.data;
  854. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  855. dai_data->port_config.pcm.num_channels = dai_data->channels;
  856. dai_data->port_config.pcm.bit_width = 16;
  857. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  858. auxpcm_pdata->mode_8k.num_slots)
  859. slot_mapping_copy_len =
  860. ARRAY_SIZE(
  861. dai_data->port_config.pcm.slot_number_mapping)
  862. * sizeof(uint16_t);
  863. else
  864. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  865. * sizeof(uint16_t);
  866. if (auxpcm_pdata->mode_8k.slot_mapping) {
  867. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  868. auxpcm_pdata->mode_8k.slot_mapping,
  869. slot_mapping_copy_len);
  870. } else {
  871. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  872. __func__);
  873. mutex_unlock(&aux_dai_data->rlock);
  874. return -EINVAL;
  875. }
  876. } else {
  877. dai_data->port_config.pcm.pcm_cfg_minor_version =
  878. AFE_API_VERSION_PCM_CONFIG;
  879. dai_data->port_config.pcm.aux_mode =
  880. auxpcm_pdata->mode_16k.mode;
  881. dai_data->port_config.pcm.sync_src =
  882. auxpcm_pdata->mode_16k.sync;
  883. dai_data->port_config.pcm.frame_setting =
  884. auxpcm_pdata->mode_16k.frame;
  885. dai_data->port_config.pcm.quantype =
  886. auxpcm_pdata->mode_16k.quant;
  887. dai_data->port_config.pcm.ctrl_data_out_enable =
  888. auxpcm_pdata->mode_16k.data;
  889. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  890. dai_data->port_config.pcm.num_channels = dai_data->channels;
  891. dai_data->port_config.pcm.bit_width = 16;
  892. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  893. auxpcm_pdata->mode_16k.num_slots)
  894. slot_mapping_copy_len =
  895. ARRAY_SIZE(
  896. dai_data->port_config.pcm.slot_number_mapping)
  897. * sizeof(uint16_t);
  898. else
  899. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  900. * sizeof(uint16_t);
  901. if (auxpcm_pdata->mode_16k.slot_mapping) {
  902. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  903. auxpcm_pdata->mode_16k.slot_mapping,
  904. slot_mapping_copy_len);
  905. } else {
  906. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  907. __func__);
  908. mutex_unlock(&aux_dai_data->rlock);
  909. return -EINVAL;
  910. }
  911. }
  912. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  913. __func__, dai_data->port_config.pcm.aux_mode,
  914. dai_data->port_config.pcm.sync_src,
  915. dai_data->port_config.pcm.frame_setting);
  916. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  917. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  918. __func__, dai_data->port_config.pcm.quantype,
  919. dai_data->port_config.pcm.ctrl_data_out_enable,
  920. dai_data->port_config.pcm.slot_number_mapping[0],
  921. dai_data->port_config.pcm.slot_number_mapping[1],
  922. dai_data->port_config.pcm.slot_number_mapping[2],
  923. dai_data->port_config.pcm.slot_number_mapping[3]);
  924. mutex_unlock(&aux_dai_data->rlock);
  925. return rc;
  926. }
  927. static int msm_dai_q6_auxpcm_set_clk(
  928. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  929. u16 port_id, bool enable)
  930. {
  931. int rc;
  932. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  933. aux_dai_data->afe_clk_ver, port_id, enable);
  934. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  935. aux_dai_data->clk_set.enable = enable;
  936. rc = afe_set_lpass_clock_v2(port_id,
  937. &aux_dai_data->clk_set);
  938. } else {
  939. if (!enable)
  940. aux_dai_data->clk_cfg.clk_val1 = 0;
  941. rc = afe_set_lpass_clock(port_id,
  942. &aux_dai_data->clk_cfg);
  943. }
  944. return rc;
  945. }
  946. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  947. struct snd_soc_dai *dai)
  948. {
  949. int rc = 0;
  950. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  951. dev_get_drvdata(dai->dev);
  952. mutex_lock(&aux_dai_data->rlock);
  953. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  954. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  955. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  956. __func__, dai->id);
  957. goto exit;
  958. }
  959. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  960. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  961. clear_bit(STATUS_TX_PORT,
  962. aux_dai_data->auxpcm_port_status);
  963. else {
  964. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  965. __func__);
  966. goto exit;
  967. }
  968. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  969. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  970. clear_bit(STATUS_RX_PORT,
  971. aux_dai_data->auxpcm_port_status);
  972. else {
  973. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  974. __func__);
  975. goto exit;
  976. }
  977. }
  978. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  979. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  980. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  981. __func__);
  982. goto exit;
  983. }
  984. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  985. __func__, dai->id);
  986. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  987. if (rc < 0)
  988. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  989. rc = afe_close(aux_dai_data->tx_pid);
  990. if (rc < 0)
  991. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  992. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  993. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  994. exit:
  995. mutex_unlock(&aux_dai_data->rlock);
  996. }
  997. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  998. struct snd_soc_dai *dai)
  999. {
  1000. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  1001. dev_get_drvdata(dai->dev);
  1002. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  1003. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  1004. int rc = 0;
  1005. u32 pcm_clk_rate;
  1006. auxpcm_pdata = dai->dev->platform_data;
  1007. mutex_lock(&aux_dai_data->rlock);
  1008. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  1009. if (test_bit(STATUS_TX_PORT,
  1010. aux_dai_data->auxpcm_port_status)) {
  1011. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  1012. __func__);
  1013. goto exit;
  1014. } else
  1015. set_bit(STATUS_TX_PORT,
  1016. aux_dai_data->auxpcm_port_status);
  1017. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1018. if (test_bit(STATUS_RX_PORT,
  1019. aux_dai_data->auxpcm_port_status)) {
  1020. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  1021. __func__);
  1022. goto exit;
  1023. } else
  1024. set_bit(STATUS_RX_PORT,
  1025. aux_dai_data->auxpcm_port_status);
  1026. }
  1027. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  1028. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1029. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  1030. goto exit;
  1031. }
  1032. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  1033. __func__, dai->id);
  1034. rc = afe_q6_interface_prepare();
  1035. if (rc < 0) {
  1036. dev_err(dai->dev, "fail to open AFE APR\n");
  1037. goto fail;
  1038. }
  1039. /*
  1040. * For AUX PCM Interface the below sequence of clk
  1041. * settings and afe_open is a strict requirement.
  1042. *
  1043. * Also using afe_open instead of afe_port_start_nowait
  1044. * to make sure the port is open before deasserting the
  1045. * clock line. This is required because pcm register is
  1046. * not written before clock deassert. Hence the hw does
  1047. * not get updated with new setting if the below clock
  1048. * assert/deasset and afe_open sequence is not followed.
  1049. */
  1050. if (dai_data->rate == 8000) {
  1051. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  1052. } else if (dai_data->rate == 16000) {
  1053. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  1054. } else {
  1055. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  1056. dai_data->rate);
  1057. rc = -EINVAL;
  1058. goto fail;
  1059. }
  1060. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  1061. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  1062. sizeof(struct afe_clk_set));
  1063. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  1064. switch (dai->id) {
  1065. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  1066. if (pcm_clk_rate)
  1067. aux_dai_data->clk_set.clk_id =
  1068. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  1069. else
  1070. aux_dai_data->clk_set.clk_id =
  1071. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  1072. break;
  1073. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  1074. if (pcm_clk_rate)
  1075. aux_dai_data->clk_set.clk_id =
  1076. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  1077. else
  1078. aux_dai_data->clk_set.clk_id =
  1079. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  1080. break;
  1081. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  1082. if (pcm_clk_rate)
  1083. aux_dai_data->clk_set.clk_id =
  1084. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  1085. else
  1086. aux_dai_data->clk_set.clk_id =
  1087. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  1088. break;
  1089. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  1090. if (pcm_clk_rate)
  1091. aux_dai_data->clk_set.clk_id =
  1092. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  1093. else
  1094. aux_dai_data->clk_set.clk_id =
  1095. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  1096. break;
  1097. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  1098. if (pcm_clk_rate)
  1099. aux_dai_data->clk_set.clk_id =
  1100. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  1101. else
  1102. aux_dai_data->clk_set.clk_id =
  1103. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  1104. break;
  1105. case MSM_DAI_SEN_AUXPCM_DT_DEV_ID:
  1106. if (pcm_clk_rate)
  1107. aux_dai_data->clk_set.clk_id =
  1108. Q6AFE_LPASS_CLK_ID_SEN_PCM_IBIT;
  1109. else
  1110. aux_dai_data->clk_set.clk_id =
  1111. Q6AFE_LPASS_CLK_ID_SEN_PCM_EBIT;
  1112. break;
  1113. default:
  1114. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  1115. __func__, dai->id);
  1116. break;
  1117. }
  1118. } else {
  1119. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  1120. sizeof(struct afe_clk_cfg));
  1121. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  1122. }
  1123. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1124. aux_dai_data->rx_pid, true);
  1125. if (rc < 0) {
  1126. dev_err(dai->dev,
  1127. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  1128. __func__);
  1129. goto fail;
  1130. }
  1131. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1132. aux_dai_data->tx_pid, true);
  1133. if (rc < 0) {
  1134. dev_err(dai->dev,
  1135. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  1136. __func__);
  1137. goto fail;
  1138. }
  1139. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  1140. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  1141. goto exit;
  1142. fail:
  1143. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  1144. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1145. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1146. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1147. exit:
  1148. mutex_unlock(&aux_dai_data->rlock);
  1149. return rc;
  1150. }
  1151. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1152. int cmd, struct snd_soc_dai *dai)
  1153. {
  1154. int rc = 0;
  1155. pr_debug("%s:port:%d cmd:%d\n",
  1156. __func__, dai->id, cmd);
  1157. switch (cmd) {
  1158. case SNDRV_PCM_TRIGGER_START:
  1159. case SNDRV_PCM_TRIGGER_RESUME:
  1160. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1161. /* afe_open will be called from prepare */
  1162. return 0;
  1163. case SNDRV_PCM_TRIGGER_STOP:
  1164. case SNDRV_PCM_TRIGGER_SUSPEND:
  1165. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1166. return 0;
  1167. default:
  1168. pr_err("%s: cmd %d\n", __func__, cmd);
  1169. rc = -EINVAL;
  1170. }
  1171. return rc;
  1172. }
  1173. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1174. {
  1175. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1176. int rc;
  1177. aux_dai_data = dev_get_drvdata(dai->dev);
  1178. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1179. __func__, dai->id);
  1180. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1181. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1182. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1183. if (rc < 0)
  1184. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1185. rc = afe_close(aux_dai_data->tx_pid);
  1186. if (rc < 0)
  1187. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1188. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1189. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1190. }
  1191. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1192. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1193. return 0;
  1194. }
  1195. static int msm_dai_q6_power_mode_put(struct snd_kcontrol *kcontrol,
  1196. struct snd_ctl_elem_value *ucontrol)
  1197. {
  1198. int value = ucontrol->value.integer.value[0];
  1199. u16 port_id = (u16)kcontrol->private_value;
  1200. pr_debug("%s: power mode = %d\n", __func__, value);
  1201. trace_printk("%s: power mode = %d\n", __func__, value);
  1202. afe_set_power_mode_cfg(port_id, value);
  1203. return 0;
  1204. }
  1205. static int msm_dai_q6_power_mode_get(struct snd_kcontrol *kcontrol,
  1206. struct snd_ctl_elem_value *ucontrol)
  1207. {
  1208. int value;
  1209. u16 port_id = (u16)kcontrol->private_value;
  1210. afe_get_power_mode_cfg(port_id, &value);
  1211. ucontrol->value.integer.value[0] = value;
  1212. return 0;
  1213. }
  1214. static void power_mode_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1215. {
  1216. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1217. kfree(knew);
  1218. }
  1219. static int msm_dai_q6_add_power_mode_mx_ctls(struct snd_card *card,
  1220. const char *dai_name,
  1221. int dai_id, void *dai_data)
  1222. {
  1223. const char *mx_ctl_name = "Power Mode";
  1224. char *mixer_str = NULL;
  1225. int dai_str_len = 0, ctl_len = 0;
  1226. int rc = 0;
  1227. struct snd_kcontrol_new *knew = NULL;
  1228. struct snd_kcontrol *kctl = NULL;
  1229. dai_str_len = strlen(dai_name) + 1;
  1230. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1231. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1232. if (!mixer_str)
  1233. return -ENOMEM;
  1234. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1235. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1236. if (!knew) {
  1237. kfree(mixer_str);
  1238. return -ENOMEM;
  1239. }
  1240. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1241. knew->info = snd_ctl_boolean_mono_info;
  1242. knew->get = msm_dai_q6_power_mode_get;
  1243. knew->put = msm_dai_q6_power_mode_put;
  1244. knew->name = mixer_str;
  1245. knew->private_value = dai_id;
  1246. kctl = snd_ctl_new1(knew, knew);
  1247. if (!kctl) {
  1248. kfree(knew);
  1249. kfree(mixer_str);
  1250. return -ENOMEM;
  1251. }
  1252. kctl->private_free = power_mode_mx_ctl_private_free;
  1253. rc = snd_ctl_add(card, kctl);
  1254. if (rc < 0)
  1255. pr_err("%s: err add config ctl, DAI = %s\n",
  1256. __func__, dai_name);
  1257. kfree(mixer_str);
  1258. return rc;
  1259. }
  1260. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1261. struct snd_ctl_elem_value *ucontrol)
  1262. {
  1263. int value = ucontrol->value.integer.value[0];
  1264. u16 port_id = (u16)kcontrol->private_value;
  1265. pr_debug("%s: island mode = %d\n", __func__, value);
  1266. trace_printk("%s: island mode = %d\n", __func__, value);
  1267. afe_set_island_mode_cfg(port_id, value);
  1268. return 0;
  1269. }
  1270. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1271. struct snd_ctl_elem_value *ucontrol)
  1272. {
  1273. int value;
  1274. u16 port_id = (u16)kcontrol->private_value;
  1275. afe_get_island_mode_cfg(port_id, &value);
  1276. ucontrol->value.integer.value[0] = value;
  1277. return 0;
  1278. }
  1279. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1280. {
  1281. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1282. kfree(knew);
  1283. }
  1284. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1285. const char *dai_name,
  1286. int dai_id, void *dai_data)
  1287. {
  1288. const char *mx_ctl_name = "TX island";
  1289. char *mixer_str = NULL;
  1290. int dai_str_len = 0, ctl_len = 0;
  1291. int rc = 0;
  1292. struct snd_kcontrol_new *knew = NULL;
  1293. struct snd_kcontrol *kctl = NULL;
  1294. dai_str_len = strlen(dai_name) + 1;
  1295. /* Add island related mixer controls */
  1296. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1297. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1298. if (!mixer_str)
  1299. return -ENOMEM;
  1300. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1301. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1302. if (!knew) {
  1303. kfree(mixer_str);
  1304. return -ENOMEM;
  1305. }
  1306. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1307. knew->info = snd_ctl_boolean_mono_info;
  1308. knew->get = msm_dai_q6_island_mode_get;
  1309. knew->put = msm_dai_q6_island_mode_put;
  1310. knew->name = mixer_str;
  1311. knew->private_value = dai_id;
  1312. kctl = snd_ctl_new1(knew, knew);
  1313. if (!kctl) {
  1314. kfree(knew);
  1315. kfree(mixer_str);
  1316. return -ENOMEM;
  1317. }
  1318. kctl->private_free = island_mx_ctl_private_free;
  1319. rc = snd_ctl_add(card, kctl);
  1320. if (rc < 0)
  1321. pr_err("%s: err add config ctl, DAI = %s\n",
  1322. __func__, dai_name);
  1323. kfree(mixer_str);
  1324. return rc;
  1325. }
  1326. static int msm_dai_q6_add_isconfig_config_mx_ctls(struct snd_card *card,
  1327. const char *dai_name,
  1328. int dai_id, void *dai_data)
  1329. {
  1330. const char *mx_ctl_name = "Island Config";
  1331. char *mixer_str = NULL;
  1332. int dai_str_len = 0, ctl_len = 0;
  1333. int rc = 0;
  1334. struct snd_kcontrol_new *knew = NULL;
  1335. struct snd_kcontrol *kctl = NULL;
  1336. dai_str_len = strlen(dai_name) + 1;
  1337. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1338. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1339. if (!mixer_str)
  1340. return -ENOMEM;
  1341. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1342. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1343. if (!knew) {
  1344. kfree(mixer_str);
  1345. return -ENOMEM;
  1346. }
  1347. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1348. knew->info = snd_ctl_boolean_mono_info;
  1349. knew->get = msm_dai_q6_island_mode_get;
  1350. knew->put = msm_dai_q6_island_mode_put;
  1351. knew->name = mixer_str;
  1352. knew->private_value = dai_id;
  1353. kctl = snd_ctl_new1(knew, knew);
  1354. if (!kctl) {
  1355. kfree(knew);
  1356. kfree(mixer_str);
  1357. return -ENOMEM;
  1358. }
  1359. kctl->private_free = island_mx_ctl_private_free;
  1360. rc = snd_ctl_add(card, kctl);
  1361. if (rc < 0)
  1362. pr_err("%s: err add config ctl, DAI = %s\n",
  1363. __func__, dai_name);
  1364. kfree(mixer_str);
  1365. return rc;
  1366. }
  1367. /*
  1368. * For single CPU DAI registration, the dai id needs to be
  1369. * set explicitly in the dai probe as ASoC does not read
  1370. * the cpu->driver->id field rather it assigns the dai id
  1371. * from the device name that is in the form %s.%d. This dai
  1372. * id should be assigned to back-end AFE port id and used
  1373. * during dai prepare. For multiple dai registration, it
  1374. * is not required to call this function, however the dai->
  1375. * driver->id field must be defined and set to corresponding
  1376. * AFE Port id.
  1377. */
  1378. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1379. {
  1380. if (!dai->driver) {
  1381. dev_err(dai->dev, "DAI driver is not set\n");
  1382. return;
  1383. }
  1384. if (!dai->driver->id) {
  1385. dev_dbg(dai->dev, "DAI driver id is not set\n");
  1386. return;
  1387. }
  1388. dai->id = dai->driver->id;
  1389. }
  1390. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1391. {
  1392. int rc = 0;
  1393. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1394. if (!dai) {
  1395. pr_err("%s: Invalid params dai\n", __func__);
  1396. return -EINVAL;
  1397. }
  1398. if (!dai->dev) {
  1399. pr_err("%s: Invalid params dai dev\n", __func__);
  1400. return -EINVAL;
  1401. }
  1402. msm_dai_q6_set_dai_id(dai);
  1403. dai_data = dev_get_drvdata(dai->dev);
  1404. if (dai_data->is_island_dai)
  1405. rc = msm_dai_q6_add_island_mx_ctls(
  1406. dai->component->card->snd_card,
  1407. dai->name, dai_data->tx_pid,
  1408. (void *)dai_data);
  1409. rc = msm_dai_q6_dai_add_route(dai);
  1410. return rc;
  1411. }
  1412. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1413. .prepare = msm_dai_q6_auxpcm_prepare,
  1414. .trigger = msm_dai_q6_auxpcm_trigger,
  1415. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1416. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1417. };
  1418. static const struct snd_soc_component_driver
  1419. msm_dai_q6_aux_pcm_dai_component = {
  1420. .name = "msm-auxpcm-dev",
  1421. };
  1422. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1423. {
  1424. .playback = {
  1425. .stream_name = "AUX PCM Playback",
  1426. .aif_name = "AUX_PCM_RX",
  1427. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1428. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1429. .channels_min = 1,
  1430. .channels_max = 1,
  1431. .rate_max = 16000,
  1432. .rate_min = 8000,
  1433. },
  1434. .capture = {
  1435. .stream_name = "AUX PCM Capture",
  1436. .aif_name = "AUX_PCM_TX",
  1437. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1438. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1439. .channels_min = 1,
  1440. .channels_max = 1,
  1441. .rate_max = 16000,
  1442. .rate_min = 8000,
  1443. },
  1444. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1445. .name = "Pri AUX PCM",
  1446. .ops = &msm_dai_q6_auxpcm_ops,
  1447. .probe = msm_dai_q6_aux_pcm_probe,
  1448. .remove = msm_dai_q6_dai_auxpcm_remove,
  1449. },
  1450. {
  1451. .playback = {
  1452. .stream_name = "Sec AUX PCM Playback",
  1453. .aif_name = "SEC_AUX_PCM_RX",
  1454. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1455. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1456. .channels_min = 1,
  1457. .channels_max = 1,
  1458. .rate_max = 16000,
  1459. .rate_min = 8000,
  1460. },
  1461. .capture = {
  1462. .stream_name = "Sec AUX PCM Capture",
  1463. .aif_name = "SEC_AUX_PCM_TX",
  1464. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1465. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1466. .channels_min = 1,
  1467. .channels_max = 1,
  1468. .rate_max = 16000,
  1469. .rate_min = 8000,
  1470. },
  1471. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1472. .name = "Sec AUX PCM",
  1473. .ops = &msm_dai_q6_auxpcm_ops,
  1474. .probe = msm_dai_q6_aux_pcm_probe,
  1475. .remove = msm_dai_q6_dai_auxpcm_remove,
  1476. },
  1477. {
  1478. .playback = {
  1479. .stream_name = "Tert AUX PCM Playback",
  1480. .aif_name = "TERT_AUX_PCM_RX",
  1481. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1482. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1483. .channels_min = 1,
  1484. .channels_max = 1,
  1485. .rate_max = 16000,
  1486. .rate_min = 8000,
  1487. },
  1488. .capture = {
  1489. .stream_name = "Tert AUX PCM Capture",
  1490. .aif_name = "TERT_AUX_PCM_TX",
  1491. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1492. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1493. .channels_min = 1,
  1494. .channels_max = 1,
  1495. .rate_max = 16000,
  1496. .rate_min = 8000,
  1497. },
  1498. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1499. .name = "Tert AUX PCM",
  1500. .ops = &msm_dai_q6_auxpcm_ops,
  1501. .probe = msm_dai_q6_aux_pcm_probe,
  1502. .remove = msm_dai_q6_dai_auxpcm_remove,
  1503. },
  1504. {
  1505. .playback = {
  1506. .stream_name = "Quat AUX PCM Playback",
  1507. .aif_name = "QUAT_AUX_PCM_RX",
  1508. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1509. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1510. .channels_min = 1,
  1511. .channels_max = 1,
  1512. .rate_max = 16000,
  1513. .rate_min = 8000,
  1514. },
  1515. .capture = {
  1516. .stream_name = "Quat AUX PCM Capture",
  1517. .aif_name = "QUAT_AUX_PCM_TX",
  1518. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1519. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1520. .channels_min = 1,
  1521. .channels_max = 1,
  1522. .rate_max = 16000,
  1523. .rate_min = 8000,
  1524. },
  1525. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1526. .name = "Quat AUX PCM",
  1527. .ops = &msm_dai_q6_auxpcm_ops,
  1528. .probe = msm_dai_q6_aux_pcm_probe,
  1529. .remove = msm_dai_q6_dai_auxpcm_remove,
  1530. },
  1531. {
  1532. .playback = {
  1533. .stream_name = "Quin AUX PCM Playback",
  1534. .aif_name = "QUIN_AUX_PCM_RX",
  1535. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1536. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1537. .channels_min = 1,
  1538. .channels_max = 1,
  1539. .rate_max = 16000,
  1540. .rate_min = 8000,
  1541. },
  1542. .capture = {
  1543. .stream_name = "Quin AUX PCM Capture",
  1544. .aif_name = "QUIN_AUX_PCM_TX",
  1545. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1546. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1547. .channels_min = 1,
  1548. .channels_max = 1,
  1549. .rate_max = 16000,
  1550. .rate_min = 8000,
  1551. },
  1552. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1553. .name = "Quin AUX PCM",
  1554. .ops = &msm_dai_q6_auxpcm_ops,
  1555. .probe = msm_dai_q6_aux_pcm_probe,
  1556. .remove = msm_dai_q6_dai_auxpcm_remove,
  1557. },
  1558. {
  1559. .playback = {
  1560. .stream_name = "Sen AUX PCM Playback",
  1561. .aif_name = "SEN_AUX_PCM_RX",
  1562. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1563. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1564. .channels_min = 1,
  1565. .channels_max = 1,
  1566. .rate_max = 16000,
  1567. .rate_min = 8000,
  1568. },
  1569. .capture = {
  1570. .stream_name = "Sen AUX PCM Capture",
  1571. .aif_name = "SEN_AUX_PCM_TX",
  1572. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1573. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1574. .channels_min = 1,
  1575. .channels_max = 1,
  1576. .rate_max = 16000,
  1577. .rate_min = 8000,
  1578. },
  1579. .id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID,
  1580. .name = "Sen AUX PCM",
  1581. .ops = &msm_dai_q6_auxpcm_ops,
  1582. .probe = msm_dai_q6_aux_pcm_probe,
  1583. .remove = msm_dai_q6_dai_auxpcm_remove,
  1584. },
  1585. };
  1586. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1587. struct snd_ctl_elem_value *ucontrol)
  1588. {
  1589. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1590. int value = ucontrol->value.integer.value[0];
  1591. dai_data->spdif_port.cfg.data_format = value;
  1592. pr_debug("%s: value = %d\n", __func__, value);
  1593. return 0;
  1594. }
  1595. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1596. struct snd_ctl_elem_value *ucontrol)
  1597. {
  1598. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1599. ucontrol->value.integer.value[0] =
  1600. dai_data->spdif_port.cfg.data_format;
  1601. return 0;
  1602. }
  1603. static int msm_dai_q6_spdif_source_put(struct snd_kcontrol *kcontrol,
  1604. struct snd_ctl_elem_value *ucontrol)
  1605. {
  1606. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1607. int value = ucontrol->value.integer.value[0];
  1608. dai_data->spdif_port.cfg.src_sel = value;
  1609. pr_debug("%s: value = %d\n", __func__, value);
  1610. return 0;
  1611. }
  1612. static int msm_dai_q6_spdif_source_get(struct snd_kcontrol *kcontrol,
  1613. struct snd_ctl_elem_value *ucontrol)
  1614. {
  1615. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1616. ucontrol->value.integer.value[0] =
  1617. dai_data->spdif_port.cfg.src_sel;
  1618. return 0;
  1619. }
  1620. static const char * const spdif_format[] = {
  1621. "LPCM",
  1622. "Compr"
  1623. };
  1624. static const char * const spdif_source[] = {
  1625. "Optical", "EXT-ARC", "Coaxial", "VT-ARC"
  1626. };
  1627. static const struct soc_enum spdif_rx_config_enum[] = {
  1628. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1629. };
  1630. static const struct soc_enum spdif_tx_config_enum[] = {
  1631. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_source), spdif_source),
  1632. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1633. };
  1634. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1635. struct snd_ctl_elem_value *ucontrol)
  1636. {
  1637. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1638. int ret = 0;
  1639. dai_data->spdif_port.ch_status.status_type =
  1640. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1641. memset(dai_data->spdif_port.ch_status.status_mask,
  1642. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1643. dai_data->spdif_port.ch_status.status_mask[0] =
  1644. CHANNEL_STATUS_MASK;
  1645. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1646. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1647. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1648. pr_debug("%s: Port already started. Dynamic update\n",
  1649. __func__);
  1650. ret = afe_send_spdif_ch_status_cfg(
  1651. &dai_data->spdif_port.ch_status,
  1652. dai_data->port_id);
  1653. }
  1654. return ret;
  1655. }
  1656. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1657. struct snd_ctl_elem_value *ucontrol)
  1658. {
  1659. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1660. memcpy(ucontrol->value.iec958.status,
  1661. dai_data->spdif_port.ch_status.status_bits,
  1662. CHANNEL_STATUS_SIZE);
  1663. return 0;
  1664. }
  1665. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1666. struct snd_ctl_elem_info *uinfo)
  1667. {
  1668. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1669. uinfo->count = 1;
  1670. return 0;
  1671. }
  1672. static const struct snd_kcontrol_new spdif_rx_config_controls[] = {
  1673. /* Primary SPDIF output */
  1674. {
  1675. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1676. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1677. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1678. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1679. .info = msm_dai_q6_spdif_chstatus_info,
  1680. .get = msm_dai_q6_spdif_chstatus_get,
  1681. .put = msm_dai_q6_spdif_chstatus_put,
  1682. },
  1683. SOC_ENUM_EXT("PRI SPDIF RX Format", spdif_rx_config_enum[0],
  1684. msm_dai_q6_spdif_format_get,
  1685. msm_dai_q6_spdif_format_put),
  1686. /* Secondary SPDIF output */
  1687. {
  1688. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1689. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1690. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1691. .name = SNDRV_CTL_NAME_IEC958("SEC", PLAYBACK, PCM_STREAM),
  1692. .info = msm_dai_q6_spdif_chstatus_info,
  1693. .get = msm_dai_q6_spdif_chstatus_get,
  1694. .put = msm_dai_q6_spdif_chstatus_put,
  1695. },
  1696. SOC_ENUM_EXT("SEC SPDIF RX Format", spdif_rx_config_enum[0],
  1697. msm_dai_q6_spdif_format_get,
  1698. msm_dai_q6_spdif_format_put)
  1699. };
  1700. static const struct snd_kcontrol_new spdif_tx_config_controls[] = {
  1701. SOC_ENUM_EXT("PRI SPDIF TX Source", spdif_tx_config_enum[0],
  1702. msm_dai_q6_spdif_source_get,
  1703. msm_dai_q6_spdif_source_put),
  1704. SOC_ENUM_EXT("PRI SPDIF TX Format", spdif_tx_config_enum[1],
  1705. msm_dai_q6_spdif_format_get,
  1706. msm_dai_q6_spdif_format_put),
  1707. SOC_ENUM_EXT("SEC SPDIF TX Source", spdif_tx_config_enum[0],
  1708. msm_dai_q6_spdif_source_get,
  1709. msm_dai_q6_spdif_source_put),
  1710. SOC_ENUM_EXT("SEC SPDIF TX Format", spdif_tx_config_enum[1],
  1711. msm_dai_q6_spdif_format_get,
  1712. msm_dai_q6_spdif_format_put)
  1713. };
  1714. static void msm_dai_q6_spdif_process_event(uint32_t opcode, uint32_t token,
  1715. uint32_t *payload, void *private_data)
  1716. {
  1717. struct msm_dai_q6_spdif_event_msg *evt;
  1718. struct msm_dai_q6_spdif_dai_data *dai_data;
  1719. int preemph_old = 0;
  1720. int preemph_new = 0;
  1721. evt = (struct msm_dai_q6_spdif_event_msg *)payload;
  1722. dai_data = (struct msm_dai_q6_spdif_dai_data *)private_data;
  1723. preemph_old = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1724. preemph_new = GET_PREEMPH(evt->fmt_event.channel_status[0]);
  1725. pr_debug("%s: old state %d, fmt %d, rate %d, preemph %d\n",
  1726. __func__, dai_data->fmt_event.status,
  1727. dai_data->fmt_event.data_format,
  1728. dai_data->fmt_event.sample_rate,
  1729. preemph_old);
  1730. pr_debug("%s: new state %d, fmt %d, rate %d, preemph %d\n",
  1731. __func__, evt->fmt_event.status,
  1732. evt->fmt_event.data_format,
  1733. evt->fmt_event.sample_rate,
  1734. preemph_new);
  1735. dai_data->fmt_event.status = evt->fmt_event.status;
  1736. dai_data->fmt_event.data_format = evt->fmt_event.data_format;
  1737. dai_data->fmt_event.sample_rate = evt->fmt_event.sample_rate;
  1738. dai_data->fmt_event.channel_status[0] =
  1739. evt->fmt_event.channel_status[0];
  1740. dai_data->fmt_event.channel_status[1] =
  1741. evt->fmt_event.channel_status[1];
  1742. dai_data->fmt_event.channel_status[2] =
  1743. evt->fmt_event.channel_status[2];
  1744. dai_data->fmt_event.channel_status[3] =
  1745. evt->fmt_event.channel_status[3];
  1746. dai_data->fmt_event.channel_status[4] =
  1747. evt->fmt_event.channel_status[4];
  1748. dai_data->fmt_event.channel_status[5] =
  1749. evt->fmt_event.channel_status[5];
  1750. }
  1751. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1752. struct snd_pcm_hw_params *params,
  1753. struct snd_soc_dai *dai)
  1754. {
  1755. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1756. dai_data->channels = params_channels(params);
  1757. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1758. switch (params_format(params)) {
  1759. case SNDRV_PCM_FORMAT_S16_LE:
  1760. dai_data->spdif_port.cfg.bit_width = 16;
  1761. break;
  1762. case SNDRV_PCM_FORMAT_S24_LE:
  1763. case SNDRV_PCM_FORMAT_S24_3LE:
  1764. dai_data->spdif_port.cfg.bit_width = 24;
  1765. break;
  1766. default:
  1767. pr_err("%s: format %d\n",
  1768. __func__, params_format(params));
  1769. return -EINVAL;
  1770. }
  1771. dai_data->rate = params_rate(params);
  1772. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1773. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1774. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1775. AFE_API_VERSION_SPDIF_CONFIG_V2;
  1776. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1777. dai_data->channels, dai_data->rate,
  1778. dai_data->spdif_port.cfg.bit_width);
  1779. dai_data->spdif_port.cfg.reserved = 0;
  1780. return 0;
  1781. }
  1782. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1783. struct snd_soc_dai *dai)
  1784. {
  1785. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1786. int rc = 0;
  1787. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1788. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1789. __func__, *dai_data->status_mask);
  1790. return;
  1791. }
  1792. rc = afe_close(dai->id);
  1793. if (rc < 0)
  1794. dev_err(dai->dev, "fail to close AFE port\n");
  1795. dai_data->fmt_event.status = 0; /* report invalid line state */
  1796. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1797. *dai_data->status_mask);
  1798. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1799. }
  1800. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1801. struct snd_soc_dai *dai)
  1802. {
  1803. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1804. int rc = 0;
  1805. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1806. rc = afe_spdif_reg_event_cfg(dai->id,
  1807. AFE_MODULE_REGISTER_EVENT_FLAG,
  1808. msm_dai_q6_spdif_process_event,
  1809. dai_data);
  1810. if (rc < 0)
  1811. dev_err(dai->dev,
  1812. "fail to register event for port 0x%x\n",
  1813. dai->id);
  1814. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1815. dai_data->rate);
  1816. if (rc < 0)
  1817. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1818. dai->id);
  1819. else
  1820. set_bit(STATUS_PORT_STARTED,
  1821. dai_data->status_mask);
  1822. }
  1823. return rc;
  1824. }
  1825. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_state(struct device *dev,
  1826. struct device_attribute *attr, char *buf)
  1827. {
  1828. ssize_t ret;
  1829. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1830. if (!dai_data) {
  1831. pr_err("%s: invalid input\n", __func__);
  1832. return -EINVAL;
  1833. }
  1834. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1835. dai_data->fmt_event.status);
  1836. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.status);
  1837. return ret;
  1838. }
  1839. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_format(struct device *dev,
  1840. struct device_attribute *attr, char *buf)
  1841. {
  1842. ssize_t ret;
  1843. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1844. if (!dai_data) {
  1845. pr_err("%s: invalid input\n", __func__);
  1846. return -EINVAL;
  1847. }
  1848. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1849. dai_data->fmt_event.data_format);
  1850. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.data_format);
  1851. return ret;
  1852. }
  1853. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_rate(struct device *dev,
  1854. struct device_attribute *attr, char *buf)
  1855. {
  1856. ssize_t ret;
  1857. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1858. if (!dai_data) {
  1859. pr_err("%s: invalid input\n", __func__);
  1860. return -EINVAL;
  1861. }
  1862. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1863. dai_data->fmt_event.sample_rate);
  1864. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.sample_rate);
  1865. return ret;
  1866. }
  1867. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_preemph(struct device *dev,
  1868. struct device_attribute *attr, char *buf)
  1869. {
  1870. ssize_t ret;
  1871. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1872. int preemph = 0;
  1873. if (!dai_data) {
  1874. pr_err("%s: invalid input\n", __func__);
  1875. return -EINVAL;
  1876. }
  1877. preemph = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1878. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n", preemph);
  1879. pr_debug("%s: '%d'\n", __func__, preemph);
  1880. return ret;
  1881. }
  1882. static DEVICE_ATTR(audio_state, 0444, msm_dai_q6_spdif_sysfs_rda_audio_state,
  1883. NULL);
  1884. static DEVICE_ATTR(audio_format, 0444, msm_dai_q6_spdif_sysfs_rda_audio_format,
  1885. NULL);
  1886. static DEVICE_ATTR(audio_rate, 0444, msm_dai_q6_spdif_sysfs_rda_audio_rate,
  1887. NULL);
  1888. static DEVICE_ATTR(audio_preemph, 0444,
  1889. msm_dai_q6_spdif_sysfs_rda_audio_preemph, NULL);
  1890. static struct attribute *msm_dai_q6_spdif_fs_attrs[] = {
  1891. &dev_attr_audio_state.attr,
  1892. &dev_attr_audio_format.attr,
  1893. &dev_attr_audio_rate.attr,
  1894. &dev_attr_audio_preemph.attr,
  1895. NULL,
  1896. };
  1897. static struct attribute_group msm_dai_q6_spdif_fs_attrs_group = {
  1898. .attrs = msm_dai_q6_spdif_fs_attrs,
  1899. };
  1900. static int msm_dai_q6_spdif_sysfs_create(struct snd_soc_dai *dai,
  1901. struct msm_dai_q6_spdif_dai_data *dai_data)
  1902. {
  1903. int rc;
  1904. rc = sysfs_create_group(&dai->dev->kobj,
  1905. &msm_dai_q6_spdif_fs_attrs_group);
  1906. if (rc) {
  1907. pr_err("%s: failed, rc=%d\n", __func__, rc);
  1908. return rc;
  1909. }
  1910. dai_data->kobj = &dai->dev->kobj;
  1911. return 0;
  1912. }
  1913. static void msm_dai_q6_spdif_sysfs_remove(struct snd_soc_dai *dai,
  1914. struct msm_dai_q6_spdif_dai_data *dai_data)
  1915. {
  1916. if (dai_data->kobj)
  1917. sysfs_remove_group(dai_data->kobj,
  1918. &msm_dai_q6_spdif_fs_attrs_group);
  1919. dai_data->kobj = NULL;
  1920. }
  1921. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1922. {
  1923. struct msm_dai_q6_spdif_dai_data *dai_data;
  1924. int rc = 0;
  1925. struct snd_soc_dapm_route intercon;
  1926. struct snd_soc_dapm_context *dapm;
  1927. if (!dai) {
  1928. pr_err("%s: dai not found!!\n", __func__);
  1929. return -EINVAL;
  1930. }
  1931. if (!dai->dev) {
  1932. pr_err("%s: Invalid params dai dev\n", __func__);
  1933. return -EINVAL;
  1934. }
  1935. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1936. GFP_KERNEL);
  1937. if (!dai_data)
  1938. return -ENOMEM;
  1939. else
  1940. dev_set_drvdata(dai->dev, dai_data);
  1941. msm_dai_q6_set_dai_id(dai);
  1942. dai_data->port_id = dai->id;
  1943. switch (dai->id) {
  1944. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  1945. rc = snd_ctl_add(dai->component->card->snd_card,
  1946. snd_ctl_new1(&spdif_rx_config_controls[1],
  1947. dai_data));
  1948. break;
  1949. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  1950. rc = snd_ctl_add(dai->component->card->snd_card,
  1951. snd_ctl_new1(&spdif_rx_config_controls[3],
  1952. dai_data));
  1953. break;
  1954. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  1955. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1956. rc = snd_ctl_add(dai->component->card->snd_card,
  1957. snd_ctl_new1(&spdif_tx_config_controls[0],
  1958. dai_data));
  1959. rc = snd_ctl_add(dai->component->card->snd_card,
  1960. snd_ctl_new1(&spdif_tx_config_controls[1],
  1961. dai_data));
  1962. break;
  1963. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  1964. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1965. rc = snd_ctl_add(dai->component->card->snd_card,
  1966. snd_ctl_new1(&spdif_tx_config_controls[2],
  1967. dai_data));
  1968. rc = snd_ctl_add(dai->component->card->snd_card,
  1969. snd_ctl_new1(&spdif_tx_config_controls[3],
  1970. dai_data));
  1971. break;
  1972. }
  1973. if (rc < 0)
  1974. dev_err(dai->dev,
  1975. "%s: err add config ctl, DAI = %s\n",
  1976. __func__, dai->name);
  1977. dapm = snd_soc_component_get_dapm(dai->component);
  1978. memset(&intercon, 0, sizeof(intercon));
  1979. if (!rc && dai && dai->driver) {
  1980. if (dai->driver->playback.stream_name &&
  1981. dai->driver->playback.aif_name) {
  1982. dev_dbg(dai->dev, "%s: add route for widget %s",
  1983. __func__, dai->driver->playback.stream_name);
  1984. intercon.source = dai->driver->playback.aif_name;
  1985. intercon.sink = dai->driver->playback.stream_name;
  1986. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1987. __func__, intercon.source, intercon.sink);
  1988. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1989. }
  1990. if (dai->driver->capture.stream_name &&
  1991. dai->driver->capture.aif_name) {
  1992. dev_dbg(dai->dev, "%s: add route for widget %s",
  1993. __func__, dai->driver->capture.stream_name);
  1994. intercon.sink = dai->driver->capture.aif_name;
  1995. intercon.source = dai->driver->capture.stream_name;
  1996. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1997. __func__, intercon.source, intercon.sink);
  1998. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1999. }
  2000. }
  2001. return rc;
  2002. }
  2003. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  2004. {
  2005. struct msm_dai_q6_spdif_dai_data *dai_data;
  2006. int rc;
  2007. dai_data = dev_get_drvdata(dai->dev);
  2008. /* If AFE port is still up, close it */
  2009. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2010. rc = afe_spdif_reg_event_cfg(dai->id,
  2011. AFE_MODULE_DEREGISTER_EVENT_FLAG,
  2012. NULL,
  2013. dai_data);
  2014. if (rc < 0)
  2015. dev_err(dai->dev,
  2016. "fail to deregister event for port 0x%x\n",
  2017. dai->id);
  2018. rc = afe_close(dai->id); /* can block */
  2019. if (rc < 0)
  2020. dev_err(dai->dev, "fail to close AFE port\n");
  2021. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2022. }
  2023. msm_dai_q6_spdif_sysfs_remove(dai, dai_data);
  2024. kfree(dai_data);
  2025. return 0;
  2026. }
  2027. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  2028. .prepare = msm_dai_q6_spdif_prepare,
  2029. .hw_params = msm_dai_q6_spdif_hw_params,
  2030. .shutdown = msm_dai_q6_spdif_shutdown,
  2031. };
  2032. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai[] = {
  2033. {
  2034. .playback = {
  2035. .stream_name = "Primary SPDIF Playback",
  2036. .aif_name = "PRI_SPDIF_RX",
  2037. .rates = SNDRV_PCM_RATE_32000 |
  2038. SNDRV_PCM_RATE_44100 |
  2039. SNDRV_PCM_RATE_48000 |
  2040. SNDRV_PCM_RATE_88200 |
  2041. SNDRV_PCM_RATE_96000 |
  2042. SNDRV_PCM_RATE_176400 |
  2043. SNDRV_PCM_RATE_192000,
  2044. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2045. SNDRV_PCM_FMTBIT_S24_LE,
  2046. .channels_min = 1,
  2047. .channels_max = 2,
  2048. .rate_min = 32000,
  2049. .rate_max = 192000,
  2050. },
  2051. .name = "PRI_SPDIF_RX",
  2052. .ops = &msm_dai_q6_spdif_ops,
  2053. .id = AFE_PORT_ID_PRIMARY_SPDIF_RX,
  2054. .probe = msm_dai_q6_spdif_dai_probe,
  2055. .remove = msm_dai_q6_spdif_dai_remove,
  2056. },
  2057. {
  2058. .playback = {
  2059. .stream_name = "Secondary SPDIF Playback",
  2060. .aif_name = "SEC_SPDIF_RX",
  2061. .rates = SNDRV_PCM_RATE_32000 |
  2062. SNDRV_PCM_RATE_44100 |
  2063. SNDRV_PCM_RATE_48000 |
  2064. SNDRV_PCM_RATE_88200 |
  2065. SNDRV_PCM_RATE_96000 |
  2066. SNDRV_PCM_RATE_176400 |
  2067. SNDRV_PCM_RATE_192000,
  2068. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2069. SNDRV_PCM_FMTBIT_S24_LE,
  2070. .channels_min = 1,
  2071. .channels_max = 2,
  2072. .rate_min = 32000,
  2073. .rate_max = 192000,
  2074. },
  2075. .name = "SEC_SPDIF_RX",
  2076. .ops = &msm_dai_q6_spdif_ops,
  2077. .id = AFE_PORT_ID_SECONDARY_SPDIF_RX,
  2078. .probe = msm_dai_q6_spdif_dai_probe,
  2079. .remove = msm_dai_q6_spdif_dai_remove,
  2080. },
  2081. };
  2082. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_tx_dai[] = {
  2083. {
  2084. .capture = {
  2085. .stream_name = "Primary SPDIF Capture",
  2086. .aif_name = "PRI_SPDIF_TX",
  2087. .rates = SNDRV_PCM_RATE_32000 |
  2088. SNDRV_PCM_RATE_44100 |
  2089. SNDRV_PCM_RATE_48000 |
  2090. SNDRV_PCM_RATE_88200 |
  2091. SNDRV_PCM_RATE_96000 |
  2092. SNDRV_PCM_RATE_176400 |
  2093. SNDRV_PCM_RATE_192000,
  2094. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2095. SNDRV_PCM_FMTBIT_S24_LE,
  2096. .channels_min = 1,
  2097. .channels_max = 2,
  2098. .rate_min = 32000,
  2099. .rate_max = 192000,
  2100. },
  2101. .name = "PRI_SPDIF_TX",
  2102. .ops = &msm_dai_q6_spdif_ops,
  2103. .id = AFE_PORT_ID_PRIMARY_SPDIF_TX,
  2104. .probe = msm_dai_q6_spdif_dai_probe,
  2105. .remove = msm_dai_q6_spdif_dai_remove,
  2106. },
  2107. {
  2108. .capture = {
  2109. .stream_name = "Secondary SPDIF Capture",
  2110. .aif_name = "SEC_SPDIF_TX",
  2111. .rates = SNDRV_PCM_RATE_32000 |
  2112. SNDRV_PCM_RATE_44100 |
  2113. SNDRV_PCM_RATE_48000 |
  2114. SNDRV_PCM_RATE_88200 |
  2115. SNDRV_PCM_RATE_96000 |
  2116. SNDRV_PCM_RATE_176400 |
  2117. SNDRV_PCM_RATE_192000,
  2118. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2119. SNDRV_PCM_FMTBIT_S24_LE,
  2120. .channels_min = 1,
  2121. .channels_max = 2,
  2122. .rate_min = 32000,
  2123. .rate_max = 192000,
  2124. },
  2125. .name = "SEC_SPDIF_TX",
  2126. .ops = &msm_dai_q6_spdif_ops,
  2127. .id = AFE_PORT_ID_SECONDARY_SPDIF_TX,
  2128. .probe = msm_dai_q6_spdif_dai_probe,
  2129. .remove = msm_dai_q6_spdif_dai_remove,
  2130. },
  2131. };
  2132. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  2133. .name = "msm-dai-q6-spdif",
  2134. };
  2135. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  2136. struct snd_soc_dai *dai)
  2137. {
  2138. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2139. int rc = 0;
  2140. uint16_t ttp_gen_enable = dai_data->ttp_config.ttp_gen_enable.enable;
  2141. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2142. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  2143. int bitwidth = 0;
  2144. switch (dai_data->afe_rx_in_bitformat) {
  2145. case SNDRV_PCM_FORMAT_S32_LE:
  2146. bitwidth = 32;
  2147. break;
  2148. case SNDRV_PCM_FORMAT_S24_LE:
  2149. bitwidth = 24;
  2150. break;
  2151. case SNDRV_PCM_FORMAT_S16_LE:
  2152. default:
  2153. bitwidth = 16;
  2154. break;
  2155. }
  2156. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  2157. __func__, dai_data->enc_config.format);
  2158. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  2159. dai_data->rate,
  2160. dai_data->afe_rx_in_channels,
  2161. bitwidth,
  2162. &dai_data->enc_config, NULL);
  2163. if (rc < 0)
  2164. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  2165. __func__, rc);
  2166. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  2167. int bitwidth = 0;
  2168. /*
  2169. * If bitwidth is not configured set default value to
  2170. * zero, so that decoder port config uses slim device
  2171. * bit width value in afe decoder config.
  2172. */
  2173. switch (dai_data->afe_tx_out_bitformat) {
  2174. case SNDRV_PCM_FORMAT_S32_LE:
  2175. bitwidth = 32;
  2176. break;
  2177. case SNDRV_PCM_FORMAT_S24_LE:
  2178. bitwidth = 24;
  2179. break;
  2180. case SNDRV_PCM_FORMAT_S16_LE:
  2181. bitwidth = 16;
  2182. break;
  2183. default:
  2184. bitwidth = 0;
  2185. break;
  2186. }
  2187. if (ttp_gen_enable == true) {
  2188. pr_debug("%s: calling AFE_PORT_START_V3 with dec format: %d\n",
  2189. __func__, dai_data->dec_config.format);
  2190. rc = afe_port_start_v3(dai->id,
  2191. &dai_data->port_config,
  2192. dai_data->rate,
  2193. dai_data->afe_tx_out_channels,
  2194. bitwidth,
  2195. NULL, &dai_data->dec_config,
  2196. &dai_data->ttp_config);
  2197. } else {
  2198. pr_debug("%s: calling AFE_PORT_START_V2 with dec format: %d\n",
  2199. __func__, dai_data->dec_config.format);
  2200. rc = afe_port_start_v2(dai->id,
  2201. &dai_data->port_config,
  2202. dai_data->rate,
  2203. dai_data->afe_tx_out_channels,
  2204. bitwidth,
  2205. NULL, &dai_data->dec_config);
  2206. }
  2207. if (rc < 0) {
  2208. pr_err("%s: fail to open AFE port 0x%x\n",
  2209. __func__, dai->id);
  2210. }
  2211. } else {
  2212. rc = afe_port_start(dai->id, &dai_data->port_config,
  2213. dai_data->rate);
  2214. }
  2215. if (rc < 0)
  2216. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  2217. dai->id);
  2218. else
  2219. set_bit(STATUS_PORT_STARTED,
  2220. dai_data->status_mask);
  2221. }
  2222. return rc;
  2223. }
  2224. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  2225. struct snd_soc_dai *dai, int stream)
  2226. {
  2227. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2228. dai_data->channels = params_channels(params);
  2229. switch (dai_data->channels) {
  2230. case 2:
  2231. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2232. break;
  2233. case 1:
  2234. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2235. break;
  2236. default:
  2237. return -EINVAL;
  2238. pr_err("%s: err channels %d\n",
  2239. __func__, dai_data->channels);
  2240. break;
  2241. }
  2242. switch (params_format(params)) {
  2243. case SNDRV_PCM_FORMAT_S16_LE:
  2244. case SNDRV_PCM_FORMAT_SPECIAL:
  2245. dai_data->port_config.i2s.bit_width = 16;
  2246. break;
  2247. case SNDRV_PCM_FORMAT_S24_LE:
  2248. case SNDRV_PCM_FORMAT_S24_3LE:
  2249. dai_data->port_config.i2s.bit_width = 24;
  2250. break;
  2251. default:
  2252. pr_err("%s: format %d\n",
  2253. __func__, params_format(params));
  2254. return -EINVAL;
  2255. }
  2256. dai_data->rate = params_rate(params);
  2257. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2258. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2259. AFE_API_VERSION_I2S_CONFIG;
  2260. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2261. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  2262. dai_data->channels, dai_data->rate);
  2263. dai_data->port_config.i2s.channel_mode = 1;
  2264. return 0;
  2265. }
  2266. static u16 num_of_bits_set(u16 sd_line_mask)
  2267. {
  2268. u8 num_bits_set = 0;
  2269. while (sd_line_mask) {
  2270. num_bits_set++;
  2271. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  2272. }
  2273. return num_bits_set;
  2274. }
  2275. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  2276. struct snd_soc_dai *dai, int stream)
  2277. {
  2278. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2279. struct msm_i2s_data *i2s_pdata =
  2280. (struct msm_i2s_data *) dai->dev->platform_data;
  2281. dai_data->channels = params_channels(params);
  2282. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  2283. switch (dai_data->channels) {
  2284. case 2:
  2285. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2286. break;
  2287. case 1:
  2288. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2289. break;
  2290. default:
  2291. pr_warn("%s: greater than stereo has not been validated %d",
  2292. __func__, dai_data->channels);
  2293. break;
  2294. }
  2295. }
  2296. dai_data->rate = params_rate(params);
  2297. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2298. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2299. AFE_API_VERSION_I2S_CONFIG;
  2300. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2301. /* Q6 only supports 16 as now */
  2302. dai_data->port_config.i2s.bit_width = 16;
  2303. dai_data->port_config.i2s.channel_mode = 1;
  2304. return 0;
  2305. }
  2306. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  2307. struct snd_soc_dai *dai, int stream)
  2308. {
  2309. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2310. dai_data->channels = params_channels(params);
  2311. dai_data->rate = params_rate(params);
  2312. switch (params_format(params)) {
  2313. case SNDRV_PCM_FORMAT_S16_LE:
  2314. case SNDRV_PCM_FORMAT_SPECIAL:
  2315. dai_data->port_config.slim_sch.bit_width = 16;
  2316. break;
  2317. case SNDRV_PCM_FORMAT_S24_LE:
  2318. case SNDRV_PCM_FORMAT_S24_3LE:
  2319. dai_data->port_config.slim_sch.bit_width = 24;
  2320. break;
  2321. case SNDRV_PCM_FORMAT_S32_LE:
  2322. dai_data->port_config.slim_sch.bit_width = 32;
  2323. break;
  2324. default:
  2325. pr_err("%s: format %d\n",
  2326. __func__, params_format(params));
  2327. return -EINVAL;
  2328. }
  2329. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  2330. AFE_API_VERSION_SLIMBUS_CONFIG;
  2331. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  2332. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  2333. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  2334. "num_channel %hu shared_ch_mapping[0] %hu\n"
  2335. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  2336. "sample_rate %d\n", __func__,
  2337. dai_data->port_config.slim_sch.slimbus_dev_id,
  2338. dai_data->port_config.slim_sch.bit_width,
  2339. dai_data->port_config.slim_sch.data_format,
  2340. dai_data->port_config.slim_sch.num_channels,
  2341. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2342. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  2343. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  2344. dai_data->rate);
  2345. return 0;
  2346. }
  2347. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  2348. struct snd_soc_dai *dai, int stream)
  2349. {
  2350. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2351. dai_data->channels = params_channels(params);
  2352. dai_data->rate = params_rate(params);
  2353. switch (params_format(params)) {
  2354. case SNDRV_PCM_FORMAT_S16_LE:
  2355. case SNDRV_PCM_FORMAT_SPECIAL:
  2356. dai_data->port_config.usb_audio.bit_width = 16;
  2357. break;
  2358. case SNDRV_PCM_FORMAT_S24_LE:
  2359. case SNDRV_PCM_FORMAT_S24_3LE:
  2360. dai_data->port_config.usb_audio.bit_width = 24;
  2361. break;
  2362. case SNDRV_PCM_FORMAT_S32_LE:
  2363. dai_data->port_config.usb_audio.bit_width = 32;
  2364. break;
  2365. default:
  2366. dev_err(dai->dev, "%s: invalid format %d\n",
  2367. __func__, params_format(params));
  2368. return -EINVAL;
  2369. }
  2370. dai_data->port_config.usb_audio.cfg_minor_version =
  2371. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  2372. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  2373. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  2374. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  2375. "num_channel %hu sample_rate %d\n", __func__,
  2376. dai_data->port_config.usb_audio.dev_token,
  2377. dai_data->port_config.usb_audio.bit_width,
  2378. dai_data->port_config.usb_audio.data_format,
  2379. dai_data->port_config.usb_audio.num_channels,
  2380. dai_data->port_config.usb_audio.sample_rate);
  2381. return 0;
  2382. }
  2383. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  2384. struct snd_soc_dai *dai, int stream)
  2385. {
  2386. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2387. dai_data->channels = params_channels(params);
  2388. dai_data->rate = params_rate(params);
  2389. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  2390. dai_data->channels, dai_data->rate);
  2391. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  2392. pr_debug("%s: setting bt_fm parameters\n", __func__);
  2393. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  2394. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  2395. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  2396. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  2397. dai_data->port_config.int_bt_fm.bit_width = 16;
  2398. return 0;
  2399. }
  2400. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  2401. struct snd_soc_dai *dai)
  2402. {
  2403. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2404. dai_data->rate = params_rate(params);
  2405. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  2406. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  2407. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  2408. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  2409. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  2410. AFE_API_VERSION_RT_PROXY_CONFIG;
  2411. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  2412. dai_data->port_config.rtproxy.interleaved = 1;
  2413. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  2414. dai_data->port_config.rtproxy.jitter_allowance =
  2415. dai_data->port_config.rtproxy.frame_size/2;
  2416. dai_data->port_config.rtproxy.low_water_mark = 0;
  2417. dai_data->port_config.rtproxy.high_water_mark = 0;
  2418. return 0;
  2419. }
  2420. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  2421. struct snd_soc_dai *dai, int stream)
  2422. {
  2423. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2424. dai_data->channels = params_channels(params);
  2425. dai_data->rate = params_rate(params);
  2426. /* Q6 only supports 16 as now */
  2427. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  2428. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  2429. dai_data->port_config.pseudo_port.num_channels =
  2430. params_channels(params);
  2431. dai_data->port_config.pseudo_port.bit_width = 16;
  2432. dai_data->port_config.pseudo_port.data_format = 0;
  2433. dai_data->port_config.pseudo_port.timing_mode =
  2434. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  2435. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  2436. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  2437. "timing Mode %hu sample_rate %d\n", __func__,
  2438. dai_data->port_config.pseudo_port.bit_width,
  2439. dai_data->port_config.pseudo_port.num_channels,
  2440. dai_data->port_config.pseudo_port.data_format,
  2441. dai_data->port_config.pseudo_port.timing_mode,
  2442. dai_data->port_config.pseudo_port.sample_rate);
  2443. return 0;
  2444. }
  2445. /* Current implementation assumes hw_param is called once
  2446. * This may not be the case but what to do when ADM and AFE
  2447. * port are already opened and parameter changes
  2448. */
  2449. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  2450. struct snd_pcm_hw_params *params,
  2451. struct snd_soc_dai *dai)
  2452. {
  2453. int rc = 0;
  2454. switch (dai->id) {
  2455. case PRIMARY_I2S_TX:
  2456. case PRIMARY_I2S_RX:
  2457. case SECONDARY_I2S_RX:
  2458. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  2459. break;
  2460. case MI2S_RX:
  2461. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  2462. break;
  2463. case SLIMBUS_0_RX:
  2464. case SLIMBUS_1_RX:
  2465. case SLIMBUS_2_RX:
  2466. case SLIMBUS_3_RX:
  2467. case SLIMBUS_4_RX:
  2468. case SLIMBUS_5_RX:
  2469. case SLIMBUS_6_RX:
  2470. case SLIMBUS_7_RX:
  2471. case SLIMBUS_8_RX:
  2472. case SLIMBUS_9_RX:
  2473. case SLIMBUS_0_TX:
  2474. case SLIMBUS_1_TX:
  2475. case SLIMBUS_2_TX:
  2476. case SLIMBUS_3_TX:
  2477. case SLIMBUS_4_TX:
  2478. case SLIMBUS_5_TX:
  2479. case SLIMBUS_6_TX:
  2480. case SLIMBUS_7_TX:
  2481. case SLIMBUS_8_TX:
  2482. case SLIMBUS_9_TX:
  2483. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  2484. substream->stream);
  2485. break;
  2486. case INT_BT_SCO_RX:
  2487. case INT_BT_SCO_TX:
  2488. case INT_BT_A2DP_RX:
  2489. case INT_FM_RX:
  2490. case INT_FM_TX:
  2491. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  2492. break;
  2493. case AFE_PORT_ID_USB_RX:
  2494. case AFE_PORT_ID_USB_TX:
  2495. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  2496. substream->stream);
  2497. break;
  2498. case RT_PROXY_DAI_001_TX:
  2499. case RT_PROXY_DAI_001_RX:
  2500. case RT_PROXY_DAI_002_TX:
  2501. case RT_PROXY_DAI_002_RX:
  2502. case RT_PROXY_DAI_003_TX:
  2503. case RT_PROXY_PORT_002_TX:
  2504. case RT_PROXY_PORT_002_RX:
  2505. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  2506. break;
  2507. case VOICE_PLAYBACK_TX:
  2508. case VOICE2_PLAYBACK_TX:
  2509. case VOICE_RECORD_RX:
  2510. case VOICE_RECORD_TX:
  2511. rc = msm_dai_q6_pseudo_port_hw_params(params,
  2512. dai, substream->stream);
  2513. break;
  2514. default:
  2515. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  2516. rc = -EINVAL;
  2517. break;
  2518. }
  2519. return rc;
  2520. }
  2521. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  2522. struct snd_soc_dai *dai)
  2523. {
  2524. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2525. int rc = 0;
  2526. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2527. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2528. rc = afe_close(dai->id); /* can block */
  2529. if (rc < 0)
  2530. dev_err(dai->dev, "fail to close AFE port\n");
  2531. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  2532. *dai_data->status_mask);
  2533. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2534. }
  2535. }
  2536. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2537. {
  2538. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2539. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2540. case SND_SOC_DAIFMT_CBS_CFS:
  2541. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  2542. break;
  2543. case SND_SOC_DAIFMT_CBM_CFM:
  2544. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  2545. break;
  2546. default:
  2547. pr_err("%s: fmt 0x%x\n",
  2548. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2549. return -EINVAL;
  2550. }
  2551. return 0;
  2552. }
  2553. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2554. {
  2555. int rc = 0;
  2556. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  2557. dai->id, fmt);
  2558. switch (dai->id) {
  2559. case PRIMARY_I2S_TX:
  2560. case PRIMARY_I2S_RX:
  2561. case MI2S_RX:
  2562. case SECONDARY_I2S_RX:
  2563. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  2564. break;
  2565. default:
  2566. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2567. rc = -EINVAL;
  2568. break;
  2569. }
  2570. return rc;
  2571. }
  2572. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  2573. unsigned int tx_num, unsigned int *tx_slot,
  2574. unsigned int rx_num, unsigned int *rx_slot)
  2575. {
  2576. int rc = 0;
  2577. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2578. unsigned int i = 0;
  2579. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  2580. switch (dai->id) {
  2581. case SLIMBUS_0_RX:
  2582. case SLIMBUS_1_RX:
  2583. case SLIMBUS_2_RX:
  2584. case SLIMBUS_3_RX:
  2585. case SLIMBUS_4_RX:
  2586. case SLIMBUS_5_RX:
  2587. case SLIMBUS_6_RX:
  2588. case SLIMBUS_7_RX:
  2589. case SLIMBUS_8_RX:
  2590. case SLIMBUS_9_RX:
  2591. /*
  2592. * channel number to be between 128 and 255.
  2593. * For RX port use channel numbers
  2594. * from 138 to 144 for pre-Taiko
  2595. * from 144 to 159 for Taiko
  2596. */
  2597. if (!rx_slot) {
  2598. pr_err("%s: rx slot not found\n", __func__);
  2599. return -EINVAL;
  2600. }
  2601. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2602. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  2603. return -EINVAL;
  2604. }
  2605. for (i = 0; i < rx_num; i++) {
  2606. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2607. rx_slot[i];
  2608. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2609. __func__, i, rx_slot[i]);
  2610. }
  2611. dai_data->port_config.slim_sch.num_channels = rx_num;
  2612. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  2613. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  2614. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2615. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2616. break;
  2617. case SLIMBUS_0_TX:
  2618. case SLIMBUS_1_TX:
  2619. case SLIMBUS_2_TX:
  2620. case SLIMBUS_3_TX:
  2621. case SLIMBUS_4_TX:
  2622. case SLIMBUS_5_TX:
  2623. case SLIMBUS_6_TX:
  2624. case SLIMBUS_7_TX:
  2625. case SLIMBUS_8_TX:
  2626. case SLIMBUS_9_TX:
  2627. /*
  2628. * channel number to be between 128 and 255.
  2629. * For TX port use channel numbers
  2630. * from 128 to 137 for pre-Taiko
  2631. * from 128 to 143 for Taiko
  2632. */
  2633. if (!tx_slot) {
  2634. pr_err("%s: tx slot not found\n", __func__);
  2635. return -EINVAL;
  2636. }
  2637. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2638. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  2639. return -EINVAL;
  2640. }
  2641. for (i = 0; i < tx_num; i++) {
  2642. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2643. tx_slot[i];
  2644. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2645. __func__, i, tx_slot[i]);
  2646. }
  2647. dai_data->port_config.slim_sch.num_channels = tx_num;
  2648. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2649. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2650. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2651. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2652. break;
  2653. default:
  2654. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2655. rc = -EINVAL;
  2656. break;
  2657. }
  2658. return rc;
  2659. }
  2660. static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai,
  2661. int mute)
  2662. {
  2663. int port_id = dai->id;
  2664. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2665. if (mute && !dai_data->xt_logging_disable)
  2666. afe_get_sp_xt_logging_data(port_id);
  2667. return 0;
  2668. }
  2669. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2670. .prepare = msm_dai_q6_prepare,
  2671. .hw_params = msm_dai_q6_hw_params,
  2672. .shutdown = msm_dai_q6_shutdown,
  2673. .set_fmt = msm_dai_q6_set_fmt,
  2674. .set_channel_map = msm_dai_q6_set_channel_map,
  2675. };
  2676. static struct snd_soc_dai_ops msm_dai_slimbus_0_rx_ops = {
  2677. .prepare = msm_dai_q6_prepare,
  2678. .hw_params = msm_dai_q6_hw_params,
  2679. .shutdown = msm_dai_q6_shutdown,
  2680. .set_fmt = msm_dai_q6_set_fmt,
  2681. .set_channel_map = msm_dai_q6_set_channel_map,
  2682. .digital_mute = msm_dai_q6_spk_digital_mute,
  2683. };
  2684. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2685. struct snd_ctl_elem_value *ucontrol)
  2686. {
  2687. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2688. u16 port_id = ((struct soc_enum *)
  2689. kcontrol->private_value)->reg;
  2690. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2691. pr_debug("%s: setting cal_mode to %d\n",
  2692. __func__, dai_data->cal_mode);
  2693. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2694. return 0;
  2695. }
  2696. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2697. struct snd_ctl_elem_value *ucontrol)
  2698. {
  2699. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2700. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2701. return 0;
  2702. }
  2703. static int msm_dai_q6_cdc_dma_xt_logging_disable_put(
  2704. struct snd_kcontrol *kcontrol,
  2705. struct snd_ctl_elem_value *ucontrol)
  2706. {
  2707. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  2708. if (dai_data) {
  2709. dai_data->xt_logging_disable = ucontrol->value.integer.value[0];
  2710. pr_debug("%s: setting xt logging disable to %d\n",
  2711. __func__, dai_data->xt_logging_disable);
  2712. }
  2713. return 0;
  2714. }
  2715. static int msm_dai_q6_cdc_dma_xt_logging_disable_get(
  2716. struct snd_kcontrol *kcontrol,
  2717. struct snd_ctl_elem_value *ucontrol)
  2718. {
  2719. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  2720. if (dai_data)
  2721. ucontrol->value.integer.value[0] = dai_data->xt_logging_disable;
  2722. return 0;
  2723. }
  2724. static int msm_dai_q6_sb_xt_logging_disable_put(
  2725. struct snd_kcontrol *kcontrol,
  2726. struct snd_ctl_elem_value *ucontrol)
  2727. {
  2728. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2729. if (dai_data) {
  2730. dai_data->xt_logging_disable = ucontrol->value.integer.value[0];
  2731. pr_debug("%s: setting xt logging disable to %d\n",
  2732. __func__, dai_data->xt_logging_disable);
  2733. }
  2734. return 0;
  2735. }
  2736. static int msm_dai_q6_sb_xt_logging_disable_get(struct snd_kcontrol *kcontrol,
  2737. struct snd_ctl_elem_value *ucontrol)
  2738. {
  2739. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2740. if (dai_data)
  2741. ucontrol->value.integer.value[0] = dai_data->xt_logging_disable;
  2742. return 0;
  2743. }
  2744. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2745. struct snd_ctl_elem_value *ucontrol)
  2746. {
  2747. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2748. int value = ucontrol->value.integer.value[0];
  2749. if (dai_data) {
  2750. dai_data->port_config.slim_sch.data_format = value;
  2751. pr_debug("%s: format = %d\n", __func__, value);
  2752. }
  2753. return 0;
  2754. }
  2755. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2756. struct snd_ctl_elem_value *ucontrol)
  2757. {
  2758. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2759. if (dai_data)
  2760. ucontrol->value.integer.value[0] =
  2761. dai_data->port_config.slim_sch.data_format;
  2762. return 0;
  2763. }
  2764. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2765. struct snd_ctl_elem_value *ucontrol)
  2766. {
  2767. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2768. u32 val = ucontrol->value.integer.value[0];
  2769. if (dai_data) {
  2770. dai_data->port_config.usb_audio.dev_token = val;
  2771. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2772. dai_data->port_config.usb_audio.dev_token);
  2773. } else {
  2774. pr_err("%s: dai_data is NULL\n", __func__);
  2775. }
  2776. return 0;
  2777. }
  2778. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2779. struct snd_ctl_elem_value *ucontrol)
  2780. {
  2781. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2782. if (dai_data) {
  2783. ucontrol->value.integer.value[0] =
  2784. dai_data->port_config.usb_audio.dev_token;
  2785. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2786. dai_data->port_config.usb_audio.dev_token);
  2787. } else {
  2788. pr_err("%s: dai_data is NULL\n", __func__);
  2789. }
  2790. return 0;
  2791. }
  2792. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2793. struct snd_ctl_elem_value *ucontrol)
  2794. {
  2795. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2796. u32 val = ucontrol->value.integer.value[0];
  2797. if (dai_data) {
  2798. dai_data->port_config.usb_audio.endian = val;
  2799. pr_debug("%s: endian = 0x%x\n", __func__,
  2800. dai_data->port_config.usb_audio.endian);
  2801. } else {
  2802. pr_err("%s: dai_data is NULL\n", __func__);
  2803. return -EINVAL;
  2804. }
  2805. return 0;
  2806. }
  2807. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2808. struct snd_ctl_elem_value *ucontrol)
  2809. {
  2810. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2811. if (dai_data) {
  2812. ucontrol->value.integer.value[0] =
  2813. dai_data->port_config.usb_audio.endian;
  2814. pr_debug("%s: endian = 0x%x\n", __func__,
  2815. dai_data->port_config.usb_audio.endian);
  2816. } else {
  2817. pr_err("%s: dai_data is NULL\n", __func__);
  2818. return -EINVAL;
  2819. }
  2820. return 0;
  2821. }
  2822. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2823. struct snd_ctl_elem_value *ucontrol)
  2824. {
  2825. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2826. u32 val = ucontrol->value.integer.value[0];
  2827. if (!dai_data) {
  2828. pr_err("%s: dai_data is NULL\n", __func__);
  2829. return -EINVAL;
  2830. }
  2831. dai_data->port_config.usb_audio.service_interval = val;
  2832. pr_debug("%s: new service interval = %u\n", __func__,
  2833. dai_data->port_config.usb_audio.service_interval);
  2834. return 0;
  2835. }
  2836. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2837. struct snd_ctl_elem_value *ucontrol)
  2838. {
  2839. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2840. if (!dai_data) {
  2841. pr_err("%s: dai_data is NULL\n", __func__);
  2842. return -EINVAL;
  2843. }
  2844. ucontrol->value.integer.value[0] =
  2845. dai_data->port_config.usb_audio.service_interval;
  2846. pr_debug("%s: service interval = %d\n", __func__,
  2847. dai_data->port_config.usb_audio.service_interval);
  2848. return 0;
  2849. }
  2850. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2851. struct snd_ctl_elem_info *uinfo)
  2852. {
  2853. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2854. uinfo->count = sizeof(struct afe_enc_config);
  2855. return 0;
  2856. }
  2857. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2858. struct snd_ctl_elem_value *ucontrol)
  2859. {
  2860. int ret = 0;
  2861. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2862. if (dai_data) {
  2863. int format_size = sizeof(dai_data->enc_config.format);
  2864. pr_debug("%s: encoder config for %d format\n",
  2865. __func__, dai_data->enc_config.format);
  2866. memcpy(ucontrol->value.bytes.data,
  2867. &dai_data->enc_config.format,
  2868. format_size);
  2869. switch (dai_data->enc_config.format) {
  2870. case ENC_FMT_SBC:
  2871. memcpy(ucontrol->value.bytes.data + format_size,
  2872. &dai_data->enc_config.data,
  2873. sizeof(struct asm_sbc_enc_cfg_t));
  2874. break;
  2875. case ENC_FMT_AAC_V2:
  2876. memcpy(ucontrol->value.bytes.data + format_size,
  2877. &dai_data->enc_config.data,
  2878. sizeof(struct asm_aac_enc_cfg_t));
  2879. break;
  2880. case ENC_FMT_APTX:
  2881. memcpy(ucontrol->value.bytes.data + format_size,
  2882. &dai_data->enc_config.data,
  2883. sizeof(struct asm_aptx_enc_cfg_t));
  2884. break;
  2885. case ENC_FMT_APTX_HD:
  2886. memcpy(ucontrol->value.bytes.data + format_size,
  2887. &dai_data->enc_config.data,
  2888. sizeof(struct asm_custom_enc_cfg_t));
  2889. break;
  2890. case ENC_FMT_CELT:
  2891. memcpy(ucontrol->value.bytes.data + format_size,
  2892. &dai_data->enc_config.data,
  2893. sizeof(struct asm_celt_enc_cfg_t));
  2894. break;
  2895. case ENC_FMT_LDAC:
  2896. memcpy(ucontrol->value.bytes.data + format_size,
  2897. &dai_data->enc_config.data,
  2898. sizeof(struct asm_ldac_enc_cfg_t));
  2899. break;
  2900. case ENC_FMT_APTX_ADAPTIVE:
  2901. memcpy(ucontrol->value.bytes.data + format_size,
  2902. &dai_data->enc_config.data,
  2903. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2904. break;
  2905. case ENC_FMT_APTX_AD_SPEECH:
  2906. memcpy(ucontrol->value.bytes.data + format_size,
  2907. &dai_data->enc_config.data,
  2908. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2909. break;
  2910. case ENC_FMT_LC3:
  2911. memcpy(ucontrol->value.bytes.data + format_size,
  2912. &dai_data->enc_config.data,
  2913. sizeof(struct asm_enc_lc3_cfg_t));
  2914. break;
  2915. default:
  2916. pr_debug("%s: unknown format = %d\n",
  2917. __func__, dai_data->enc_config.format);
  2918. ret = -EINVAL;
  2919. break;
  2920. }
  2921. }
  2922. return ret;
  2923. }
  2924. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2925. struct snd_ctl_elem_value *ucontrol)
  2926. {
  2927. int ret = 0;
  2928. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2929. if (dai_data) {
  2930. int format_size = sizeof(dai_data->enc_config.format);
  2931. memset(&dai_data->enc_config, 0x0,
  2932. sizeof(struct afe_enc_config));
  2933. memcpy(&dai_data->enc_config.format,
  2934. ucontrol->value.bytes.data,
  2935. format_size);
  2936. pr_debug("%s: Received encoder config for %d format\n",
  2937. __func__, dai_data->enc_config.format);
  2938. switch (dai_data->enc_config.format) {
  2939. case ENC_FMT_SBC:
  2940. memcpy(&dai_data->enc_config.data,
  2941. ucontrol->value.bytes.data + format_size,
  2942. sizeof(struct asm_sbc_enc_cfg_t));
  2943. break;
  2944. case ENC_FMT_AAC_V2:
  2945. memcpy(&dai_data->enc_config.data,
  2946. ucontrol->value.bytes.data + format_size,
  2947. sizeof(struct asm_aac_enc_cfg_t));
  2948. break;
  2949. case ENC_FMT_APTX:
  2950. memcpy(&dai_data->enc_config.data,
  2951. ucontrol->value.bytes.data + format_size,
  2952. sizeof(struct asm_aptx_enc_cfg_t));
  2953. break;
  2954. case ENC_FMT_APTX_HD:
  2955. memcpy(&dai_data->enc_config.data,
  2956. ucontrol->value.bytes.data + format_size,
  2957. sizeof(struct asm_custom_enc_cfg_t));
  2958. break;
  2959. case ENC_FMT_CELT:
  2960. memcpy(&dai_data->enc_config.data,
  2961. ucontrol->value.bytes.data + format_size,
  2962. sizeof(struct asm_celt_enc_cfg_t));
  2963. break;
  2964. case ENC_FMT_LDAC:
  2965. memcpy(&dai_data->enc_config.data,
  2966. ucontrol->value.bytes.data + format_size,
  2967. sizeof(struct asm_ldac_enc_cfg_t));
  2968. break;
  2969. case ENC_FMT_APTX_ADAPTIVE:
  2970. memcpy(&dai_data->enc_config.data,
  2971. ucontrol->value.bytes.data + format_size,
  2972. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2973. break;
  2974. case ENC_FMT_APTX_AD_SPEECH:
  2975. memcpy(&dai_data->enc_config.data,
  2976. ucontrol->value.bytes.data + format_size,
  2977. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2978. break;
  2979. case ENC_FMT_LC3:
  2980. memcpy(&dai_data->enc_config.data,
  2981. ucontrol->value.bytes.data + format_size,
  2982. sizeof(struct asm_enc_lc3_cfg_t));
  2983. break;
  2984. default:
  2985. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2986. __func__, dai_data->enc_config.format);
  2987. ret = -EINVAL;
  2988. break;
  2989. }
  2990. } else
  2991. ret = -EINVAL;
  2992. return ret;
  2993. }
  2994. static const char *const afe_chs_text[] = {"Zero", "One", "Two"};
  2995. static const struct soc_enum afe_chs_enum[] = {
  2996. SOC_ENUM_SINGLE_EXT(3, afe_chs_text),
  2997. };
  2998. static const char *const afe_bit_format_text[] = {"S16_LE", "S24_LE",
  2999. "S32_LE"};
  3000. static const struct soc_enum afe_bit_format_enum[] = {
  3001. SOC_ENUM_SINGLE_EXT(3, afe_bit_format_text),
  3002. };
  3003. static const char *const tws_chs_mode_text[] = {"Zero", "One", "Two"};
  3004. static const struct soc_enum tws_chs_mode_enum[] = {
  3005. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tws_chs_mode_text), tws_chs_mode_text),
  3006. };
  3007. static const char *const lc3_chs_mode_text[] = {"Zero", "One", "Two"};
  3008. static const struct soc_enum lc3_chs_mode_enum[] = {
  3009. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lc3_chs_mode_text), lc3_chs_mode_text),
  3010. };
  3011. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  3012. struct snd_ctl_elem_value *ucontrol)
  3013. {
  3014. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3015. if (dai_data) {
  3016. ucontrol->value.integer.value[0] = dai_data->afe_rx_in_channels;
  3017. pr_debug("%s:afe input channel = %d\n",
  3018. __func__, dai_data->afe_rx_in_channels);
  3019. }
  3020. return 0;
  3021. }
  3022. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  3023. struct snd_ctl_elem_value *ucontrol)
  3024. {
  3025. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3026. if (dai_data) {
  3027. dai_data->afe_rx_in_channels = ucontrol->value.integer.value[0];
  3028. pr_debug("%s: updating afe input channel : %d\n",
  3029. __func__, dai_data->afe_rx_in_channels);
  3030. }
  3031. return 0;
  3032. }
  3033. static int msm_dai_q6_tws_channel_mode_get(struct snd_kcontrol *kcontrol,
  3034. struct snd_ctl_elem_value *ucontrol)
  3035. {
  3036. struct snd_soc_dai *dai = kcontrol->private_data;
  3037. struct msm_dai_q6_dai_data *dai_data = NULL;
  3038. if (dai)
  3039. dai_data = dev_get_drvdata(dai->dev);
  3040. if (dai_data) {
  3041. ucontrol->value.integer.value[0] =
  3042. dai_data->enc_config.mono_mode;
  3043. pr_debug("%s:tws channel mode = %d\n",
  3044. __func__, dai_data->enc_config.mono_mode);
  3045. }
  3046. return 0;
  3047. }
  3048. static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol,
  3049. struct snd_ctl_elem_value *ucontrol)
  3050. {
  3051. struct snd_soc_dai *dai = kcontrol->private_data;
  3052. struct msm_dai_q6_dai_data *dai_data = NULL;
  3053. int ret = 0;
  3054. u32 format = 0;
  3055. if (dai)
  3056. dai_data = dev_get_drvdata(dai->dev);
  3057. if (dai_data)
  3058. format = dai_data->enc_config.format;
  3059. else
  3060. goto exit;
  3061. if (format == ENC_FMT_APTX || format == ENC_FMT_APTX_ADAPTIVE) {
  3062. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3063. ret = afe_set_tws_channel_mode(format,
  3064. dai->id, ucontrol->value.integer.value[0]);
  3065. if (ret < 0) {
  3066. pr_err("%s: channel mode setting failed for TWS\n",
  3067. __func__);
  3068. goto exit;
  3069. } else {
  3070. pr_debug("%s: updating tws channel mode : %d\n",
  3071. __func__, dai_data->enc_config.mono_mode);
  3072. }
  3073. }
  3074. if (ucontrol->value.integer.value[0] ==
  3075. MSM_DAI_TWS_CHANNEL_MODE_ONE ||
  3076. ucontrol->value.integer.value[0] ==
  3077. MSM_DAI_TWS_CHANNEL_MODE_TWO)
  3078. dai_data->enc_config.mono_mode =
  3079. ucontrol->value.integer.value[0];
  3080. else
  3081. return -EINVAL;
  3082. }
  3083. exit:
  3084. return ret;
  3085. }
  3086. static int msm_dai_q6_lc3_channel_mode_get(struct snd_kcontrol *kcontrol,
  3087. struct snd_ctl_elem_value *ucontrol)
  3088. {
  3089. struct snd_soc_dai *dai = kcontrol->private_data;
  3090. struct msm_dai_q6_dai_data *dai_data = NULL;
  3091. if (dai)
  3092. dai_data = dev_get_drvdata(dai->dev);
  3093. if (dai_data) {
  3094. ucontrol->value.integer.value[0] =
  3095. dai_data->enc_config.lc3_mono_mode;
  3096. pr_debug("%s:lc3 channel mode = %d\n",
  3097. __func__, dai_data->enc_config.lc3_mono_mode);
  3098. }
  3099. return 0;
  3100. }
  3101. static int msm_dai_q6_lc3_channel_mode_put(struct snd_kcontrol *kcontrol,
  3102. struct snd_ctl_elem_value *ucontrol)
  3103. {
  3104. struct snd_soc_dai *dai = kcontrol->private_data;
  3105. struct msm_dai_q6_dai_data *dai_data = NULL;
  3106. int ret = 0;
  3107. u32 format = 0;
  3108. if (dai)
  3109. dai_data = dev_get_drvdata(dai->dev);
  3110. if (dai_data)
  3111. format = dai_data->enc_config.format;
  3112. else
  3113. goto exit;
  3114. if (format == ENC_FMT_LC3) {
  3115. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3116. ret = afe_set_lc3_channel_mode(format,
  3117. dai->id, ucontrol->value.integer.value[0]);
  3118. if (ret < 0) {
  3119. pr_err("%s: channel mode setting failed for LC3\n",
  3120. __func__);
  3121. goto exit;
  3122. } else {
  3123. pr_debug("%s: updating lc3 channel mode : %d\n",
  3124. __func__, dai_data->enc_config.lc3_mono_mode);
  3125. }
  3126. }
  3127. if (ucontrol->value.integer.value[0] ==
  3128. MSM_DAI_LC3_CHANNEL_MODE_ONE ||
  3129. ucontrol->value.integer.value[0] ==
  3130. MSM_DAI_LC3_CHANNEL_MODE_TWO)
  3131. dai_data->enc_config.lc3_mono_mode =
  3132. ucontrol->value.integer.value[0];
  3133. else
  3134. return -EINVAL;
  3135. }
  3136. exit:
  3137. return ret;
  3138. }
  3139. static int msm_dai_q6_afe_input_bit_format_get(
  3140. struct snd_kcontrol *kcontrol,
  3141. struct snd_ctl_elem_value *ucontrol)
  3142. {
  3143. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3144. if (!dai_data) {
  3145. pr_err("%s: Invalid dai data\n", __func__);
  3146. return -EINVAL;
  3147. }
  3148. switch (dai_data->afe_rx_in_bitformat) {
  3149. case SNDRV_PCM_FORMAT_S32_LE:
  3150. ucontrol->value.integer.value[0] = 2;
  3151. break;
  3152. case SNDRV_PCM_FORMAT_S24_LE:
  3153. ucontrol->value.integer.value[0] = 1;
  3154. break;
  3155. case SNDRV_PCM_FORMAT_S16_LE:
  3156. default:
  3157. ucontrol->value.integer.value[0] = 0;
  3158. break;
  3159. }
  3160. pr_debug("%s: afe input bit format : %ld\n",
  3161. __func__, ucontrol->value.integer.value[0]);
  3162. return 0;
  3163. }
  3164. static int msm_dai_q6_afe_input_bit_format_put(
  3165. struct snd_kcontrol *kcontrol,
  3166. struct snd_ctl_elem_value *ucontrol)
  3167. {
  3168. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3169. if (!dai_data) {
  3170. pr_err("%s: Invalid dai data\n", __func__);
  3171. return -EINVAL;
  3172. }
  3173. switch (ucontrol->value.integer.value[0]) {
  3174. case 2:
  3175. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  3176. break;
  3177. case 1:
  3178. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  3179. break;
  3180. case 0:
  3181. default:
  3182. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  3183. break;
  3184. }
  3185. pr_debug("%s: updating afe input bit format : %d\n",
  3186. __func__, dai_data->afe_rx_in_bitformat);
  3187. return 0;
  3188. }
  3189. static int msm_dai_q6_afe_output_bit_format_get(
  3190. struct snd_kcontrol *kcontrol,
  3191. struct snd_ctl_elem_value *ucontrol)
  3192. {
  3193. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3194. if (!dai_data) {
  3195. pr_err("%s: Invalid dai data\n", __func__);
  3196. return -EINVAL;
  3197. }
  3198. switch (dai_data->afe_tx_out_bitformat) {
  3199. case SNDRV_PCM_FORMAT_S32_LE:
  3200. ucontrol->value.integer.value[0] = 2;
  3201. break;
  3202. case SNDRV_PCM_FORMAT_S24_LE:
  3203. ucontrol->value.integer.value[0] = 1;
  3204. break;
  3205. case SNDRV_PCM_FORMAT_S16_LE:
  3206. default:
  3207. ucontrol->value.integer.value[0] = 0;
  3208. break;
  3209. }
  3210. pr_debug("%s: afe output bit format : %ld\n",
  3211. __func__, ucontrol->value.integer.value[0]);
  3212. return 0;
  3213. }
  3214. static int msm_dai_q6_afe_output_bit_format_put(
  3215. struct snd_kcontrol *kcontrol,
  3216. struct snd_ctl_elem_value *ucontrol)
  3217. {
  3218. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3219. if (!dai_data) {
  3220. pr_err("%s: Invalid dai data\n", __func__);
  3221. return -EINVAL;
  3222. }
  3223. switch (ucontrol->value.integer.value[0]) {
  3224. case 2:
  3225. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  3226. break;
  3227. case 1:
  3228. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  3229. break;
  3230. case 0:
  3231. default:
  3232. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  3233. break;
  3234. }
  3235. pr_debug("%s: updating afe output bit format : %d\n",
  3236. __func__, dai_data->afe_tx_out_bitformat);
  3237. return 0;
  3238. }
  3239. static int msm_dai_q6_afe_output_channel_get(struct snd_kcontrol *kcontrol,
  3240. struct snd_ctl_elem_value *ucontrol)
  3241. {
  3242. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3243. if (dai_data) {
  3244. ucontrol->value.integer.value[0] =
  3245. dai_data->afe_tx_out_channels;
  3246. pr_debug("%s:afe output channel = %d\n",
  3247. __func__, dai_data->afe_tx_out_channels);
  3248. }
  3249. return 0;
  3250. }
  3251. static int msm_dai_q6_afe_output_channel_put(struct snd_kcontrol *kcontrol,
  3252. struct snd_ctl_elem_value *ucontrol)
  3253. {
  3254. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3255. if (dai_data) {
  3256. dai_data->afe_tx_out_channels =
  3257. ucontrol->value.integer.value[0];
  3258. pr_debug("%s: updating afe output channel : %d\n",
  3259. __func__, dai_data->afe_tx_out_channels);
  3260. }
  3261. return 0;
  3262. }
  3263. static int msm_dai_q6_afe_scrambler_mode_get(
  3264. struct snd_kcontrol *kcontrol,
  3265. struct snd_ctl_elem_value *ucontrol)
  3266. {
  3267. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3268. if (!dai_data) {
  3269. pr_err("%s: Invalid dai data\n", __func__);
  3270. return -EINVAL;
  3271. }
  3272. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  3273. return 0;
  3274. }
  3275. static int msm_dai_q6_afe_scrambler_mode_put(
  3276. struct snd_kcontrol *kcontrol,
  3277. struct snd_ctl_elem_value *ucontrol)
  3278. {
  3279. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3280. if (!dai_data) {
  3281. pr_err("%s: Invalid dai data\n", __func__);
  3282. return -EINVAL;
  3283. }
  3284. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  3285. pr_debug("%s: afe scrambler mode : %d\n",
  3286. __func__, dai_data->enc_config.scrambler_mode);
  3287. return 0;
  3288. }
  3289. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  3290. {
  3291. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3292. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3293. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3294. .name = "SLIM_7_RX Encoder Config",
  3295. .info = msm_dai_q6_afe_enc_cfg_info,
  3296. .get = msm_dai_q6_afe_enc_cfg_get,
  3297. .put = msm_dai_q6_afe_enc_cfg_put,
  3298. },
  3299. SOC_ENUM_EXT("AFE Input Channels", afe_chs_enum[0],
  3300. msm_dai_q6_afe_input_channel_get,
  3301. msm_dai_q6_afe_input_channel_put),
  3302. SOC_ENUM_EXT("AFE Input Bit Format", afe_bit_format_enum[0],
  3303. msm_dai_q6_afe_input_bit_format_get,
  3304. msm_dai_q6_afe_input_bit_format_put),
  3305. SOC_SINGLE_EXT("AFE Scrambler Mode",
  3306. 0, 0, 1, 0,
  3307. msm_dai_q6_afe_scrambler_mode_get,
  3308. msm_dai_q6_afe_scrambler_mode_put),
  3309. SOC_ENUM_EXT("TWS Channel Mode", tws_chs_mode_enum[0],
  3310. msm_dai_q6_tws_channel_mode_get,
  3311. msm_dai_q6_tws_channel_mode_put),
  3312. {
  3313. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3314. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3315. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3316. .name = "SLIM_7_RX APTX_AD Enc Cfg",
  3317. .info = msm_dai_q6_afe_enc_cfg_info,
  3318. .get = msm_dai_q6_afe_enc_cfg_get,
  3319. .put = msm_dai_q6_afe_enc_cfg_put,
  3320. },
  3321. SOC_ENUM_EXT("LC3 Channel Mode", lc3_chs_mode_enum[0],
  3322. msm_dai_q6_lc3_channel_mode_get,
  3323. msm_dai_q6_lc3_channel_mode_put)
  3324. };
  3325. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  3326. struct snd_ctl_elem_info *uinfo)
  3327. {
  3328. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3329. uinfo->count = sizeof(struct afe_dec_config);
  3330. return 0;
  3331. }
  3332. static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3333. struct snd_ctl_elem_value *ucontrol)
  3334. {
  3335. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3336. u32 format_size = 0;
  3337. u32 abr_size = 0;
  3338. if (!dai_data) {
  3339. pr_err("%s: Invalid dai data\n", __func__);
  3340. return -EINVAL;
  3341. }
  3342. format_size = sizeof(dai_data->dec_config.format);
  3343. memcpy(ucontrol->value.bytes.data,
  3344. &dai_data->dec_config.format,
  3345. format_size);
  3346. pr_debug("%s: abr_dec_cfg for %d format\n",
  3347. __func__, dai_data->dec_config.format);
  3348. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3349. memcpy(ucontrol->value.bytes.data + format_size,
  3350. &dai_data->dec_config.abr_dec_cfg,
  3351. sizeof(struct afe_imc_dec_enc_info));
  3352. switch (dai_data->dec_config.format) {
  3353. case DEC_FMT_APTX_AD_SPEECH:
  3354. pr_debug("%s: afe_dec_cfg for %d format\n",
  3355. __func__, dai_data->dec_config.format);
  3356. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3357. &dai_data->dec_config.data,
  3358. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3359. break;
  3360. case ASM_MEDIA_FMT_LC3:
  3361. pr_debug("%s: afe_dec_cfg for %d format\n",
  3362. __func__, dai_data->dec_config.format);
  3363. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3364. &dai_data->dec_config.data,
  3365. sizeof(struct asm_lc3_dec_cfg_t));
  3366. break;
  3367. default:
  3368. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3369. __func__, dai_data->dec_config.format);
  3370. break;
  3371. }
  3372. return 0;
  3373. }
  3374. static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3375. struct snd_ctl_elem_value *ucontrol)
  3376. {
  3377. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3378. u32 format_size = 0;
  3379. u32 abr_size = 0;
  3380. if (!dai_data) {
  3381. pr_err("%s: Invalid dai data\n", __func__);
  3382. return -EINVAL;
  3383. }
  3384. memset(&dai_data->dec_config, 0x0,
  3385. sizeof(struct afe_dec_config));
  3386. format_size = sizeof(dai_data->dec_config.format);
  3387. memcpy(&dai_data->dec_config.format,
  3388. ucontrol->value.bytes.data,
  3389. format_size);
  3390. pr_debug("%s: abr_dec_cfg for %d format\n",
  3391. __func__, dai_data->dec_config.format);
  3392. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3393. memcpy(&dai_data->dec_config.abr_dec_cfg,
  3394. ucontrol->value.bytes.data + format_size,
  3395. sizeof(struct afe_imc_dec_enc_info));
  3396. dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
  3397. switch (dai_data->dec_config.format) {
  3398. case DEC_FMT_APTX_AD_SPEECH:
  3399. pr_debug("%s: afe_dec_cfg for %d format\n",
  3400. __func__, dai_data->dec_config.format);
  3401. memcpy(&dai_data->dec_config.data,
  3402. ucontrol->value.bytes.data + format_size + abr_size,
  3403. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3404. break;
  3405. case ASM_MEDIA_FMT_LC3:
  3406. pr_debug("%s: afe_dec_cfg for %d format\n",
  3407. __func__, dai_data->dec_config.format);
  3408. memcpy(&dai_data->dec_config.data,
  3409. ucontrol->value.bytes.data + format_size + abr_size,
  3410. sizeof(struct asm_lc3_dec_cfg_t));
  3411. break;
  3412. default:
  3413. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3414. __func__, dai_data->dec_config.format);
  3415. break;
  3416. }
  3417. return 0;
  3418. }
  3419. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3420. struct snd_ctl_elem_value *ucontrol)
  3421. {
  3422. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3423. u32 format_size = 0;
  3424. int ret = 0;
  3425. if (!dai_data) {
  3426. pr_err("%s: Invalid dai data\n", __func__);
  3427. return -EINVAL;
  3428. }
  3429. format_size = sizeof(dai_data->dec_config.format);
  3430. memcpy(ucontrol->value.bytes.data,
  3431. &dai_data->dec_config.format,
  3432. format_size);
  3433. switch (dai_data->dec_config.format) {
  3434. case DEC_FMT_AAC_V2:
  3435. memcpy(ucontrol->value.bytes.data + format_size,
  3436. &dai_data->dec_config.data,
  3437. sizeof(struct asm_aac_dec_cfg_v2_t));
  3438. break;
  3439. case DEC_FMT_APTX_ADAPTIVE:
  3440. memcpy(ucontrol->value.bytes.data + format_size,
  3441. &dai_data->dec_config.data,
  3442. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3443. break;
  3444. case DEC_FMT_SBC:
  3445. case DEC_FMT_MP3:
  3446. /* No decoder specific data available */
  3447. break;
  3448. default:
  3449. pr_err("%s: Invalid format %d\n",
  3450. __func__, dai_data->dec_config.format);
  3451. ret = -EINVAL;
  3452. break;
  3453. }
  3454. return ret;
  3455. }
  3456. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3457. struct snd_ctl_elem_value *ucontrol)
  3458. {
  3459. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3460. u32 format_size = 0;
  3461. int ret = 0;
  3462. if (!dai_data) {
  3463. pr_err("%s: Invalid dai data\n", __func__);
  3464. return -EINVAL;
  3465. }
  3466. memset(&dai_data->dec_config, 0x0,
  3467. sizeof(struct afe_dec_config));
  3468. format_size = sizeof(dai_data->dec_config.format);
  3469. memcpy(&dai_data->dec_config.format,
  3470. ucontrol->value.bytes.data,
  3471. format_size);
  3472. pr_debug("%s: Received decoder config for %d format\n",
  3473. __func__, dai_data->dec_config.format);
  3474. switch (dai_data->dec_config.format) {
  3475. case DEC_FMT_AAC_V2:
  3476. memcpy(&dai_data->dec_config.data,
  3477. ucontrol->value.bytes.data + format_size,
  3478. sizeof(struct asm_aac_dec_cfg_v2_t));
  3479. break;
  3480. case DEC_FMT_SBC:
  3481. memcpy(&dai_data->dec_config.data,
  3482. ucontrol->value.bytes.data + format_size,
  3483. sizeof(struct asm_sbc_dec_cfg_t));
  3484. break;
  3485. case DEC_FMT_APTX_ADAPTIVE:
  3486. memcpy(&dai_data->dec_config.data,
  3487. ucontrol->value.bytes.data + format_size,
  3488. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3489. break;
  3490. default:
  3491. pr_err("%s: Invalid format %d\n",
  3492. __func__, dai_data->dec_config.format);
  3493. ret = -EINVAL;
  3494. break;
  3495. }
  3496. return ret;
  3497. }
  3498. static int msm_dai_q6_afe_enable_ttp_info(struct snd_kcontrol *kcontrol,
  3499. struct snd_ctl_elem_info *uinfo)
  3500. {
  3501. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3502. uinfo->count = sizeof(struct afe_ttp_gen_enable_t);
  3503. return 0;
  3504. }
  3505. static int msm_dai_q6_afe_enable_ttp_get(struct snd_kcontrol *kcontrol,
  3506. struct snd_ctl_elem_value *ucontrol)
  3507. {
  3508. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3509. pr_debug("%s:\n", __func__);
  3510. if (!dai_data) {
  3511. pr_err("%s: Invalid dai data\n", __func__);
  3512. return -EINVAL;
  3513. }
  3514. memcpy(ucontrol->value.bytes.data,
  3515. &dai_data->ttp_config.ttp_gen_enable,
  3516. sizeof(struct afe_ttp_gen_enable_t));
  3517. return 0;
  3518. }
  3519. static int msm_dai_q6_afe_enable_ttp_put(struct snd_kcontrol *kcontrol,
  3520. struct snd_ctl_elem_value *ucontrol)
  3521. {
  3522. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3523. pr_debug("%s:\n", __func__);
  3524. if (!dai_data) {
  3525. pr_err("%s: Invalid dai data\n", __func__);
  3526. return -EINVAL;
  3527. }
  3528. memcpy(&dai_data->ttp_config.ttp_gen_enable,
  3529. ucontrol->value.bytes.data,
  3530. sizeof(struct afe_ttp_gen_enable_t));
  3531. return 0;
  3532. }
  3533. static int msm_dai_q6_afe_ttp_cfg_info(struct snd_kcontrol *kcontrol,
  3534. struct snd_ctl_elem_info *uinfo)
  3535. {
  3536. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3537. uinfo->count = sizeof(struct afe_ttp_gen_cfg_t);
  3538. return 0;
  3539. }
  3540. static int msm_dai_q6_afe_ttp_cfg_get(struct snd_kcontrol *kcontrol,
  3541. struct snd_ctl_elem_value *ucontrol)
  3542. {
  3543. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3544. pr_debug("%s:\n", __func__);
  3545. if (!dai_data) {
  3546. pr_err("%s: Invalid dai data\n", __func__);
  3547. return -EINVAL;
  3548. }
  3549. memcpy(ucontrol->value.bytes.data,
  3550. &dai_data->ttp_config.ttp_gen_cfg,
  3551. sizeof(struct afe_ttp_gen_cfg_t));
  3552. return 0;
  3553. }
  3554. static int msm_dai_q6_afe_ttp_cfg_put(struct snd_kcontrol *kcontrol,
  3555. struct snd_ctl_elem_value *ucontrol)
  3556. {
  3557. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3558. pr_debug("%s: Received ttp config\n", __func__);
  3559. if (!dai_data) {
  3560. pr_err("%s: Invalid dai data\n", __func__);
  3561. return -EINVAL;
  3562. }
  3563. memcpy(&dai_data->ttp_config.ttp_gen_cfg,
  3564. ucontrol->value.bytes.data, sizeof(struct afe_ttp_gen_cfg_t));
  3565. return 0;
  3566. }
  3567. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  3568. {
  3569. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3570. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3571. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3572. .name = "SLIM_7_TX Decoder Config",
  3573. .info = msm_dai_q6_afe_dec_cfg_info,
  3574. .get = msm_dai_q6_afe_feedback_dec_cfg_get,
  3575. .put = msm_dai_q6_afe_feedback_dec_cfg_put,
  3576. },
  3577. {
  3578. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3579. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3580. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3581. .name = "SLIM_9_TX Decoder Config",
  3582. .info = msm_dai_q6_afe_dec_cfg_info,
  3583. .get = msm_dai_q6_afe_dec_cfg_get,
  3584. .put = msm_dai_q6_afe_dec_cfg_put,
  3585. },
  3586. SOC_ENUM_EXT("AFE Output Channels", afe_chs_enum[0],
  3587. msm_dai_q6_afe_output_channel_get,
  3588. msm_dai_q6_afe_output_channel_put),
  3589. SOC_ENUM_EXT("AFE Output Bit Format", afe_bit_format_enum[0],
  3590. msm_dai_q6_afe_output_bit_format_get,
  3591. msm_dai_q6_afe_output_bit_format_put),
  3592. };
  3593. static const struct snd_kcontrol_new afe_ttp_config_controls[] = {
  3594. {
  3595. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3596. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3597. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3598. .name = "TTP Enable",
  3599. .info = msm_dai_q6_afe_enable_ttp_info,
  3600. .get = msm_dai_q6_afe_enable_ttp_get,
  3601. .put = msm_dai_q6_afe_enable_ttp_put,
  3602. },
  3603. {
  3604. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3605. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3606. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3607. .name = "AFE TTP config",
  3608. .info = msm_dai_q6_afe_ttp_cfg_info,
  3609. .get = msm_dai_q6_afe_ttp_cfg_get,
  3610. .put = msm_dai_q6_afe_ttp_cfg_put,
  3611. },
  3612. };
  3613. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  3614. struct snd_ctl_elem_info *uinfo)
  3615. {
  3616. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3617. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  3618. return 0;
  3619. }
  3620. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  3621. struct snd_ctl_elem_value *ucontrol)
  3622. {
  3623. int ret = -EINVAL;
  3624. struct afe_param_id_dev_timing_stats timing_stats;
  3625. struct snd_soc_dai *dai = kcontrol->private_data;
  3626. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3627. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3628. pr_debug("%s: afe port not started. dai_data->status_mask = %ld\n",
  3629. __func__, *dai_data->status_mask);
  3630. goto done;
  3631. }
  3632. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  3633. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  3634. if (ret) {
  3635. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  3636. __func__, dai->id, ret);
  3637. goto done;
  3638. }
  3639. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  3640. sizeof(struct afe_param_id_dev_timing_stats));
  3641. done:
  3642. return ret;
  3643. }
  3644. static const char * const afe_cal_mode_text[] = {
  3645. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  3646. };
  3647. static const struct soc_enum slim_2_rx_enum =
  3648. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3649. afe_cal_mode_text);
  3650. static const struct soc_enum rt_proxy_1_rx_enum =
  3651. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3652. afe_cal_mode_text);
  3653. static const struct soc_enum rt_proxy_1_tx_enum =
  3654. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3655. afe_cal_mode_text);
  3656. static const struct snd_kcontrol_new sb_config_controls[] = {
  3657. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  3658. msm_dai_q6_sb_format_get,
  3659. msm_dai_q6_sb_format_put),
  3660. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  3661. msm_dai_q6_cal_info_get,
  3662. msm_dai_q6_cal_info_put),
  3663. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  3664. msm_dai_q6_sb_format_get,
  3665. msm_dai_q6_sb_format_put),
  3666. SOC_ENUM_EXT("SLIM_0_RX XTLoggingDisable", xt_logging_disable_enum[0],
  3667. msm_dai_q6_sb_xt_logging_disable_get,
  3668. msm_dai_q6_sb_xt_logging_disable_put),
  3669. };
  3670. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  3671. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  3672. msm_dai_q6_cal_info_get,
  3673. msm_dai_q6_cal_info_put),
  3674. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  3675. msm_dai_q6_cal_info_get,
  3676. msm_dai_q6_cal_info_put),
  3677. };
  3678. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  3679. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  3680. msm_dai_q6_usb_audio_cfg_get,
  3681. msm_dai_q6_usb_audio_cfg_put),
  3682. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  3683. msm_dai_q6_usb_audio_endian_cfg_get,
  3684. msm_dai_q6_usb_audio_endian_cfg_put),
  3685. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  3686. msm_dai_q6_usb_audio_cfg_get,
  3687. msm_dai_q6_usb_audio_cfg_put),
  3688. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  3689. msm_dai_q6_usb_audio_endian_cfg_get,
  3690. msm_dai_q6_usb_audio_endian_cfg_put),
  3691. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  3692. UINT_MAX, 0,
  3693. msm_dai_q6_usb_audio_svc_interval_get,
  3694. msm_dai_q6_usb_audio_svc_interval_put),
  3695. };
  3696. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  3697. {
  3698. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3699. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3700. .name = "SLIMBUS_0_RX DRIFT",
  3701. .info = msm_dai_q6_slim_rx_drift_info,
  3702. .get = msm_dai_q6_slim_rx_drift_get,
  3703. },
  3704. {
  3705. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3706. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3707. .name = "SLIMBUS_6_RX DRIFT",
  3708. .info = msm_dai_q6_slim_rx_drift_info,
  3709. .get = msm_dai_q6_slim_rx_drift_get,
  3710. },
  3711. {
  3712. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3713. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3714. .name = "SLIMBUS_7_RX DRIFT",
  3715. .info = msm_dai_q6_slim_rx_drift_info,
  3716. .get = msm_dai_q6_slim_rx_drift_get,
  3717. },
  3718. };
  3719. static inline void msm_dai_q6_set_slim_dev_id(struct snd_soc_dai *dai)
  3720. {
  3721. int rc = 0;
  3722. int slim_dev_id = 0;
  3723. const char *q6_slim_dev_id = "qcom,msm-dai-q6-slim-dev-id";
  3724. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3725. dai_data->port_config.slim_sch.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1;
  3726. rc = of_property_read_u32(dai->dev->of_node, q6_slim_dev_id,
  3727. &slim_dev_id);
  3728. if (rc) {
  3729. dev_dbg(dai->dev,
  3730. "%s: missing %s in dt node\n", __func__, q6_slim_dev_id);
  3731. return;
  3732. }
  3733. dev_dbg(dai->dev, "%s: slim_dev_id = %d\n", __func__, slim_dev_id);
  3734. if (slim_dev_id >= AFE_SLIMBUS_DEVICE_1 &&
  3735. slim_dev_id <= AFE_SLIMBUS_DEVICE_2)
  3736. dai_data->port_config.slim_sch.slimbus_dev_id = slim_dev_id;
  3737. }
  3738. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  3739. {
  3740. struct msm_dai_q6_dai_data *dai_data;
  3741. int rc = 0;
  3742. if (!dai) {
  3743. pr_err("%s: Invalid params dai\n", __func__);
  3744. return -EINVAL;
  3745. }
  3746. if (!dai->dev) {
  3747. pr_err("%s: Invalid params dai dev\n", __func__);
  3748. return -EINVAL;
  3749. }
  3750. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  3751. if (!dai_data)
  3752. return -ENOMEM;
  3753. else
  3754. dev_set_drvdata(dai->dev, dai_data);
  3755. msm_dai_q6_set_dai_id(dai);
  3756. if ((dai->id >= SLIMBUS_0_RX) && (dai->id <= SLIMBUS_9_TX))
  3757. msm_dai_q6_set_slim_dev_id(dai);
  3758. switch (dai->id) {
  3759. case SLIMBUS_4_TX:
  3760. rc = snd_ctl_add(dai->component->card->snd_card,
  3761. snd_ctl_new1(&sb_config_controls[0],
  3762. dai_data));
  3763. break;
  3764. case SLIMBUS_2_RX:
  3765. rc = snd_ctl_add(dai->component->card->snd_card,
  3766. snd_ctl_new1(&sb_config_controls[1],
  3767. dai_data));
  3768. rc = snd_ctl_add(dai->component->card->snd_card,
  3769. snd_ctl_new1(&sb_config_controls[2],
  3770. dai_data));
  3771. break;
  3772. case SLIMBUS_7_RX:
  3773. rc = snd_ctl_add(dai->component->card->snd_card,
  3774. snd_ctl_new1(&afe_enc_config_controls[0],
  3775. dai_data));
  3776. rc = snd_ctl_add(dai->component->card->snd_card,
  3777. snd_ctl_new1(&afe_enc_config_controls[1],
  3778. dai_data));
  3779. rc = snd_ctl_add(dai->component->card->snd_card,
  3780. snd_ctl_new1(&afe_enc_config_controls[2],
  3781. dai_data));
  3782. rc = snd_ctl_add(dai->component->card->snd_card,
  3783. snd_ctl_new1(&afe_enc_config_controls[3],
  3784. dai_data));
  3785. rc = snd_ctl_add(dai->component->card->snd_card,
  3786. snd_ctl_new1(&afe_enc_config_controls[4],
  3787. dai));
  3788. rc = snd_ctl_add(dai->component->card->snd_card,
  3789. snd_ctl_new1(&afe_enc_config_controls[5],
  3790. dai_data));
  3791. rc = snd_ctl_add(dai->component->card->snd_card,
  3792. snd_ctl_new1(&afe_enc_config_controls[6],
  3793. dai));
  3794. rc = snd_ctl_add(dai->component->card->snd_card,
  3795. snd_ctl_new1(&avd_drift_config_controls[2],
  3796. dai));
  3797. break;
  3798. case SLIMBUS_7_TX:
  3799. rc = snd_ctl_add(dai->component->card->snd_card,
  3800. snd_ctl_new1(&afe_dec_config_controls[0],
  3801. dai_data));
  3802. break;
  3803. case SLIMBUS_9_TX:
  3804. rc = snd_ctl_add(dai->component->card->snd_card,
  3805. snd_ctl_new1(&afe_dec_config_controls[1],
  3806. dai_data));
  3807. rc = snd_ctl_add(dai->component->card->snd_card,
  3808. snd_ctl_new1(&afe_dec_config_controls[2],
  3809. dai_data));
  3810. rc = snd_ctl_add(dai->component->card->snd_card,
  3811. snd_ctl_new1(&afe_dec_config_controls[3],
  3812. dai_data));
  3813. rc = snd_ctl_add(dai->component->card->snd_card,
  3814. snd_ctl_new1(&afe_ttp_config_controls[0],
  3815. dai_data));
  3816. rc = snd_ctl_add(dai->component->card->snd_card,
  3817. snd_ctl_new1(&afe_ttp_config_controls[1],
  3818. dai_data));
  3819. break;
  3820. case RT_PROXY_DAI_001_RX:
  3821. rc = snd_ctl_add(dai->component->card->snd_card,
  3822. snd_ctl_new1(&rt_proxy_config_controls[0],
  3823. dai_data));
  3824. break;
  3825. case RT_PROXY_DAI_001_TX:
  3826. rc = snd_ctl_add(dai->component->card->snd_card,
  3827. snd_ctl_new1(&rt_proxy_config_controls[1],
  3828. dai_data));
  3829. break;
  3830. case AFE_PORT_ID_USB_RX:
  3831. rc = snd_ctl_add(dai->component->card->snd_card,
  3832. snd_ctl_new1(&usb_audio_cfg_controls[0],
  3833. dai_data));
  3834. rc = snd_ctl_add(dai->component->card->snd_card,
  3835. snd_ctl_new1(&usb_audio_cfg_controls[1],
  3836. dai_data));
  3837. rc = snd_ctl_add(dai->component->card->snd_card,
  3838. snd_ctl_new1(&usb_audio_cfg_controls[4],
  3839. dai_data));
  3840. break;
  3841. case AFE_PORT_ID_USB_TX:
  3842. rc = snd_ctl_add(dai->component->card->snd_card,
  3843. snd_ctl_new1(&usb_audio_cfg_controls[2],
  3844. dai_data));
  3845. rc = snd_ctl_add(dai->component->card->snd_card,
  3846. snd_ctl_new1(&usb_audio_cfg_controls[3],
  3847. dai_data));
  3848. break;
  3849. case SLIMBUS_0_RX:
  3850. rc = snd_ctl_add(dai->component->card->snd_card,
  3851. snd_ctl_new1(&avd_drift_config_controls[0],
  3852. dai));
  3853. rc = snd_ctl_add(dai->component->card->snd_card,
  3854. snd_ctl_new1(&sb_config_controls[3],
  3855. dai_data));
  3856. break;
  3857. case SLIMBUS_6_RX:
  3858. rc = snd_ctl_add(dai->component->card->snd_card,
  3859. snd_ctl_new1(&avd_drift_config_controls[1],
  3860. dai));
  3861. break;
  3862. }
  3863. if (rc < 0)
  3864. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  3865. __func__, dai->name);
  3866. rc = msm_dai_q6_dai_add_route(dai);
  3867. return rc;
  3868. }
  3869. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  3870. {
  3871. struct msm_dai_q6_dai_data *dai_data;
  3872. int rc;
  3873. dai_data = dev_get_drvdata(dai->dev);
  3874. /* If AFE port is still up, close it */
  3875. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3876. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  3877. rc = afe_close(dai->id); /* can block */
  3878. if (rc < 0)
  3879. dev_err(dai->dev, "fail to close AFE port\n");
  3880. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3881. }
  3882. kfree(dai_data);
  3883. return 0;
  3884. }
  3885. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  3886. {
  3887. .playback = {
  3888. .stream_name = "AFE Playback",
  3889. .aif_name = "PCM_RX",
  3890. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3891. SNDRV_PCM_RATE_16000,
  3892. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3893. SNDRV_PCM_FMTBIT_S24_LE,
  3894. .channels_min = 1,
  3895. .channels_max = 2,
  3896. .rate_min = 8000,
  3897. .rate_max = 48000,
  3898. },
  3899. .ops = &msm_dai_q6_ops,
  3900. .id = RT_PROXY_DAI_001_RX,
  3901. .probe = msm_dai_q6_dai_probe,
  3902. .remove = msm_dai_q6_dai_remove,
  3903. },
  3904. {
  3905. .playback = {
  3906. .stream_name = "AFE-PROXY RX",
  3907. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3908. SNDRV_PCM_RATE_16000,
  3909. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3910. SNDRV_PCM_FMTBIT_S24_LE,
  3911. .channels_min = 1,
  3912. .channels_max = 2,
  3913. .rate_min = 8000,
  3914. .rate_max = 48000,
  3915. },
  3916. .ops = &msm_dai_q6_ops,
  3917. .id = RT_PROXY_DAI_002_RX,
  3918. .probe = msm_dai_q6_dai_probe,
  3919. .remove = msm_dai_q6_dai_remove,
  3920. },
  3921. };
  3922. static struct snd_soc_dai_driver msm_dai_q6_afe_lb_tx_dai[] = {
  3923. {
  3924. .capture = {
  3925. .stream_name = "AFE Loopback Capture",
  3926. .aif_name = "AFE_LOOPBACK_TX",
  3927. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3928. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3929. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3930. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3931. SNDRV_PCM_RATE_192000,
  3932. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  3933. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE |
  3934. SNDRV_PCM_FMTBIT_S32_LE ),
  3935. .channels_min = 1,
  3936. .channels_max = 8,
  3937. .rate_min = 8000,
  3938. .rate_max = 192000,
  3939. },
  3940. .id = AFE_LOOPBACK_TX,
  3941. .probe = msm_dai_q6_dai_probe,
  3942. .remove = msm_dai_q6_dai_remove,
  3943. },
  3944. };
  3945. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  3946. {
  3947. .capture = {
  3948. .stream_name = "AFE Capture",
  3949. .aif_name = "PCM_TX",
  3950. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3951. SNDRV_PCM_RATE_16000,
  3952. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3953. .channels_min = 1,
  3954. .channels_max = 8,
  3955. .rate_min = 8000,
  3956. .rate_max = 48000,
  3957. },
  3958. .ops = &msm_dai_q6_ops,
  3959. .id = RT_PROXY_DAI_002_TX,
  3960. .probe = msm_dai_q6_dai_probe,
  3961. .remove = msm_dai_q6_dai_remove,
  3962. },
  3963. {
  3964. .capture = {
  3965. .stream_name = "AFE-PROXY TX",
  3966. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3967. SNDRV_PCM_RATE_16000,
  3968. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3969. .channels_min = 1,
  3970. .channels_max = 8,
  3971. .rate_min = 8000,
  3972. .rate_max = 48000,
  3973. },
  3974. .ops = &msm_dai_q6_ops,
  3975. .id = RT_PROXY_DAI_001_TX,
  3976. .probe = msm_dai_q6_dai_probe,
  3977. .remove = msm_dai_q6_dai_remove,
  3978. },
  3979. };
  3980. static struct snd_soc_dai_driver msm_dai_q6_afe_cap_dai = {
  3981. .capture = {
  3982. .stream_name = "AFE-PROXY TX1",
  3983. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3984. SNDRV_PCM_RATE_16000,
  3985. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3986. .channels_min = 1,
  3987. .channels_max = 8,
  3988. .rate_min = 8000,
  3989. .rate_max = 48000,
  3990. },
  3991. .ops = &msm_dai_q6_ops,
  3992. .id = RT_PROXY_DAI_003_TX,
  3993. .probe = msm_dai_q6_dai_probe,
  3994. .remove = msm_dai_q6_dai_remove,
  3995. };
  3996. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3997. .playback = {
  3998. .stream_name = "Internal BT-SCO Playback",
  3999. .aif_name = "INT_BT_SCO_RX",
  4000. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  4001. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4002. .channels_min = 1,
  4003. .channels_max = 1,
  4004. .rate_max = 16000,
  4005. .rate_min = 8000,
  4006. },
  4007. .ops = &msm_dai_q6_ops,
  4008. .id = INT_BT_SCO_RX,
  4009. .probe = msm_dai_q6_dai_probe,
  4010. .remove = msm_dai_q6_dai_remove,
  4011. };
  4012. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  4013. .playback = {
  4014. .stream_name = "Internal BT-A2DP Playback",
  4015. .aif_name = "INT_BT_A2DP_RX",
  4016. .rates = SNDRV_PCM_RATE_48000,
  4017. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4018. .channels_min = 1,
  4019. .channels_max = 2,
  4020. .rate_max = 48000,
  4021. .rate_min = 48000,
  4022. },
  4023. .ops = &msm_dai_q6_ops,
  4024. .id = INT_BT_A2DP_RX,
  4025. .probe = msm_dai_q6_dai_probe,
  4026. .remove = msm_dai_q6_dai_remove,
  4027. };
  4028. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  4029. .capture = {
  4030. .stream_name = "Internal BT-SCO Capture",
  4031. .aif_name = "INT_BT_SCO_TX",
  4032. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  4033. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4034. .channels_min = 1,
  4035. .channels_max = 1,
  4036. .rate_max = 16000,
  4037. .rate_min = 8000,
  4038. },
  4039. .ops = &msm_dai_q6_ops,
  4040. .id = INT_BT_SCO_TX,
  4041. .probe = msm_dai_q6_dai_probe,
  4042. .remove = msm_dai_q6_dai_remove,
  4043. };
  4044. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  4045. .playback = {
  4046. .stream_name = "Internal FM Playback",
  4047. .aif_name = "INT_FM_RX",
  4048. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4049. SNDRV_PCM_RATE_16000,
  4050. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4051. .channels_min = 2,
  4052. .channels_max = 2,
  4053. .rate_max = 48000,
  4054. .rate_min = 8000,
  4055. },
  4056. .ops = &msm_dai_q6_ops,
  4057. .id = INT_FM_RX,
  4058. .probe = msm_dai_q6_dai_probe,
  4059. .remove = msm_dai_q6_dai_remove,
  4060. };
  4061. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  4062. .capture = {
  4063. .stream_name = "Internal FM Capture",
  4064. .aif_name = "INT_FM_TX",
  4065. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4066. SNDRV_PCM_RATE_16000,
  4067. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4068. .channels_min = 2,
  4069. .channels_max = 2,
  4070. .rate_max = 48000,
  4071. .rate_min = 8000,
  4072. },
  4073. .ops = &msm_dai_q6_ops,
  4074. .id = INT_FM_TX,
  4075. .probe = msm_dai_q6_dai_probe,
  4076. .remove = msm_dai_q6_dai_remove,
  4077. };
  4078. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  4079. {
  4080. .playback = {
  4081. .stream_name = "Voice Farend Playback",
  4082. .aif_name = "VOICE_PLAYBACK_TX",
  4083. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4084. SNDRV_PCM_RATE_16000,
  4085. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4086. .channels_min = 1,
  4087. .channels_max = 2,
  4088. .rate_min = 8000,
  4089. .rate_max = 48000,
  4090. },
  4091. .ops = &msm_dai_q6_ops,
  4092. .id = VOICE_PLAYBACK_TX,
  4093. .probe = msm_dai_q6_dai_probe,
  4094. .remove = msm_dai_q6_dai_remove,
  4095. },
  4096. {
  4097. .playback = {
  4098. .stream_name = "Voice2 Farend Playback",
  4099. .aif_name = "VOICE2_PLAYBACK_TX",
  4100. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4101. SNDRV_PCM_RATE_16000,
  4102. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4103. .channels_min = 1,
  4104. .channels_max = 2,
  4105. .rate_min = 8000,
  4106. .rate_max = 48000,
  4107. },
  4108. .ops = &msm_dai_q6_ops,
  4109. .id = VOICE2_PLAYBACK_TX,
  4110. .probe = msm_dai_q6_dai_probe,
  4111. .remove = msm_dai_q6_dai_remove,
  4112. },
  4113. };
  4114. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  4115. {
  4116. .capture = {
  4117. .stream_name = "Voice Uplink Capture",
  4118. .aif_name = "INCALL_RECORD_TX",
  4119. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4120. SNDRV_PCM_RATE_16000,
  4121. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4122. .channels_min = 1,
  4123. .channels_max = 2,
  4124. .rate_min = 8000,
  4125. .rate_max = 48000,
  4126. },
  4127. .ops = &msm_dai_q6_ops,
  4128. .id = VOICE_RECORD_TX,
  4129. .probe = msm_dai_q6_dai_probe,
  4130. .remove = msm_dai_q6_dai_remove,
  4131. },
  4132. {
  4133. .capture = {
  4134. .stream_name = "Voice Downlink Capture",
  4135. .aif_name = "INCALL_RECORD_RX",
  4136. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4137. SNDRV_PCM_RATE_16000,
  4138. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4139. .channels_min = 1,
  4140. .channels_max = 2,
  4141. .rate_min = 8000,
  4142. .rate_max = 48000,
  4143. },
  4144. .ops = &msm_dai_q6_ops,
  4145. .id = VOICE_RECORD_RX,
  4146. .probe = msm_dai_q6_dai_probe,
  4147. .remove = msm_dai_q6_dai_remove,
  4148. },
  4149. };
  4150. static struct snd_soc_dai_driver msm_dai_q6_proxy_tx_dai = {
  4151. .capture = {
  4152. .stream_name = "Proxy Capture",
  4153. .aif_name = "PROXY_TX",
  4154. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4155. SNDRV_PCM_RATE_16000,
  4156. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4157. .channels_min = 1,
  4158. .channels_max = 2,
  4159. .rate_min = 8000,
  4160. .rate_max = 48000,
  4161. },
  4162. .ops = &msm_dai_q6_ops,
  4163. .id = RT_PROXY_PORT_002_TX,
  4164. .probe = msm_dai_q6_dai_probe,
  4165. .remove = msm_dai_q6_dai_remove,
  4166. };
  4167. static struct snd_soc_dai_driver msm_dai_q6_proxy_rx_dai = {
  4168. .playback = {
  4169. .stream_name = "Proxy Playback",
  4170. .aif_name = "PROXY_RX",
  4171. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4172. SNDRV_PCM_RATE_16000,
  4173. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4174. .channels_min = 1,
  4175. .channels_max = 2,
  4176. .rate_min = 8000,
  4177. .rate_max = 48000,
  4178. },
  4179. .ops = &msm_dai_q6_ops,
  4180. .id = RT_PROXY_PORT_002_RX,
  4181. .probe = msm_dai_q6_dai_probe,
  4182. .remove = msm_dai_q6_dai_remove,
  4183. };
  4184. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  4185. .playback = {
  4186. .stream_name = "USB Audio Playback",
  4187. .aif_name = "USB_AUDIO_RX",
  4188. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4189. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4190. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4191. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  4192. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  4193. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  4194. SNDRV_PCM_RATE_384000,
  4195. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  4196. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  4197. .channels_min = 1,
  4198. .channels_max = 8,
  4199. .rate_max = 384000,
  4200. .rate_min = 8000,
  4201. },
  4202. .ops = &msm_dai_q6_ops,
  4203. .id = AFE_PORT_ID_USB_RX,
  4204. .probe = msm_dai_q6_dai_probe,
  4205. .remove = msm_dai_q6_dai_remove,
  4206. };
  4207. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  4208. .capture = {
  4209. .stream_name = "USB Audio Capture",
  4210. .aif_name = "USB_AUDIO_TX",
  4211. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4212. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4213. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4214. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  4215. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  4216. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  4217. SNDRV_PCM_RATE_384000,
  4218. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  4219. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  4220. .channels_min = 1,
  4221. .channels_max = 8,
  4222. .rate_max = 384000,
  4223. .rate_min = 8000,
  4224. },
  4225. .ops = &msm_dai_q6_ops,
  4226. .id = AFE_PORT_ID_USB_TX,
  4227. .probe = msm_dai_q6_dai_probe,
  4228. .remove = msm_dai_q6_dai_remove,
  4229. };
  4230. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  4231. {
  4232. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  4233. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  4234. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  4235. uint32_t val = 0;
  4236. const char *intf_name;
  4237. int rc = 0, i = 0, len = 0;
  4238. const uint32_t *slot_mapping_array = NULL;
  4239. u32 array_length = 0;
  4240. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  4241. GFP_KERNEL);
  4242. if (!dai_data)
  4243. return -ENOMEM;
  4244. rc = of_property_read_u32(pdev->dev.of_node,
  4245. "qcom,msm-dai-is-island-supported",
  4246. &dai_data->is_island_dai);
  4247. if (rc)
  4248. dev_dbg(&pdev->dev, "island supported entry not found\n");
  4249. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  4250. GFP_KERNEL);
  4251. if (!auxpcm_pdata) {
  4252. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  4253. goto fail_pdata_nomem;
  4254. }
  4255. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  4256. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  4257. rc = of_property_read_u32_array(pdev->dev.of_node,
  4258. "qcom,msm-cpudai-auxpcm-mode",
  4259. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4260. if (rc) {
  4261. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  4262. __func__);
  4263. goto fail_invalid_dt;
  4264. }
  4265. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  4266. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  4267. rc = of_property_read_u32_array(pdev->dev.of_node,
  4268. "qcom,msm-cpudai-auxpcm-sync",
  4269. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4270. if (rc) {
  4271. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  4272. __func__);
  4273. goto fail_invalid_dt;
  4274. }
  4275. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  4276. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  4277. rc = of_property_read_u32_array(pdev->dev.of_node,
  4278. "qcom,msm-cpudai-auxpcm-frame",
  4279. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4280. if (rc) {
  4281. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  4282. __func__);
  4283. goto fail_invalid_dt;
  4284. }
  4285. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  4286. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  4287. rc = of_property_read_u32_array(pdev->dev.of_node,
  4288. "qcom,msm-cpudai-auxpcm-quant",
  4289. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4290. if (rc) {
  4291. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  4292. __func__);
  4293. goto fail_invalid_dt;
  4294. }
  4295. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  4296. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  4297. rc = of_property_read_u32_array(pdev->dev.of_node,
  4298. "qcom,msm-cpudai-auxpcm-num-slots",
  4299. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4300. if (rc) {
  4301. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  4302. __func__);
  4303. goto fail_invalid_dt;
  4304. }
  4305. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  4306. if (auxpcm_pdata->mode_8k.num_slots >
  4307. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  4308. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  4309. __func__,
  4310. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  4311. auxpcm_pdata->mode_8k.num_slots);
  4312. rc = -EINVAL;
  4313. goto fail_invalid_dt;
  4314. }
  4315. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  4316. if (auxpcm_pdata->mode_16k.num_slots >
  4317. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  4318. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  4319. __func__,
  4320. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  4321. auxpcm_pdata->mode_16k.num_slots);
  4322. rc = -EINVAL;
  4323. goto fail_invalid_dt;
  4324. }
  4325. slot_mapping_array = of_get_property(pdev->dev.of_node,
  4326. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  4327. if (slot_mapping_array == NULL) {
  4328. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  4329. __func__);
  4330. rc = -EINVAL;
  4331. goto fail_invalid_dt;
  4332. }
  4333. array_length = auxpcm_pdata->mode_8k.num_slots +
  4334. auxpcm_pdata->mode_16k.num_slots;
  4335. if (len != sizeof(uint32_t) * array_length) {
  4336. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  4337. __func__, len, sizeof(uint32_t) * array_length);
  4338. rc = -EINVAL;
  4339. goto fail_invalid_dt;
  4340. }
  4341. auxpcm_pdata->mode_8k.slot_mapping =
  4342. kzalloc(sizeof(uint16_t) *
  4343. auxpcm_pdata->mode_8k.num_slots,
  4344. GFP_KERNEL);
  4345. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  4346. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  4347. __func__);
  4348. rc = -ENOMEM;
  4349. goto fail_invalid_dt;
  4350. }
  4351. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  4352. auxpcm_pdata->mode_8k.slot_mapping[i] =
  4353. (u16)be32_to_cpu(slot_mapping_array[i]);
  4354. auxpcm_pdata->mode_16k.slot_mapping =
  4355. kzalloc(sizeof(uint16_t) *
  4356. auxpcm_pdata->mode_16k.num_slots,
  4357. GFP_KERNEL);
  4358. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  4359. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  4360. __func__);
  4361. rc = -ENOMEM;
  4362. goto fail_invalid_16k_slot_mapping;
  4363. }
  4364. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  4365. auxpcm_pdata->mode_16k.slot_mapping[i] =
  4366. (u16)be32_to_cpu(slot_mapping_array[i +
  4367. auxpcm_pdata->mode_8k.num_slots]);
  4368. rc = of_property_read_u32_array(pdev->dev.of_node,
  4369. "qcom,msm-cpudai-auxpcm-data",
  4370. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4371. if (rc) {
  4372. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  4373. __func__);
  4374. goto fail_invalid_dt1;
  4375. }
  4376. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  4377. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  4378. rc = of_property_read_u32_array(pdev->dev.of_node,
  4379. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  4380. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4381. if (rc) {
  4382. dev_err(&pdev->dev,
  4383. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  4384. __func__);
  4385. goto fail_invalid_dt1;
  4386. }
  4387. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  4388. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  4389. rc = of_property_read_string(pdev->dev.of_node,
  4390. "qcom,msm-auxpcm-interface", &intf_name);
  4391. if (rc) {
  4392. dev_err(&pdev->dev,
  4393. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  4394. __func__);
  4395. goto fail_nodev_intf;
  4396. }
  4397. if (!strcmp(intf_name, "primary")) {
  4398. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  4399. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  4400. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  4401. i = 0;
  4402. } else if (!strcmp(intf_name, "secondary")) {
  4403. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  4404. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  4405. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  4406. i = 1;
  4407. } else if (!strcmp(intf_name, "tertiary")) {
  4408. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  4409. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  4410. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  4411. i = 2;
  4412. } else if (!strcmp(intf_name, "quaternary")) {
  4413. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  4414. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  4415. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  4416. i = 3;
  4417. } else if (!strcmp(intf_name, "quinary")) {
  4418. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  4419. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  4420. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  4421. i = 4;
  4422. } else if (!strcmp(intf_name, "senary")) {
  4423. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  4424. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  4425. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  4426. i = 5;
  4427. } else {
  4428. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  4429. __func__, intf_name);
  4430. goto fail_invalid_intf;
  4431. }
  4432. rc = of_property_read_u32(pdev->dev.of_node,
  4433. "qcom,msm-cpudai-afe-clk-ver", &val);
  4434. if (rc)
  4435. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  4436. else
  4437. dai_data->afe_clk_ver = val;
  4438. mutex_init(&dai_data->rlock);
  4439. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  4440. dev_set_drvdata(&pdev->dev, dai_data);
  4441. pdev->dev.platform_data = (void *) auxpcm_pdata;
  4442. rc = snd_soc_register_component(&pdev->dev,
  4443. &msm_dai_q6_aux_pcm_dai_component,
  4444. &msm_dai_q6_aux_pcm_dai[i], 1);
  4445. if (rc) {
  4446. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  4447. __func__, rc);
  4448. goto fail_reg_dai;
  4449. }
  4450. return rc;
  4451. fail_reg_dai:
  4452. fail_invalid_intf:
  4453. fail_nodev_intf:
  4454. fail_invalid_dt1:
  4455. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  4456. fail_invalid_16k_slot_mapping:
  4457. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  4458. fail_invalid_dt:
  4459. kfree(auxpcm_pdata);
  4460. fail_pdata_nomem:
  4461. kfree(dai_data);
  4462. return rc;
  4463. }
  4464. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  4465. {
  4466. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  4467. dai_data = dev_get_drvdata(&pdev->dev);
  4468. snd_soc_unregister_component(&pdev->dev);
  4469. mutex_destroy(&dai_data->rlock);
  4470. kfree(dai_data);
  4471. kfree(pdev->dev.platform_data);
  4472. return 0;
  4473. }
  4474. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  4475. { .compatible = "qcom,msm-auxpcm-dev", },
  4476. {}
  4477. };
  4478. static struct platform_driver msm_auxpcm_dev_driver = {
  4479. .probe = msm_auxpcm_dev_probe,
  4480. .remove = msm_auxpcm_dev_remove,
  4481. .driver = {
  4482. .name = "msm-auxpcm-dev",
  4483. .owner = THIS_MODULE,
  4484. .of_match_table = msm_auxpcm_dev_dt_match,
  4485. .suppress_bind_attrs = true,
  4486. },
  4487. };
  4488. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  4489. {
  4490. .playback = {
  4491. .stream_name = "Slimbus Playback",
  4492. .aif_name = "SLIMBUS_0_RX",
  4493. .rates = SNDRV_PCM_RATE_8000_384000,
  4494. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4495. .channels_min = 1,
  4496. .channels_max = 8,
  4497. .rate_min = 8000,
  4498. .rate_max = 384000,
  4499. },
  4500. .ops = &msm_dai_slimbus_0_rx_ops,
  4501. .id = SLIMBUS_0_RX,
  4502. .probe = msm_dai_q6_dai_probe,
  4503. .remove = msm_dai_q6_dai_remove,
  4504. },
  4505. {
  4506. .playback = {
  4507. .stream_name = "Slimbus1 Playback",
  4508. .aif_name = "SLIMBUS_1_RX",
  4509. .rates = SNDRV_PCM_RATE_8000_384000,
  4510. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4511. .channels_min = 1,
  4512. .channels_max = 2,
  4513. .rate_min = 8000,
  4514. .rate_max = 384000,
  4515. },
  4516. .ops = &msm_dai_q6_ops,
  4517. .id = SLIMBUS_1_RX,
  4518. .probe = msm_dai_q6_dai_probe,
  4519. .remove = msm_dai_q6_dai_remove,
  4520. },
  4521. {
  4522. .playback = {
  4523. .stream_name = "Slimbus2 Playback",
  4524. .aif_name = "SLIMBUS_2_RX",
  4525. .rates = SNDRV_PCM_RATE_8000_384000,
  4526. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4527. .channels_min = 1,
  4528. .channels_max = 8,
  4529. .rate_min = 8000,
  4530. .rate_max = 384000,
  4531. },
  4532. .ops = &msm_dai_q6_ops,
  4533. .id = SLIMBUS_2_RX,
  4534. .probe = msm_dai_q6_dai_probe,
  4535. .remove = msm_dai_q6_dai_remove,
  4536. },
  4537. {
  4538. .playback = {
  4539. .stream_name = "Slimbus3 Playback",
  4540. .aif_name = "SLIMBUS_3_RX",
  4541. .rates = SNDRV_PCM_RATE_8000_384000,
  4542. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4543. .channels_min = 1,
  4544. .channels_max = 2,
  4545. .rate_min = 8000,
  4546. .rate_max = 384000,
  4547. },
  4548. .ops = &msm_dai_q6_ops,
  4549. .id = SLIMBUS_3_RX,
  4550. .probe = msm_dai_q6_dai_probe,
  4551. .remove = msm_dai_q6_dai_remove,
  4552. },
  4553. {
  4554. .playback = {
  4555. .stream_name = "Slimbus4 Playback",
  4556. .aif_name = "SLIMBUS_4_RX",
  4557. .rates = SNDRV_PCM_RATE_8000_384000,
  4558. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4559. .channels_min = 1,
  4560. .channels_max = 2,
  4561. .rate_min = 8000,
  4562. .rate_max = 384000,
  4563. },
  4564. .ops = &msm_dai_q6_ops,
  4565. .id = SLIMBUS_4_RX,
  4566. .probe = msm_dai_q6_dai_probe,
  4567. .remove = msm_dai_q6_dai_remove,
  4568. },
  4569. {
  4570. .playback = {
  4571. .stream_name = "Slimbus6 Playback",
  4572. .aif_name = "SLIMBUS_6_RX",
  4573. .rates = SNDRV_PCM_RATE_8000_384000,
  4574. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4575. .channels_min = 1,
  4576. .channels_max = 2,
  4577. .rate_min = 8000,
  4578. .rate_max = 384000,
  4579. },
  4580. .ops = &msm_dai_q6_ops,
  4581. .id = SLIMBUS_6_RX,
  4582. .probe = msm_dai_q6_dai_probe,
  4583. .remove = msm_dai_q6_dai_remove,
  4584. },
  4585. {
  4586. .playback = {
  4587. .stream_name = "Slimbus5 Playback",
  4588. .aif_name = "SLIMBUS_5_RX",
  4589. .rates = SNDRV_PCM_RATE_8000_384000,
  4590. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4591. .channels_min = 1,
  4592. .channels_max = 2,
  4593. .rate_min = 8000,
  4594. .rate_max = 384000,
  4595. },
  4596. .ops = &msm_dai_q6_ops,
  4597. .id = SLIMBUS_5_RX,
  4598. .probe = msm_dai_q6_dai_probe,
  4599. .remove = msm_dai_q6_dai_remove,
  4600. },
  4601. {
  4602. .playback = {
  4603. .stream_name = "Slimbus7 Playback",
  4604. .aif_name = "SLIMBUS_7_RX",
  4605. .rates = SNDRV_PCM_RATE_8000_384000,
  4606. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4607. .channels_min = 1,
  4608. .channels_max = 8,
  4609. .rate_min = 8000,
  4610. .rate_max = 384000,
  4611. },
  4612. .ops = &msm_dai_q6_ops,
  4613. .id = SLIMBUS_7_RX,
  4614. .probe = msm_dai_q6_dai_probe,
  4615. .remove = msm_dai_q6_dai_remove,
  4616. },
  4617. {
  4618. .playback = {
  4619. .stream_name = "Slimbus8 Playback",
  4620. .aif_name = "SLIMBUS_8_RX",
  4621. .rates = SNDRV_PCM_RATE_8000_384000,
  4622. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4623. .channels_min = 1,
  4624. .channels_max = 8,
  4625. .rate_min = 8000,
  4626. .rate_max = 384000,
  4627. },
  4628. .ops = &msm_dai_q6_ops,
  4629. .id = SLIMBUS_8_RX,
  4630. .probe = msm_dai_q6_dai_probe,
  4631. .remove = msm_dai_q6_dai_remove,
  4632. },
  4633. {
  4634. .playback = {
  4635. .stream_name = "Slimbus9 Playback",
  4636. .aif_name = "SLIMBUS_9_RX",
  4637. .rates = SNDRV_PCM_RATE_8000_384000,
  4638. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4639. .channels_min = 1,
  4640. .channels_max = 8,
  4641. .rate_min = 8000,
  4642. .rate_max = 384000,
  4643. },
  4644. .ops = &msm_dai_q6_ops,
  4645. .id = SLIMBUS_9_RX,
  4646. .probe = msm_dai_q6_dai_probe,
  4647. .remove = msm_dai_q6_dai_remove,
  4648. },
  4649. };
  4650. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  4651. {
  4652. .capture = {
  4653. .stream_name = "Slimbus Capture",
  4654. .aif_name = "SLIMBUS_0_TX",
  4655. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4656. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4657. SNDRV_PCM_RATE_192000,
  4658. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4659. SNDRV_PCM_FMTBIT_S24_LE |
  4660. SNDRV_PCM_FMTBIT_S24_3LE,
  4661. .channels_min = 1,
  4662. .channels_max = 8,
  4663. .rate_min = 8000,
  4664. .rate_max = 192000,
  4665. },
  4666. .ops = &msm_dai_q6_ops,
  4667. .id = SLIMBUS_0_TX,
  4668. .probe = msm_dai_q6_dai_probe,
  4669. .remove = msm_dai_q6_dai_remove,
  4670. },
  4671. {
  4672. .capture = {
  4673. .stream_name = "Slimbus1 Capture",
  4674. .aif_name = "SLIMBUS_1_TX",
  4675. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4676. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4677. SNDRV_PCM_RATE_192000,
  4678. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4679. SNDRV_PCM_FMTBIT_S24_LE |
  4680. SNDRV_PCM_FMTBIT_S24_3LE,
  4681. .channels_min = 1,
  4682. .channels_max = 2,
  4683. .rate_min = 8000,
  4684. .rate_max = 192000,
  4685. },
  4686. .ops = &msm_dai_q6_ops,
  4687. .id = SLIMBUS_1_TX,
  4688. .probe = msm_dai_q6_dai_probe,
  4689. .remove = msm_dai_q6_dai_remove,
  4690. },
  4691. {
  4692. .capture = {
  4693. .stream_name = "Slimbus2 Capture",
  4694. .aif_name = "SLIMBUS_2_TX",
  4695. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4696. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4697. SNDRV_PCM_RATE_192000,
  4698. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4699. SNDRV_PCM_FMTBIT_S24_LE,
  4700. .channels_min = 1,
  4701. .channels_max = 8,
  4702. .rate_min = 8000,
  4703. .rate_max = 192000,
  4704. },
  4705. .ops = &msm_dai_q6_ops,
  4706. .id = SLIMBUS_2_TX,
  4707. .probe = msm_dai_q6_dai_probe,
  4708. .remove = msm_dai_q6_dai_remove,
  4709. },
  4710. {
  4711. .capture = {
  4712. .stream_name = "Slimbus3 Capture",
  4713. .aif_name = "SLIMBUS_3_TX",
  4714. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4715. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4716. SNDRV_PCM_RATE_192000,
  4717. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4718. SNDRV_PCM_FMTBIT_S24_LE,
  4719. .channels_min = 2,
  4720. .channels_max = 4,
  4721. .rate_min = 8000,
  4722. .rate_max = 192000,
  4723. },
  4724. .ops = &msm_dai_q6_ops,
  4725. .id = SLIMBUS_3_TX,
  4726. .probe = msm_dai_q6_dai_probe,
  4727. .remove = msm_dai_q6_dai_remove,
  4728. },
  4729. {
  4730. .capture = {
  4731. .stream_name = "Slimbus4 Capture",
  4732. .aif_name = "SLIMBUS_4_TX",
  4733. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4734. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4735. SNDRV_PCM_RATE_192000,
  4736. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4737. SNDRV_PCM_FMTBIT_S24_LE |
  4738. SNDRV_PCM_FMTBIT_S32_LE,
  4739. .channels_min = 2,
  4740. .channels_max = 4,
  4741. .rate_min = 8000,
  4742. .rate_max = 192000,
  4743. },
  4744. .ops = &msm_dai_q6_ops,
  4745. .id = SLIMBUS_4_TX,
  4746. .probe = msm_dai_q6_dai_probe,
  4747. .remove = msm_dai_q6_dai_remove,
  4748. },
  4749. {
  4750. .capture = {
  4751. .stream_name = "Slimbus5 Capture",
  4752. .aif_name = "SLIMBUS_5_TX",
  4753. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4754. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4755. SNDRV_PCM_RATE_192000,
  4756. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4757. SNDRV_PCM_FMTBIT_S24_LE,
  4758. .channels_min = 1,
  4759. .channels_max = 8,
  4760. .rate_min = 8000,
  4761. .rate_max = 192000,
  4762. },
  4763. .ops = &msm_dai_q6_ops,
  4764. .id = SLIMBUS_5_TX,
  4765. .probe = msm_dai_q6_dai_probe,
  4766. .remove = msm_dai_q6_dai_remove,
  4767. },
  4768. {
  4769. .capture = {
  4770. .stream_name = "Slimbus6 Capture",
  4771. .aif_name = "SLIMBUS_6_TX",
  4772. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4773. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4774. SNDRV_PCM_RATE_192000,
  4775. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4776. SNDRV_PCM_FMTBIT_S24_LE,
  4777. .channels_min = 1,
  4778. .channels_max = 2,
  4779. .rate_min = 8000,
  4780. .rate_max = 192000,
  4781. },
  4782. .ops = &msm_dai_q6_ops,
  4783. .id = SLIMBUS_6_TX,
  4784. .probe = msm_dai_q6_dai_probe,
  4785. .remove = msm_dai_q6_dai_remove,
  4786. },
  4787. {
  4788. .capture = {
  4789. .stream_name = "Slimbus7 Capture",
  4790. .aif_name = "SLIMBUS_7_TX",
  4791. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4792. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4793. SNDRV_PCM_RATE_192000,
  4794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4795. SNDRV_PCM_FMTBIT_S24_LE |
  4796. SNDRV_PCM_FMTBIT_S32_LE,
  4797. .channels_min = 1,
  4798. .channels_max = 8,
  4799. .rate_min = 8000,
  4800. .rate_max = 192000,
  4801. },
  4802. .ops = &msm_dai_q6_ops,
  4803. .id = SLIMBUS_7_TX,
  4804. .probe = msm_dai_q6_dai_probe,
  4805. .remove = msm_dai_q6_dai_remove,
  4806. },
  4807. {
  4808. .capture = {
  4809. .stream_name = "Slimbus8 Capture",
  4810. .aif_name = "SLIMBUS_8_TX",
  4811. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4812. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4813. SNDRV_PCM_RATE_192000,
  4814. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4815. SNDRV_PCM_FMTBIT_S24_LE |
  4816. SNDRV_PCM_FMTBIT_S32_LE,
  4817. .channels_min = 1,
  4818. .channels_max = 8,
  4819. .rate_min = 8000,
  4820. .rate_max = 192000,
  4821. },
  4822. .ops = &msm_dai_q6_ops,
  4823. .id = SLIMBUS_8_TX,
  4824. .probe = msm_dai_q6_dai_probe,
  4825. .remove = msm_dai_q6_dai_remove,
  4826. },
  4827. {
  4828. .capture = {
  4829. .stream_name = "Slimbus9 Capture",
  4830. .aif_name = "SLIMBUS_9_TX",
  4831. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4832. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  4833. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  4834. SNDRV_PCM_RATE_192000,
  4835. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4836. SNDRV_PCM_FMTBIT_S24_LE |
  4837. SNDRV_PCM_FMTBIT_S32_LE,
  4838. .channels_min = 1,
  4839. .channels_max = 8,
  4840. .rate_min = 8000,
  4841. .rate_max = 192000,
  4842. },
  4843. .ops = &msm_dai_q6_ops,
  4844. .id = SLIMBUS_9_TX,
  4845. .probe = msm_dai_q6_dai_probe,
  4846. .remove = msm_dai_q6_dai_remove,
  4847. },
  4848. };
  4849. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  4850. struct snd_ctl_elem_value *ucontrol)
  4851. {
  4852. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4853. int value = ucontrol->value.integer.value[0];
  4854. dai_data->port_config.i2s.data_format = value;
  4855. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  4856. __func__, value, dai_data->port_config.i2s.mono_stereo,
  4857. dai_data->port_config.i2s.channel_mode);
  4858. return 0;
  4859. }
  4860. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  4861. struct snd_ctl_elem_value *ucontrol)
  4862. {
  4863. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4864. ucontrol->value.integer.value[0] =
  4865. dai_data->port_config.i2s.data_format;
  4866. return 0;
  4867. }
  4868. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  4869. struct snd_ctl_elem_value *ucontrol)
  4870. {
  4871. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4872. int value = ucontrol->value.integer.value[0];
  4873. dai_data->vi_feed_mono = value;
  4874. pr_debug("%s: value = %d\n", __func__, value);
  4875. return 0;
  4876. }
  4877. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  4878. struct snd_ctl_elem_value *ucontrol)
  4879. {
  4880. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4881. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  4882. return 0;
  4883. }
  4884. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  4885. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  4886. msm_dai_q6_mi2s_format_get,
  4887. msm_dai_q6_mi2s_format_put),
  4888. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  4889. msm_dai_q6_mi2s_format_get,
  4890. msm_dai_q6_mi2s_format_put),
  4891. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  4892. msm_dai_q6_mi2s_format_get,
  4893. msm_dai_q6_mi2s_format_put),
  4894. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  4895. msm_dai_q6_mi2s_format_get,
  4896. msm_dai_q6_mi2s_format_put),
  4897. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  4898. msm_dai_q6_mi2s_format_get,
  4899. msm_dai_q6_mi2s_format_put),
  4900. SOC_ENUM_EXT("SENARY MI2S RX Format", mi2s_config_enum[0],
  4901. msm_dai_q6_mi2s_format_get,
  4902. msm_dai_q6_mi2s_format_put),
  4903. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  4904. msm_dai_q6_mi2s_format_get,
  4905. msm_dai_q6_mi2s_format_put),
  4906. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  4907. msm_dai_q6_mi2s_format_get,
  4908. msm_dai_q6_mi2s_format_put),
  4909. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  4910. msm_dai_q6_mi2s_format_get,
  4911. msm_dai_q6_mi2s_format_put),
  4912. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  4913. msm_dai_q6_mi2s_format_get,
  4914. msm_dai_q6_mi2s_format_put),
  4915. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  4916. msm_dai_q6_mi2s_format_get,
  4917. msm_dai_q6_mi2s_format_put),
  4918. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  4919. msm_dai_q6_mi2s_format_get,
  4920. msm_dai_q6_mi2s_format_put),
  4921. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4922. msm_dai_q6_mi2s_format_get,
  4923. msm_dai_q6_mi2s_format_put),
  4924. };
  4925. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4926. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4927. msm_dai_q6_mi2s_vi_feed_mono_get,
  4928. msm_dai_q6_mi2s_vi_feed_mono_put),
  4929. };
  4930. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4931. {
  4932. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4933. dev_get_drvdata(dai->dev);
  4934. struct msm_mi2s_pdata *mi2s_pdata =
  4935. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4936. struct snd_kcontrol *kcontrol = NULL;
  4937. int rc = 0;
  4938. const struct snd_kcontrol_new *ctrl = NULL;
  4939. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4940. u16 dai_id = 0;
  4941. dai->id = mi2s_pdata->intf_id;
  4942. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4943. if (dai->id == MSM_PRIM_MI2S)
  4944. ctrl = &mi2s_config_controls[0];
  4945. if (dai->id == MSM_SEC_MI2S)
  4946. ctrl = &mi2s_config_controls[1];
  4947. if (dai->id == MSM_TERT_MI2S)
  4948. ctrl = &mi2s_config_controls[2];
  4949. if (dai->id == MSM_QUAT_MI2S)
  4950. ctrl = &mi2s_config_controls[3];
  4951. if (dai->id == MSM_QUIN_MI2S)
  4952. ctrl = &mi2s_config_controls[4];
  4953. if (dai->id == MSM_SENARY_MI2S)
  4954. ctrl = &mi2s_config_controls[5];
  4955. }
  4956. if (ctrl) {
  4957. kcontrol = snd_ctl_new1(ctrl,
  4958. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4959. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4960. if (rc < 0) {
  4961. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4962. __func__, dai->name);
  4963. goto rtn;
  4964. }
  4965. }
  4966. ctrl = NULL;
  4967. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4968. if (dai->id == MSM_PRIM_MI2S)
  4969. ctrl = &mi2s_config_controls[6];
  4970. if (dai->id == MSM_SEC_MI2S)
  4971. ctrl = &mi2s_config_controls[7];
  4972. if (dai->id == MSM_TERT_MI2S)
  4973. ctrl = &mi2s_config_controls[8];
  4974. if (dai->id == MSM_QUAT_MI2S)
  4975. ctrl = &mi2s_config_controls[9];
  4976. if (dai->id == MSM_QUIN_MI2S)
  4977. ctrl = &mi2s_config_controls[10];
  4978. if (dai->id == MSM_SENARY_MI2S)
  4979. ctrl = &mi2s_config_controls[11];
  4980. if (dai->id == MSM_INT5_MI2S)
  4981. ctrl = &mi2s_config_controls[12];
  4982. }
  4983. if (ctrl) {
  4984. rc = snd_ctl_add(dai->component->card->snd_card,
  4985. snd_ctl_new1(ctrl,
  4986. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4987. if (rc < 0) {
  4988. if (kcontrol)
  4989. snd_ctl_remove(dai->component->card->snd_card,
  4990. kcontrol);
  4991. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4992. __func__, dai->name);
  4993. }
  4994. }
  4995. if (dai->id == MSM_INT5_MI2S)
  4996. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4997. if (vi_feed_ctrl) {
  4998. rc = snd_ctl_add(dai->component->card->snd_card,
  4999. snd_ctl_new1(vi_feed_ctrl,
  5000. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  5001. if (rc < 0) {
  5002. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  5003. __func__, dai->name);
  5004. }
  5005. }
  5006. if (mi2s_dai_data->is_island_dai) {
  5007. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  5008. &dai_id);
  5009. rc = msm_dai_q6_add_island_mx_ctls(
  5010. dai->component->card->snd_card,
  5011. dai->name, dai_id,
  5012. (void *)mi2s_dai_data);
  5013. }
  5014. rc = msm_dai_q6_dai_add_route(dai);
  5015. rtn:
  5016. return rc;
  5017. }
  5018. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  5019. {
  5020. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5021. dev_get_drvdata(dai->dev);
  5022. int rc;
  5023. /* If AFE port is still up, close it */
  5024. if (test_bit(STATUS_PORT_STARTED,
  5025. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  5026. rc = afe_close(MI2S_RX); /* can block */
  5027. if (rc < 0)
  5028. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  5029. clear_bit(STATUS_PORT_STARTED,
  5030. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  5031. }
  5032. if (test_bit(STATUS_PORT_STARTED,
  5033. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  5034. rc = afe_close(MI2S_TX); /* can block */
  5035. if (rc < 0)
  5036. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  5037. clear_bit(STATUS_PORT_STARTED,
  5038. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  5039. }
  5040. return 0;
  5041. }
  5042. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  5043. struct snd_soc_dai *dai)
  5044. {
  5045. return 0;
  5046. }
  5047. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  5048. {
  5049. int ret = 0;
  5050. switch (stream) {
  5051. case SNDRV_PCM_STREAM_PLAYBACK:
  5052. switch (mi2s_id) {
  5053. case MSM_PRIM_MI2S:
  5054. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  5055. break;
  5056. case MSM_SEC_MI2S:
  5057. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  5058. break;
  5059. case MSM_TERT_MI2S:
  5060. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  5061. break;
  5062. case MSM_QUAT_MI2S:
  5063. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  5064. break;
  5065. case MSM_SEC_MI2S_SD1:
  5066. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  5067. break;
  5068. case MSM_QUIN_MI2S:
  5069. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  5070. break;
  5071. case MSM_SENARY_MI2S:
  5072. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  5073. break;
  5074. case MSM_INT0_MI2S:
  5075. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  5076. break;
  5077. case MSM_INT1_MI2S:
  5078. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  5079. break;
  5080. case MSM_INT2_MI2S:
  5081. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  5082. break;
  5083. case MSM_INT3_MI2S:
  5084. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  5085. break;
  5086. case MSM_INT4_MI2S:
  5087. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  5088. break;
  5089. case MSM_INT5_MI2S:
  5090. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  5091. break;
  5092. case MSM_INT6_MI2S:
  5093. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  5094. break;
  5095. default:
  5096. pr_err("%s: playback err id 0x%x\n",
  5097. __func__, mi2s_id);
  5098. ret = -1;
  5099. break;
  5100. }
  5101. break;
  5102. case SNDRV_PCM_STREAM_CAPTURE:
  5103. switch (mi2s_id) {
  5104. case MSM_PRIM_MI2S:
  5105. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  5106. break;
  5107. case MSM_SEC_MI2S:
  5108. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  5109. break;
  5110. case MSM_TERT_MI2S:
  5111. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  5112. break;
  5113. case MSM_QUAT_MI2S:
  5114. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  5115. break;
  5116. case MSM_QUIN_MI2S:
  5117. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  5118. break;
  5119. case MSM_SENARY_MI2S:
  5120. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  5121. break;
  5122. case MSM_INT0_MI2S:
  5123. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  5124. break;
  5125. case MSM_INT1_MI2S:
  5126. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  5127. break;
  5128. case MSM_INT2_MI2S:
  5129. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  5130. break;
  5131. case MSM_INT3_MI2S:
  5132. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  5133. break;
  5134. case MSM_INT4_MI2S:
  5135. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  5136. break;
  5137. case MSM_INT5_MI2S:
  5138. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  5139. break;
  5140. case MSM_INT6_MI2S:
  5141. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  5142. break;
  5143. default:
  5144. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  5145. ret = -1;
  5146. break;
  5147. }
  5148. break;
  5149. default:
  5150. pr_err("%s: default err %d\n", __func__, stream);
  5151. ret = -1;
  5152. break;
  5153. }
  5154. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  5155. return ret;
  5156. }
  5157. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  5158. struct snd_soc_dai *dai)
  5159. {
  5160. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5161. dev_get_drvdata(dai->dev);
  5162. struct msm_dai_q6_dai_data *dai_data =
  5163. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5164. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5165. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5166. u16 port_id = 0;
  5167. int rc = 0;
  5168. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  5169. &port_id) != 0) {
  5170. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5171. __func__, port_id);
  5172. return -EINVAL;
  5173. }
  5174. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  5175. "dai_data->channels = %u sample_rate = %u\n", __func__,
  5176. dai->id, port_id, dai_data->channels, dai_data->rate);
  5177. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5178. /* PORT START should be set if prepare called
  5179. * in active state.
  5180. */
  5181. rc = afe_port_start(port_id, &dai_data->port_config,
  5182. dai_data->rate);
  5183. if (rc < 0)
  5184. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  5185. dai->id);
  5186. else
  5187. set_bit(STATUS_PORT_STARTED,
  5188. dai_data->status_mask);
  5189. }
  5190. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  5191. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5192. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  5193. __func__);
  5194. }
  5195. return rc;
  5196. }
  5197. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  5198. struct snd_pcm_hw_params *params,
  5199. struct snd_soc_dai *dai)
  5200. {
  5201. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5202. dev_get_drvdata(dai->dev);
  5203. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  5204. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5205. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  5206. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  5207. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  5208. dai_data->channels = params_channels(params);
  5209. switch (dai_data->channels) {
  5210. case 15:
  5211. case 16:
  5212. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5213. case AFE_PORT_I2S_16CHS:
  5214. dai_data->port_config.i2s.channel_mode
  5215. = AFE_PORT_I2S_16CHS;
  5216. break;
  5217. default:
  5218. goto error_invalid_data;
  5219. };
  5220. break;
  5221. case 13:
  5222. case 14:
  5223. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5224. case AFE_PORT_I2S_14CHS:
  5225. case AFE_PORT_I2S_16CHS:
  5226. dai_data->port_config.i2s.channel_mode
  5227. = AFE_PORT_I2S_14CHS;
  5228. break;
  5229. default:
  5230. goto error_invalid_data;
  5231. };
  5232. break;
  5233. case 11:
  5234. case 12:
  5235. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5236. case AFE_PORT_I2S_12CHS:
  5237. case AFE_PORT_I2S_14CHS:
  5238. case AFE_PORT_I2S_16CHS:
  5239. dai_data->port_config.i2s.channel_mode
  5240. = AFE_PORT_I2S_12CHS;
  5241. break;
  5242. default:
  5243. goto error_invalid_data;
  5244. };
  5245. break;
  5246. case 9:
  5247. case 10:
  5248. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5249. case AFE_PORT_I2S_10CHS:
  5250. case AFE_PORT_I2S_12CHS:
  5251. case AFE_PORT_I2S_14CHS:
  5252. case AFE_PORT_I2S_16CHS:
  5253. dai_data->port_config.i2s.channel_mode
  5254. = AFE_PORT_I2S_10CHS;
  5255. break;
  5256. default:
  5257. goto error_invalid_data;
  5258. };
  5259. break;
  5260. case 8:
  5261. case 7:
  5262. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  5263. goto error_invalid_data;
  5264. else
  5265. if (mi2s_dai_config->pdata_mi2s_lines
  5266. == AFE_PORT_I2S_8CHS_2)
  5267. dai_data->port_config.i2s.channel_mode =
  5268. AFE_PORT_I2S_8CHS_2;
  5269. else
  5270. dai_data->port_config.i2s.channel_mode =
  5271. AFE_PORT_I2S_8CHS;
  5272. break;
  5273. case 6:
  5274. case 5:
  5275. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  5276. goto error_invalid_data;
  5277. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  5278. break;
  5279. case 4:
  5280. case 3:
  5281. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5282. case AFE_PORT_I2S_SD0:
  5283. case AFE_PORT_I2S_SD1:
  5284. case AFE_PORT_I2S_SD2:
  5285. case AFE_PORT_I2S_SD3:
  5286. case AFE_PORT_I2S_SD4:
  5287. case AFE_PORT_I2S_SD5:
  5288. case AFE_PORT_I2S_SD6:
  5289. case AFE_PORT_I2S_SD7:
  5290. goto error_invalid_data;
  5291. break;
  5292. case AFE_PORT_I2S_QUAD01:
  5293. case AFE_PORT_I2S_QUAD23:
  5294. case AFE_PORT_I2S_QUAD45:
  5295. case AFE_PORT_I2S_QUAD67:
  5296. dai_data->port_config.i2s.channel_mode =
  5297. mi2s_dai_config->pdata_mi2s_lines;
  5298. break;
  5299. case AFE_PORT_I2S_8CHS_2:
  5300. dai_data->port_config.i2s.channel_mode =
  5301. AFE_PORT_I2S_QUAD45;
  5302. break;
  5303. default:
  5304. dai_data->port_config.i2s.channel_mode =
  5305. AFE_PORT_I2S_QUAD01;
  5306. break;
  5307. };
  5308. break;
  5309. case 2:
  5310. case 1:
  5311. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  5312. goto error_invalid_data;
  5313. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5314. case AFE_PORT_I2S_SD0:
  5315. case AFE_PORT_I2S_SD1:
  5316. case AFE_PORT_I2S_SD2:
  5317. case AFE_PORT_I2S_SD3:
  5318. case AFE_PORT_I2S_SD4:
  5319. case AFE_PORT_I2S_SD5:
  5320. case AFE_PORT_I2S_SD6:
  5321. case AFE_PORT_I2S_SD7:
  5322. dai_data->port_config.i2s.channel_mode =
  5323. mi2s_dai_config->pdata_mi2s_lines;
  5324. break;
  5325. case AFE_PORT_I2S_QUAD01:
  5326. case AFE_PORT_I2S_6CHS:
  5327. case AFE_PORT_I2S_8CHS:
  5328. case AFE_PORT_I2S_10CHS:
  5329. case AFE_PORT_I2S_12CHS:
  5330. case AFE_PORT_I2S_14CHS:
  5331. case AFE_PORT_I2S_16CHS:
  5332. if (dai_data->vi_feed_mono == SPKR_1)
  5333. dai_data->port_config.i2s.channel_mode =
  5334. AFE_PORT_I2S_SD0;
  5335. else
  5336. dai_data->port_config.i2s.channel_mode =
  5337. AFE_PORT_I2S_SD1;
  5338. break;
  5339. case AFE_PORT_I2S_QUAD23:
  5340. dai_data->port_config.i2s.channel_mode =
  5341. AFE_PORT_I2S_SD2;
  5342. break;
  5343. case AFE_PORT_I2S_QUAD45:
  5344. dai_data->port_config.i2s.channel_mode =
  5345. AFE_PORT_I2S_SD4;
  5346. break;
  5347. case AFE_PORT_I2S_QUAD67:
  5348. dai_data->port_config.i2s.channel_mode =
  5349. AFE_PORT_I2S_SD6;
  5350. break;
  5351. }
  5352. if (dai_data->channels == 2)
  5353. dai_data->port_config.i2s.mono_stereo =
  5354. MSM_AFE_CH_STEREO;
  5355. else
  5356. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  5357. break;
  5358. default:
  5359. pr_err("%s: default err channels %d\n",
  5360. __func__, dai_data->channels);
  5361. goto error_invalid_data;
  5362. }
  5363. dai_data->rate = params_rate(params);
  5364. switch (params_format(params)) {
  5365. case SNDRV_PCM_FORMAT_S16_LE:
  5366. case SNDRV_PCM_FORMAT_SPECIAL:
  5367. dai_data->port_config.i2s.bit_width = 16;
  5368. dai_data->bitwidth = 16;
  5369. break;
  5370. case SNDRV_PCM_FORMAT_S24_LE:
  5371. case SNDRV_PCM_FORMAT_S24_3LE:
  5372. dai_data->port_config.i2s.bit_width = 24;
  5373. dai_data->bitwidth = 24;
  5374. break;
  5375. case SNDRV_PCM_FORMAT_S32_LE:
  5376. dai_data->port_config.i2s.bit_width = 32;
  5377. dai_data->bitwidth = 32;
  5378. break;
  5379. default:
  5380. pr_err("%s: format %d\n",
  5381. __func__, params_format(params));
  5382. return -EINVAL;
  5383. }
  5384. dai_data->port_config.i2s.i2s_cfg_minor_version =
  5385. AFE_API_VERSION_I2S_CONFIG;
  5386. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  5387. if ((test_bit(STATUS_PORT_STARTED,
  5388. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  5389. test_bit(STATUS_PORT_STARTED,
  5390. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  5391. (test_bit(STATUS_PORT_STARTED,
  5392. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  5393. test_bit(STATUS_PORT_STARTED,
  5394. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  5395. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  5396. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  5397. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  5398. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  5399. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  5400. "Tx sample_rate = %u bit_width = %hu\n"
  5401. "Rx sample_rate = %u bit_width = %hu\n"
  5402. , __func__,
  5403. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  5404. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  5405. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  5406. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  5407. return -EINVAL;
  5408. }
  5409. }
  5410. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  5411. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  5412. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  5413. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  5414. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  5415. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  5416. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  5417. i2s->sample_rate, i2s->data_format, i2s->reserved);
  5418. return 0;
  5419. error_invalid_data:
  5420. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  5421. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  5422. return -EINVAL;
  5423. }
  5424. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  5425. {
  5426. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5427. dev_get_drvdata(dai->dev);
  5428. if (test_bit(STATUS_PORT_STARTED,
  5429. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  5430. test_bit(STATUS_PORT_STARTED,
  5431. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  5432. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  5433. __func__);
  5434. return -EPERM;
  5435. }
  5436. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  5437. case SND_SOC_DAIFMT_CBS_CFS:
  5438. case SND_SOC_DAIFMT_CBM_CFS:
  5439. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5440. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5441. break;
  5442. case SND_SOC_DAIFMT_CBM_CFM:
  5443. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5444. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5445. break;
  5446. default:
  5447. pr_err("%s: fmt %d\n",
  5448. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  5449. return -EINVAL;
  5450. }
  5451. return 0;
  5452. }
  5453. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  5454. struct snd_soc_dai *dai)
  5455. {
  5456. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5457. dev_get_drvdata(dai->dev);
  5458. struct msm_dai_q6_dai_data *dai_data =
  5459. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5460. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5461. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5462. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  5463. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5464. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  5465. }
  5466. return 0;
  5467. }
  5468. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  5469. struct snd_soc_dai *dai)
  5470. {
  5471. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5472. dev_get_drvdata(dai->dev);
  5473. struct msm_dai_q6_dai_data *dai_data =
  5474. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5475. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5476. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5477. u16 port_id = 0;
  5478. int rc = 0;
  5479. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  5480. &port_id) != 0) {
  5481. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5482. __func__, port_id);
  5483. }
  5484. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  5485. __func__, port_id);
  5486. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5487. rc = afe_close(port_id);
  5488. if (rc < 0)
  5489. dev_err(dai->dev, "fail to close AFE port\n");
  5490. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  5491. }
  5492. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  5493. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5494. }
  5495. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  5496. .startup = msm_dai_q6_mi2s_startup,
  5497. .prepare = msm_dai_q6_mi2s_prepare,
  5498. .hw_params = msm_dai_q6_mi2s_hw_params,
  5499. .hw_free = msm_dai_q6_mi2s_hw_free,
  5500. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  5501. .shutdown = msm_dai_q6_mi2s_shutdown,
  5502. };
  5503. /* Channel min and max are initialized base on platform data */
  5504. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  5505. {
  5506. .playback = {
  5507. .stream_name = "Primary MI2S Playback",
  5508. .aif_name = "PRI_MI2S_RX",
  5509. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5510. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5511. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5512. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5513. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5514. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5515. SNDRV_PCM_RATE_384000,
  5516. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5517. SNDRV_PCM_FMTBIT_S24_LE |
  5518. SNDRV_PCM_FMTBIT_S24_3LE,
  5519. .rate_min = 8000,
  5520. .rate_max = 384000,
  5521. },
  5522. .capture = {
  5523. .stream_name = "Primary MI2S Capture",
  5524. .aif_name = "PRI_MI2S_TX",
  5525. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5526. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5527. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5528. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5529. SNDRV_PCM_RATE_192000,
  5530. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5531. .rate_min = 8000,
  5532. .rate_max = 192000,
  5533. },
  5534. .ops = &msm_dai_q6_mi2s_ops,
  5535. .name = "Primary MI2S",
  5536. .id = MSM_PRIM_MI2S,
  5537. .probe = msm_dai_q6_dai_mi2s_probe,
  5538. .remove = msm_dai_q6_dai_mi2s_remove,
  5539. },
  5540. {
  5541. .playback = {
  5542. .stream_name = "Secondary MI2S Playback",
  5543. .aif_name = "SEC_MI2S_RX",
  5544. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5545. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5546. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5547. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5548. SNDRV_PCM_RATE_192000,
  5549. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5550. .rate_min = 8000,
  5551. .rate_max = 192000,
  5552. },
  5553. .capture = {
  5554. .stream_name = "Secondary MI2S Capture",
  5555. .aif_name = "SEC_MI2S_TX",
  5556. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5557. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5558. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5559. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5560. SNDRV_PCM_RATE_192000,
  5561. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5562. .rate_min = 8000,
  5563. .rate_max = 192000,
  5564. },
  5565. .ops = &msm_dai_q6_mi2s_ops,
  5566. .name = "Secondary MI2S",
  5567. .id = MSM_SEC_MI2S,
  5568. .probe = msm_dai_q6_dai_mi2s_probe,
  5569. .remove = msm_dai_q6_dai_mi2s_remove,
  5570. },
  5571. {
  5572. .playback = {
  5573. .stream_name = "Tertiary MI2S Playback",
  5574. .aif_name = "TERT_MI2S_RX",
  5575. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5576. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5577. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5578. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5579. SNDRV_PCM_RATE_192000,
  5580. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5581. .rate_min = 8000,
  5582. .rate_max = 192000,
  5583. },
  5584. .capture = {
  5585. .stream_name = "Tertiary MI2S Capture",
  5586. .aif_name = "TERT_MI2S_TX",
  5587. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5588. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5589. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5590. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5591. SNDRV_PCM_RATE_192000,
  5592. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5593. .rate_min = 8000,
  5594. .rate_max = 192000,
  5595. },
  5596. .ops = &msm_dai_q6_mi2s_ops,
  5597. .name = "Tertiary MI2S",
  5598. .id = MSM_TERT_MI2S,
  5599. .probe = msm_dai_q6_dai_mi2s_probe,
  5600. .remove = msm_dai_q6_dai_mi2s_remove,
  5601. },
  5602. {
  5603. .playback = {
  5604. .stream_name = "Quaternary MI2S Playback",
  5605. .aif_name = "QUAT_MI2S_RX",
  5606. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5607. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5608. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5609. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5610. SNDRV_PCM_RATE_192000,
  5611. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5612. .rate_min = 8000,
  5613. .rate_max = 192000,
  5614. },
  5615. .capture = {
  5616. .stream_name = "Quaternary MI2S Capture",
  5617. .aif_name = "QUAT_MI2S_TX",
  5618. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5619. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5620. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5621. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5622. SNDRV_PCM_RATE_192000,
  5623. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5624. .rate_min = 8000,
  5625. .rate_max = 192000,
  5626. },
  5627. .ops = &msm_dai_q6_mi2s_ops,
  5628. .name = "Quaternary MI2S",
  5629. .id = MSM_QUAT_MI2S,
  5630. .probe = msm_dai_q6_dai_mi2s_probe,
  5631. .remove = msm_dai_q6_dai_mi2s_remove,
  5632. },
  5633. {
  5634. .playback = {
  5635. .stream_name = "Quinary MI2S Playback",
  5636. .aif_name = "QUIN_MI2S_RX",
  5637. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5638. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5639. SNDRV_PCM_RATE_192000,
  5640. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5641. .rate_min = 8000,
  5642. .rate_max = 192000,
  5643. },
  5644. .capture = {
  5645. .stream_name = "Quinary MI2S Capture",
  5646. .aif_name = "QUIN_MI2S_TX",
  5647. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5648. SNDRV_PCM_RATE_16000,
  5649. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5650. .rate_min = 8000,
  5651. .rate_max = 48000,
  5652. },
  5653. .ops = &msm_dai_q6_mi2s_ops,
  5654. .name = "Quinary MI2S",
  5655. .id = MSM_QUIN_MI2S,
  5656. .probe = msm_dai_q6_dai_mi2s_probe,
  5657. .remove = msm_dai_q6_dai_mi2s_remove,
  5658. },
  5659. {
  5660. .playback = {
  5661. .stream_name = "Senary MI2S Playback",
  5662. .aif_name = "SEN_MI2S_RX",
  5663. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5664. SNDRV_PCM_RATE_16000,
  5665. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5666. .rate_min = 8000,
  5667. .rate_max = 48000,
  5668. },
  5669. .capture = {
  5670. .stream_name = "Senary MI2S Capture",
  5671. .aif_name = "SENARY_MI2S_TX",
  5672. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5673. SNDRV_PCM_RATE_16000,
  5674. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5675. .rate_min = 8000,
  5676. .rate_max = 48000,
  5677. },
  5678. .ops = &msm_dai_q6_mi2s_ops,
  5679. .name = "Senary MI2S",
  5680. .id = MSM_SENARY_MI2S,
  5681. .probe = msm_dai_q6_dai_mi2s_probe,
  5682. .remove = msm_dai_q6_dai_mi2s_remove,
  5683. },
  5684. {
  5685. .playback = {
  5686. .stream_name = "Secondary MI2S Playback SD1",
  5687. .aif_name = "SEC_MI2S_RX_SD1",
  5688. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5689. SNDRV_PCM_RATE_16000,
  5690. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5691. .rate_min = 8000,
  5692. .rate_max = 48000,
  5693. },
  5694. .id = MSM_SEC_MI2S_SD1,
  5695. },
  5696. {
  5697. .playback = {
  5698. .stream_name = "INT0 MI2S Playback",
  5699. .aif_name = "INT0_MI2S_RX",
  5700. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5701. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5702. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5704. SNDRV_PCM_FMTBIT_S24_LE |
  5705. SNDRV_PCM_FMTBIT_S24_3LE,
  5706. .rate_min = 8000,
  5707. .rate_max = 192000,
  5708. },
  5709. .capture = {
  5710. .stream_name = "INT0 MI2S Capture",
  5711. .aif_name = "INT0_MI2S_TX",
  5712. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5713. SNDRV_PCM_RATE_16000,
  5714. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5715. .rate_min = 8000,
  5716. .rate_max = 48000,
  5717. },
  5718. .ops = &msm_dai_q6_mi2s_ops,
  5719. .name = "INT0 MI2S",
  5720. .id = MSM_INT0_MI2S,
  5721. .probe = msm_dai_q6_dai_mi2s_probe,
  5722. .remove = msm_dai_q6_dai_mi2s_remove,
  5723. },
  5724. {
  5725. .playback = {
  5726. .stream_name = "INT1 MI2S Playback",
  5727. .aif_name = "INT1_MI2S_RX",
  5728. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5729. SNDRV_PCM_RATE_16000,
  5730. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5731. SNDRV_PCM_FMTBIT_S24_LE |
  5732. SNDRV_PCM_FMTBIT_S24_3LE,
  5733. .rate_min = 8000,
  5734. .rate_max = 48000,
  5735. },
  5736. .capture = {
  5737. .stream_name = "INT1 MI2S Capture",
  5738. .aif_name = "INT1_MI2S_TX",
  5739. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5740. SNDRV_PCM_RATE_16000,
  5741. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5742. .rate_min = 8000,
  5743. .rate_max = 48000,
  5744. },
  5745. .ops = &msm_dai_q6_mi2s_ops,
  5746. .name = "INT1 MI2S",
  5747. .id = MSM_INT1_MI2S,
  5748. .probe = msm_dai_q6_dai_mi2s_probe,
  5749. .remove = msm_dai_q6_dai_mi2s_remove,
  5750. },
  5751. {
  5752. .playback = {
  5753. .stream_name = "INT2 MI2S Playback",
  5754. .aif_name = "INT2_MI2S_RX",
  5755. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5756. SNDRV_PCM_RATE_16000,
  5757. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5758. SNDRV_PCM_FMTBIT_S24_LE |
  5759. SNDRV_PCM_FMTBIT_S24_3LE,
  5760. .rate_min = 8000,
  5761. .rate_max = 48000,
  5762. },
  5763. .capture = {
  5764. .stream_name = "INT2 MI2S Capture",
  5765. .aif_name = "INT2_MI2S_TX",
  5766. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5767. SNDRV_PCM_RATE_16000,
  5768. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5769. .rate_min = 8000,
  5770. .rate_max = 48000,
  5771. },
  5772. .ops = &msm_dai_q6_mi2s_ops,
  5773. .name = "INT2 MI2S",
  5774. .id = MSM_INT2_MI2S,
  5775. .probe = msm_dai_q6_dai_mi2s_probe,
  5776. .remove = msm_dai_q6_dai_mi2s_remove,
  5777. },
  5778. {
  5779. .playback = {
  5780. .stream_name = "INT3 MI2S Playback",
  5781. .aif_name = "INT3_MI2S_RX",
  5782. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5783. SNDRV_PCM_RATE_16000,
  5784. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5785. SNDRV_PCM_FMTBIT_S24_LE |
  5786. SNDRV_PCM_FMTBIT_S24_3LE,
  5787. .rate_min = 8000,
  5788. .rate_max = 48000,
  5789. },
  5790. .capture = {
  5791. .stream_name = "INT3 MI2S Capture",
  5792. .aif_name = "INT3_MI2S_TX",
  5793. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5794. SNDRV_PCM_RATE_16000,
  5795. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5796. .rate_min = 8000,
  5797. .rate_max = 48000,
  5798. },
  5799. .ops = &msm_dai_q6_mi2s_ops,
  5800. .name = "INT3 MI2S",
  5801. .id = MSM_INT3_MI2S,
  5802. .probe = msm_dai_q6_dai_mi2s_probe,
  5803. .remove = msm_dai_q6_dai_mi2s_remove,
  5804. },
  5805. {
  5806. .playback = {
  5807. .stream_name = "INT4 MI2S Playback",
  5808. .aif_name = "INT4_MI2S_RX",
  5809. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5810. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5811. SNDRV_PCM_RATE_192000,
  5812. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5813. SNDRV_PCM_FMTBIT_S24_LE |
  5814. SNDRV_PCM_FMTBIT_S24_3LE,
  5815. .rate_min = 8000,
  5816. .rate_max = 192000,
  5817. },
  5818. .capture = {
  5819. .stream_name = "INT4 MI2S Capture",
  5820. .aif_name = "INT4_MI2S_TX",
  5821. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5822. SNDRV_PCM_RATE_16000,
  5823. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5824. .rate_min = 8000,
  5825. .rate_max = 48000,
  5826. },
  5827. .ops = &msm_dai_q6_mi2s_ops,
  5828. .name = "INT4 MI2S",
  5829. .id = MSM_INT4_MI2S,
  5830. .probe = msm_dai_q6_dai_mi2s_probe,
  5831. .remove = msm_dai_q6_dai_mi2s_remove,
  5832. },
  5833. {
  5834. .playback = {
  5835. .stream_name = "INT5 MI2S Playback",
  5836. .aif_name = "INT5_MI2S_RX",
  5837. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5838. SNDRV_PCM_RATE_16000,
  5839. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5840. SNDRV_PCM_FMTBIT_S24_LE |
  5841. SNDRV_PCM_FMTBIT_S24_3LE,
  5842. .rate_min = 8000,
  5843. .rate_max = 48000,
  5844. },
  5845. .capture = {
  5846. .stream_name = "INT5 MI2S Capture",
  5847. .aif_name = "INT5_MI2S_TX",
  5848. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5849. SNDRV_PCM_RATE_16000,
  5850. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5851. .rate_min = 8000,
  5852. .rate_max = 48000,
  5853. },
  5854. .ops = &msm_dai_q6_mi2s_ops,
  5855. .name = "INT5 MI2S",
  5856. .id = MSM_INT5_MI2S,
  5857. .probe = msm_dai_q6_dai_mi2s_probe,
  5858. .remove = msm_dai_q6_dai_mi2s_remove,
  5859. },
  5860. {
  5861. .playback = {
  5862. .stream_name = "INT6 MI2S Playback",
  5863. .aif_name = "INT6_MI2S_RX",
  5864. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5865. SNDRV_PCM_RATE_16000,
  5866. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5867. SNDRV_PCM_FMTBIT_S24_LE |
  5868. SNDRV_PCM_FMTBIT_S24_3LE,
  5869. .rate_min = 8000,
  5870. .rate_max = 48000,
  5871. },
  5872. .capture = {
  5873. .stream_name = "INT6 MI2S Capture",
  5874. .aif_name = "INT6_MI2S_TX",
  5875. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5876. SNDRV_PCM_RATE_16000,
  5877. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5878. .rate_min = 8000,
  5879. .rate_max = 48000,
  5880. },
  5881. .ops = &msm_dai_q6_mi2s_ops,
  5882. .name = "INT6 MI2S",
  5883. .id = MSM_INT6_MI2S,
  5884. .probe = msm_dai_q6_dai_mi2s_probe,
  5885. .remove = msm_dai_q6_dai_mi2s_remove,
  5886. },
  5887. };
  5888. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5889. unsigned int *ch_cnt)
  5890. {
  5891. u8 num_of_sd_lines;
  5892. num_of_sd_lines = num_of_bits_set(sd_lines);
  5893. switch (num_of_sd_lines) {
  5894. case 0:
  5895. pr_debug("%s: no line is assigned\n", __func__);
  5896. break;
  5897. case 1:
  5898. switch (sd_lines) {
  5899. case MSM_MI2S_SD0:
  5900. *config_ptr = AFE_PORT_I2S_SD0;
  5901. break;
  5902. case MSM_MI2S_SD1:
  5903. *config_ptr = AFE_PORT_I2S_SD1;
  5904. break;
  5905. case MSM_MI2S_SD2:
  5906. *config_ptr = AFE_PORT_I2S_SD2;
  5907. break;
  5908. case MSM_MI2S_SD3:
  5909. *config_ptr = AFE_PORT_I2S_SD3;
  5910. break;
  5911. case MSM_MI2S_SD4:
  5912. *config_ptr = AFE_PORT_I2S_SD4;
  5913. break;
  5914. case MSM_MI2S_SD5:
  5915. *config_ptr = AFE_PORT_I2S_SD5;
  5916. break;
  5917. case MSM_MI2S_SD6:
  5918. *config_ptr = AFE_PORT_I2S_SD6;
  5919. break;
  5920. case MSM_MI2S_SD7:
  5921. *config_ptr = AFE_PORT_I2S_SD7;
  5922. break;
  5923. default:
  5924. pr_err("%s: invalid SD lines %d\n",
  5925. __func__, sd_lines);
  5926. goto error_invalid_data;
  5927. }
  5928. break;
  5929. case 2:
  5930. switch (sd_lines) {
  5931. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5932. *config_ptr = AFE_PORT_I2S_QUAD01;
  5933. break;
  5934. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5935. *config_ptr = AFE_PORT_I2S_QUAD23;
  5936. break;
  5937. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5938. *config_ptr = AFE_PORT_I2S_QUAD45;
  5939. break;
  5940. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5941. *config_ptr = AFE_PORT_I2S_QUAD67;
  5942. break;
  5943. default:
  5944. pr_err("%s: invalid SD lines %d\n",
  5945. __func__, sd_lines);
  5946. goto error_invalid_data;
  5947. }
  5948. break;
  5949. case 3:
  5950. switch (sd_lines) {
  5951. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5952. *config_ptr = AFE_PORT_I2S_6CHS;
  5953. break;
  5954. default:
  5955. pr_err("%s: invalid SD lines %d\n",
  5956. __func__, sd_lines);
  5957. goto error_invalid_data;
  5958. }
  5959. break;
  5960. case 4:
  5961. switch (sd_lines) {
  5962. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5963. *config_ptr = AFE_PORT_I2S_8CHS;
  5964. break;
  5965. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5966. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5967. break;
  5968. default:
  5969. pr_err("%s: invalid SD lines %d\n",
  5970. __func__, sd_lines);
  5971. goto error_invalid_data;
  5972. }
  5973. break;
  5974. case 5:
  5975. switch (sd_lines) {
  5976. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5977. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5978. *config_ptr = AFE_PORT_I2S_10CHS;
  5979. break;
  5980. default:
  5981. pr_err("%s: invalid SD lines %d\n",
  5982. __func__, sd_lines);
  5983. goto error_invalid_data;
  5984. }
  5985. break;
  5986. case 6:
  5987. switch (sd_lines) {
  5988. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5989. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5990. *config_ptr = AFE_PORT_I2S_12CHS;
  5991. break;
  5992. default:
  5993. pr_err("%s: invalid SD lines %d\n",
  5994. __func__, sd_lines);
  5995. goto error_invalid_data;
  5996. }
  5997. break;
  5998. case 7:
  5999. switch (sd_lines) {
  6000. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  6001. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  6002. *config_ptr = AFE_PORT_I2S_14CHS;
  6003. break;
  6004. default:
  6005. pr_err("%s: invalid SD lines %d\n",
  6006. __func__, sd_lines);
  6007. goto error_invalid_data;
  6008. }
  6009. break;
  6010. case 8:
  6011. switch (sd_lines) {
  6012. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  6013. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  6014. *config_ptr = AFE_PORT_I2S_16CHS;
  6015. break;
  6016. default:
  6017. pr_err("%s: invalid SD lines %d\n",
  6018. __func__, sd_lines);
  6019. goto error_invalid_data;
  6020. }
  6021. break;
  6022. default:
  6023. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  6024. goto error_invalid_data;
  6025. }
  6026. *ch_cnt = num_of_sd_lines;
  6027. return 0;
  6028. error_invalid_data:
  6029. pr_err("%s: invalid data\n", __func__);
  6030. return -EINVAL;
  6031. }
  6032. static u16 msm_dai_q6_mi2s_get_num_channels(u16 config)
  6033. {
  6034. switch (config) {
  6035. case AFE_PORT_I2S_SD0:
  6036. case AFE_PORT_I2S_SD1:
  6037. case AFE_PORT_I2S_SD2:
  6038. case AFE_PORT_I2S_SD3:
  6039. case AFE_PORT_I2S_SD4:
  6040. case AFE_PORT_I2S_SD5:
  6041. case AFE_PORT_I2S_SD6:
  6042. case AFE_PORT_I2S_SD7:
  6043. return 2;
  6044. case AFE_PORT_I2S_QUAD01:
  6045. case AFE_PORT_I2S_QUAD23:
  6046. case AFE_PORT_I2S_QUAD45:
  6047. case AFE_PORT_I2S_QUAD67:
  6048. return 4;
  6049. case AFE_PORT_I2S_6CHS:
  6050. return 6;
  6051. case AFE_PORT_I2S_8CHS:
  6052. case AFE_PORT_I2S_8CHS_2:
  6053. return 8;
  6054. case AFE_PORT_I2S_10CHS:
  6055. return 10;
  6056. case AFE_PORT_I2S_12CHS:
  6057. return 12;
  6058. case AFE_PORT_I2S_14CHS:
  6059. return 14;
  6060. case AFE_PORT_I2S_16CHS:
  6061. return 16;
  6062. default:
  6063. pr_err("%s: invalid config\n", __func__);
  6064. return 0;
  6065. }
  6066. }
  6067. static int msm_dai_q6_mi2s_platform_data_validation(
  6068. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  6069. {
  6070. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  6071. struct msm_mi2s_pdata *mi2s_pdata =
  6072. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  6073. unsigned int ch_cnt;
  6074. int rc = 0;
  6075. u16 sd_line;
  6076. if (mi2s_pdata == NULL) {
  6077. pr_err("%s: mi2s_pdata NULL", __func__);
  6078. return -EINVAL;
  6079. }
  6080. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  6081. &sd_line, &ch_cnt);
  6082. if (rc < 0) {
  6083. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  6084. goto rtn;
  6085. }
  6086. if (ch_cnt) {
  6087. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  6088. sd_line;
  6089. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  6090. dai_driver->playback.channels_min = 1;
  6091. dai_driver->playback.channels_max = ch_cnt << 1;
  6092. } else {
  6093. dai_driver->playback.channels_min = 0;
  6094. dai_driver->playback.channels_max = 0;
  6095. }
  6096. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  6097. &sd_line, &ch_cnt);
  6098. if (rc < 0) {
  6099. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  6100. goto rtn;
  6101. }
  6102. if (ch_cnt) {
  6103. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  6104. sd_line;
  6105. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  6106. dai_driver->capture.channels_min = 1;
  6107. dai_driver->capture.channels_max = ch_cnt << 1;
  6108. } else {
  6109. dai_driver->capture.channels_min = 0;
  6110. dai_driver->capture.channels_max = 0;
  6111. }
  6112. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  6113. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  6114. dai_data->tx_dai.pdata_mi2s_lines);
  6115. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  6116. __func__, dai_driver->playback.channels_max,
  6117. dai_driver->capture.channels_max);
  6118. rtn:
  6119. return rc;
  6120. }
  6121. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  6122. .name = "msm-dai-q6-mi2s",
  6123. };
  6124. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  6125. {
  6126. struct msm_dai_q6_mi2s_dai_data *dai_data;
  6127. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  6128. u32 tx_line = 0;
  6129. u32 rx_line = 0;
  6130. u32 mi2s_intf = 0;
  6131. struct msm_mi2s_pdata *mi2s_pdata;
  6132. int rc;
  6133. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  6134. &mi2s_intf);
  6135. if (rc) {
  6136. dev_err(&pdev->dev,
  6137. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  6138. goto rtn;
  6139. }
  6140. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  6141. mi2s_intf);
  6142. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  6143. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  6144. dev_err(&pdev->dev,
  6145. "%s: Invalid MI2S ID %u from Device Tree\n",
  6146. __func__, mi2s_intf);
  6147. rc = -ENXIO;
  6148. goto rtn;
  6149. }
  6150. pdev->id = mi2s_intf;
  6151. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  6152. if (!mi2s_pdata) {
  6153. rc = -ENOMEM;
  6154. goto rtn;
  6155. }
  6156. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  6157. &rx_line);
  6158. if (rc) {
  6159. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  6160. "qcom,msm-mi2s-rx-lines");
  6161. goto free_pdata;
  6162. }
  6163. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  6164. &tx_line);
  6165. if (rc) {
  6166. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  6167. "qcom,msm-mi2s-tx-lines");
  6168. goto free_pdata;
  6169. }
  6170. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  6171. dev_name(&pdev->dev), rx_line, tx_line);
  6172. mi2s_pdata->rx_sd_lines = rx_line;
  6173. mi2s_pdata->tx_sd_lines = tx_line;
  6174. mi2s_pdata->intf_id = mi2s_intf;
  6175. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  6176. GFP_KERNEL);
  6177. if (!dai_data) {
  6178. rc = -ENOMEM;
  6179. goto free_pdata;
  6180. } else
  6181. dev_set_drvdata(&pdev->dev, dai_data);
  6182. rc = of_property_read_u32(pdev->dev.of_node,
  6183. "qcom,msm-dai-is-island-supported",
  6184. &dai_data->is_island_dai);
  6185. if (rc)
  6186. dev_dbg(&pdev->dev, "island supported entry not found\n");
  6187. pdev->dev.platform_data = mi2s_pdata;
  6188. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  6189. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  6190. if (rc < 0)
  6191. goto free_dai_data;
  6192. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  6193. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  6194. if (rc < 0)
  6195. goto err_register;
  6196. return 0;
  6197. err_register:
  6198. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  6199. free_dai_data:
  6200. kfree(dai_data);
  6201. free_pdata:
  6202. kfree(mi2s_pdata);
  6203. rtn:
  6204. return rc;
  6205. }
  6206. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  6207. {
  6208. snd_soc_unregister_component(&pdev->dev);
  6209. return 0;
  6210. }
  6211. static int msm_dai_q6_dai_meta_mi2s_probe(struct snd_soc_dai *dai)
  6212. {
  6213. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6214. (struct msm_meta_mi2s_pdata *) dai->dev->platform_data;
  6215. int rc = 0;
  6216. dai->id = meta_mi2s_pdata->intf_id;
  6217. rc = msm_dai_q6_dai_add_route(dai);
  6218. return rc;
  6219. }
  6220. static int msm_dai_q6_dai_meta_mi2s_remove(struct snd_soc_dai *dai)
  6221. {
  6222. return 0;
  6223. }
  6224. static int msm_dai_q6_meta_mi2s_startup(struct snd_pcm_substream *substream,
  6225. struct snd_soc_dai *dai)
  6226. {
  6227. return 0;
  6228. }
  6229. static int msm_meta_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  6230. {
  6231. int ret = 0;
  6232. switch (stream) {
  6233. case SNDRV_PCM_STREAM_PLAYBACK:
  6234. switch (mi2s_id) {
  6235. case MSM_PRIM_META_MI2S:
  6236. *port_id = AFE_PORT_ID_PRIMARY_META_MI2S_RX;
  6237. break;
  6238. case MSM_SEC_META_MI2S:
  6239. *port_id = AFE_PORT_ID_SECONDARY_META_MI2S_RX;
  6240. break;
  6241. default:
  6242. pr_err("%s: playback err id 0x%x\n",
  6243. __func__, mi2s_id);
  6244. ret = -1;
  6245. break;
  6246. }
  6247. break;
  6248. case SNDRV_PCM_STREAM_CAPTURE:
  6249. switch (mi2s_id) {
  6250. default:
  6251. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  6252. ret = -1;
  6253. break;
  6254. }
  6255. break;
  6256. default:
  6257. pr_err("%s: default err %d\n", __func__, stream);
  6258. ret = -1;
  6259. break;
  6260. }
  6261. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  6262. return ret;
  6263. }
  6264. static int msm_dai_q6_meta_mi2s_prepare(struct snd_pcm_substream *substream,
  6265. struct snd_soc_dai *dai)
  6266. {
  6267. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6268. dev_get_drvdata(dai->dev);
  6269. u16 port_id = 0;
  6270. int rc = 0;
  6271. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6272. &port_id) != 0) {
  6273. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6274. __func__, port_id);
  6275. return -EINVAL;
  6276. }
  6277. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  6278. "dai_data->channels = %u sample_rate = %u\n", __func__,
  6279. dai->id, port_id, dai_data->channels, dai_data->rate);
  6280. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6281. /* PORT START should be set if prepare called
  6282. * in active state.
  6283. */
  6284. rc = afe_port_start(port_id, &dai_data->port_config,
  6285. dai_data->rate);
  6286. if (rc < 0)
  6287. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  6288. dai->id);
  6289. else
  6290. set_bit(STATUS_PORT_STARTED,
  6291. dai_data->status_mask);
  6292. }
  6293. return rc;
  6294. }
  6295. static int msm_dai_q6_meta_mi2s_hw_params(struct snd_pcm_substream *substream,
  6296. struct snd_pcm_hw_params *params,
  6297. struct snd_soc_dai *dai)
  6298. {
  6299. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6300. dev_get_drvdata(dai->dev);
  6301. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6302. &dai_data->port_config.meta_i2s;
  6303. int idx = 0;
  6304. u16 port_channels = 0;
  6305. u16 channels_left = 0;
  6306. dai_data->channels = params_channels(params);
  6307. channels_left = dai_data->channels;
  6308. /* map requested channels to channels that member ports provide */
  6309. for (idx = 0; idx < dai_data->num_member_ports; idx++) {
  6310. port_channels = msm_dai_q6_mi2s_get_num_channels(
  6311. dai_data->channel_mode[idx]);
  6312. if (channels_left >= port_channels) {
  6313. port_cfg->member_port_id[idx] =
  6314. dai_data->member_port_id[idx];
  6315. port_cfg->member_port_channel_mode[idx] =
  6316. dai_data->channel_mode[idx];
  6317. channels_left -= port_channels;
  6318. } else {
  6319. switch (channels_left) {
  6320. case 15:
  6321. case 16:
  6322. switch (dai_data->channel_mode[idx]) {
  6323. case AFE_PORT_I2S_16CHS:
  6324. port_cfg->member_port_channel_mode[idx]
  6325. = AFE_PORT_I2S_16CHS;
  6326. break;
  6327. default:
  6328. goto error_invalid_data;
  6329. };
  6330. break;
  6331. case 13:
  6332. case 14:
  6333. switch (dai_data->channel_mode[idx]) {
  6334. case AFE_PORT_I2S_14CHS:
  6335. case AFE_PORT_I2S_16CHS:
  6336. port_cfg->member_port_channel_mode[idx]
  6337. = AFE_PORT_I2S_14CHS;
  6338. break;
  6339. default:
  6340. goto error_invalid_data;
  6341. };
  6342. break;
  6343. case 11:
  6344. case 12:
  6345. switch (dai_data->channel_mode[idx]) {
  6346. case AFE_PORT_I2S_12CHS:
  6347. case AFE_PORT_I2S_14CHS:
  6348. case AFE_PORT_I2S_16CHS:
  6349. port_cfg->member_port_channel_mode[idx]
  6350. = AFE_PORT_I2S_12CHS;
  6351. break;
  6352. default:
  6353. goto error_invalid_data;
  6354. };
  6355. break;
  6356. case 9:
  6357. case 10:
  6358. switch (dai_data->channel_mode[idx]) {
  6359. case AFE_PORT_I2S_10CHS:
  6360. case AFE_PORT_I2S_12CHS:
  6361. case AFE_PORT_I2S_14CHS:
  6362. case AFE_PORT_I2S_16CHS:
  6363. port_cfg->member_port_channel_mode[idx]
  6364. = AFE_PORT_I2S_10CHS;
  6365. break;
  6366. default:
  6367. goto error_invalid_data;
  6368. };
  6369. break;
  6370. case 8:
  6371. case 7:
  6372. switch (dai_data->channel_mode[idx]) {
  6373. case AFE_PORT_I2S_8CHS:
  6374. case AFE_PORT_I2S_10CHS:
  6375. case AFE_PORT_I2S_12CHS:
  6376. case AFE_PORT_I2S_14CHS:
  6377. case AFE_PORT_I2S_16CHS:
  6378. port_cfg->member_port_channel_mode[idx]
  6379. = AFE_PORT_I2S_8CHS;
  6380. break;
  6381. case AFE_PORT_I2S_8CHS_2:
  6382. port_cfg->member_port_channel_mode[idx]
  6383. = AFE_PORT_I2S_8CHS_2;
  6384. break;
  6385. default:
  6386. goto error_invalid_data;
  6387. };
  6388. break;
  6389. case 6:
  6390. case 5:
  6391. switch (dai_data->channel_mode[idx]) {
  6392. case AFE_PORT_I2S_6CHS:
  6393. case AFE_PORT_I2S_8CHS:
  6394. case AFE_PORT_I2S_10CHS:
  6395. case AFE_PORT_I2S_12CHS:
  6396. case AFE_PORT_I2S_14CHS:
  6397. case AFE_PORT_I2S_16CHS:
  6398. port_cfg->member_port_channel_mode[idx]
  6399. = AFE_PORT_I2S_6CHS;
  6400. break;
  6401. default:
  6402. goto error_invalid_data;
  6403. };
  6404. break;
  6405. case 4:
  6406. case 3:
  6407. switch (dai_data->channel_mode[idx]) {
  6408. case AFE_PORT_I2S_SD0:
  6409. case AFE_PORT_I2S_SD1:
  6410. case AFE_PORT_I2S_SD2:
  6411. case AFE_PORT_I2S_SD3:
  6412. case AFE_PORT_I2S_SD4:
  6413. case AFE_PORT_I2S_SD5:
  6414. case AFE_PORT_I2S_SD6:
  6415. case AFE_PORT_I2S_SD7:
  6416. goto error_invalid_data;
  6417. case AFE_PORT_I2S_QUAD01:
  6418. case AFE_PORT_I2S_QUAD23:
  6419. case AFE_PORT_I2S_QUAD45:
  6420. case AFE_PORT_I2S_QUAD67:
  6421. port_cfg->member_port_channel_mode[idx]
  6422. = dai_data->channel_mode[idx];
  6423. break;
  6424. case AFE_PORT_I2S_8CHS_2:
  6425. port_cfg->member_port_channel_mode[idx]
  6426. = AFE_PORT_I2S_QUAD45;
  6427. break;
  6428. default:
  6429. port_cfg->member_port_channel_mode[idx]
  6430. = AFE_PORT_I2S_QUAD01;
  6431. };
  6432. break;
  6433. case 2:
  6434. case 1:
  6435. if (dai_data->channel_mode[idx] <
  6436. AFE_PORT_I2S_SD0)
  6437. goto error_invalid_data;
  6438. switch (dai_data->channel_mode[idx]) {
  6439. case AFE_PORT_I2S_SD0:
  6440. case AFE_PORT_I2S_SD1:
  6441. case AFE_PORT_I2S_SD2:
  6442. case AFE_PORT_I2S_SD3:
  6443. case AFE_PORT_I2S_SD4:
  6444. case AFE_PORT_I2S_SD5:
  6445. case AFE_PORT_I2S_SD6:
  6446. case AFE_PORT_I2S_SD7:
  6447. port_cfg->member_port_channel_mode[idx]
  6448. = dai_data->channel_mode[idx];
  6449. break;
  6450. case AFE_PORT_I2S_QUAD01:
  6451. case AFE_PORT_I2S_6CHS:
  6452. case AFE_PORT_I2S_8CHS:
  6453. case AFE_PORT_I2S_10CHS:
  6454. case AFE_PORT_I2S_12CHS:
  6455. case AFE_PORT_I2S_14CHS:
  6456. case AFE_PORT_I2S_16CHS:
  6457. port_cfg->member_port_channel_mode[idx]
  6458. = AFE_PORT_I2S_SD0;
  6459. break;
  6460. case AFE_PORT_I2S_QUAD23:
  6461. port_cfg->member_port_channel_mode[idx]
  6462. = AFE_PORT_I2S_SD2;
  6463. break;
  6464. case AFE_PORT_I2S_QUAD45:
  6465. case AFE_PORT_I2S_8CHS_2:
  6466. port_cfg->member_port_channel_mode[idx]
  6467. = AFE_PORT_I2S_SD4;
  6468. break;
  6469. case AFE_PORT_I2S_QUAD67:
  6470. port_cfg->member_port_channel_mode[idx]
  6471. = AFE_PORT_I2S_SD6;
  6472. break;
  6473. }
  6474. break;
  6475. case 0:
  6476. port_cfg->member_port_channel_mode[idx] = 0;
  6477. }
  6478. if (port_cfg->member_port_channel_mode[idx] == 0) {
  6479. port_cfg->member_port_id[idx] =
  6480. AFE_PORT_ID_INVALID;
  6481. } else {
  6482. port_cfg->member_port_id[idx] =
  6483. dai_data->member_port_id[idx];
  6484. channels_left -=
  6485. msm_dai_q6_mi2s_get_num_channels(
  6486. port_cfg->member_port_channel_mode[idx]);
  6487. }
  6488. }
  6489. }
  6490. if (channels_left > 0) {
  6491. pr_err("%s: too many channels %d\n",
  6492. __func__, dai_data->channels);
  6493. return -EINVAL;
  6494. }
  6495. dai_data->rate = params_rate(params);
  6496. port_cfg->sample_rate = dai_data->rate;
  6497. switch (params_format(params)) {
  6498. case SNDRV_PCM_FORMAT_S16_LE:
  6499. case SNDRV_PCM_FORMAT_SPECIAL:
  6500. port_cfg->bit_width = 16;
  6501. dai_data->bitwidth = 16;
  6502. break;
  6503. case SNDRV_PCM_FORMAT_S24_LE:
  6504. case SNDRV_PCM_FORMAT_S24_3LE:
  6505. port_cfg->bit_width = 24;
  6506. dai_data->bitwidth = 24;
  6507. break;
  6508. case SNDRV_PCM_FORMAT_S32_LE:
  6509. port_cfg->bit_width = 32;
  6510. dai_data->bitwidth = 32;
  6511. break;
  6512. default:
  6513. pr_err("%s: format %d\n",
  6514. __func__, params_format(params));
  6515. return -EINVAL;
  6516. }
  6517. port_cfg->minor_version = AFE_API_VERSION_META_I2S_CONFIG;
  6518. port_cfg->data_format = AFE_LINEAR_PCM_DATA;
  6519. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  6520. "bit_width = %hu ws_src = 0x%x sample_rate = %u\n"
  6521. "member_ports 0x%x 0x%x 0x%x 0x%x\n"
  6522. "sd_lines 0x%x 0x%x 0x%x 0x%x\n",
  6523. __func__, dai->id, dai_data->channels,
  6524. port_cfg->bit_width, port_cfg->ws_src, port_cfg->sample_rate,
  6525. port_cfg->member_port_id[0],
  6526. port_cfg->member_port_id[1],
  6527. port_cfg->member_port_id[2],
  6528. port_cfg->member_port_id[3],
  6529. port_cfg->member_port_channel_mode[0],
  6530. port_cfg->member_port_channel_mode[1],
  6531. port_cfg->member_port_channel_mode[2],
  6532. port_cfg->member_port_channel_mode[3]);
  6533. return 0;
  6534. error_invalid_data:
  6535. pr_err("%s: error when assigning member port %d channels (channels_left %d)\n",
  6536. __func__, idx, channels_left);
  6537. return -EINVAL;
  6538. }
  6539. static int msm_dai_q6_meta_mi2s_set_fmt(struct snd_soc_dai *dai,
  6540. unsigned int fmt)
  6541. {
  6542. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6543. dev_get_drvdata(dai->dev);
  6544. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6545. dev_err(dai->dev, "%s: err chg meta i2s mode while dai running",
  6546. __func__);
  6547. return -EPERM;
  6548. }
  6549. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  6550. case SND_SOC_DAIFMT_CBS_CFS:
  6551. dai_data->port_config.meta_i2s.ws_src = 1;
  6552. break;
  6553. case SND_SOC_DAIFMT_CBM_CFM:
  6554. dai_data->port_config.meta_i2s.ws_src = 0;
  6555. break;
  6556. default:
  6557. pr_err("%s: fmt %d\n",
  6558. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  6559. return -EINVAL;
  6560. }
  6561. return 0;
  6562. }
  6563. static void msm_dai_q6_meta_mi2s_shutdown(struct snd_pcm_substream *substream,
  6564. struct snd_soc_dai *dai)
  6565. {
  6566. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6567. dev_get_drvdata(dai->dev);
  6568. u16 port_id = 0;
  6569. int rc = 0;
  6570. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6571. &port_id) != 0) {
  6572. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6573. __func__, port_id);
  6574. }
  6575. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  6576. __func__, port_id);
  6577. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6578. rc = afe_close(port_id);
  6579. if (rc < 0)
  6580. dev_err(dai->dev, "fail to close AFE port\n");
  6581. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  6582. }
  6583. }
  6584. static struct snd_soc_dai_ops msm_dai_q6_meta_mi2s_ops = {
  6585. .startup = msm_dai_q6_meta_mi2s_startup,
  6586. .prepare = msm_dai_q6_meta_mi2s_prepare,
  6587. .hw_params = msm_dai_q6_meta_mi2s_hw_params,
  6588. .set_fmt = msm_dai_q6_meta_mi2s_set_fmt,
  6589. .shutdown = msm_dai_q6_meta_mi2s_shutdown,
  6590. };
  6591. /* Channel min and max are initialized base on platform data */
  6592. static struct snd_soc_dai_driver msm_dai_q6_meta_mi2s_dai[] = {
  6593. {
  6594. .playback = {
  6595. .stream_name = "Primary META MI2S Playback",
  6596. .aif_name = "PRI_META_MI2S_RX",
  6597. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6598. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6599. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6600. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  6601. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  6602. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6603. SNDRV_PCM_RATE_384000,
  6604. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6605. SNDRV_PCM_FMTBIT_S24_LE |
  6606. SNDRV_PCM_FMTBIT_S24_3LE,
  6607. .rate_min = 8000,
  6608. .rate_max = 384000,
  6609. },
  6610. .ops = &msm_dai_q6_meta_mi2s_ops,
  6611. .name = "Primary META MI2S",
  6612. .id = AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  6613. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6614. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6615. },
  6616. {
  6617. .playback = {
  6618. .stream_name = "Secondary META MI2S Playback",
  6619. .aif_name = "SEC_META_MI2S_RX",
  6620. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6621. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6622. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6623. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  6624. SNDRV_PCM_RATE_192000,
  6625. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  6626. .rate_min = 8000,
  6627. .rate_max = 192000,
  6628. },
  6629. .ops = &msm_dai_q6_meta_mi2s_ops,
  6630. .name = "Secondary META MI2S",
  6631. .id = AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  6632. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6633. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6634. },
  6635. };
  6636. static int msm_dai_q6_meta_mi2s_platform_data_validation(
  6637. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  6638. {
  6639. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6640. dev_get_drvdata(&pdev->dev);
  6641. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6642. (struct msm_meta_mi2s_pdata *) pdev->dev.platform_data;
  6643. int rc = 0;
  6644. int idx = 0;
  6645. u16 channel_mode = 0;
  6646. unsigned int ch_cnt = 0;
  6647. unsigned int ch_cnt_sum = 0;
  6648. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6649. &dai_data->port_config.meta_i2s;
  6650. if (meta_mi2s_pdata == NULL) {
  6651. pr_err("%s: meta_mi2s_pdata NULL", __func__);
  6652. return -EINVAL;
  6653. }
  6654. dai_data->num_member_ports = meta_mi2s_pdata->num_member_ports;
  6655. for (idx = 0; idx < meta_mi2s_pdata->num_member_ports; idx++) {
  6656. rc = msm_dai_q6_mi2s_get_lineconfig(
  6657. meta_mi2s_pdata->sd_lines[idx],
  6658. &channel_mode,
  6659. &ch_cnt);
  6660. if (rc < 0) {
  6661. dev_err(&pdev->dev, "invalid META MI2S RX sd line config\n");
  6662. goto rtn;
  6663. }
  6664. if (ch_cnt) {
  6665. msm_mi2s_get_port_id(meta_mi2s_pdata->member_port[idx],
  6666. SNDRV_PCM_STREAM_PLAYBACK,
  6667. &dai_data->member_port_id[idx]);
  6668. dai_data->channel_mode[idx] = channel_mode;
  6669. port_cfg->member_port_id[idx] =
  6670. dai_data->member_port_id[idx];
  6671. port_cfg->member_port_channel_mode[idx] = channel_mode;
  6672. }
  6673. ch_cnt_sum += ch_cnt;
  6674. }
  6675. if (ch_cnt_sum) {
  6676. dai_driver->playback.channels_min = 1;
  6677. dai_driver->playback.channels_max = ch_cnt_sum << 1;
  6678. } else {
  6679. dai_driver->playback.channels_min = 0;
  6680. dai_driver->playback.channels_max = 0;
  6681. }
  6682. dev_dbg(&pdev->dev, "%s: sdline 0x%x 0x%x 0x%x 0x%x\n", __func__,
  6683. dai_data->channel_mode[0], dai_data->channel_mode[1],
  6684. dai_data->channel_mode[2], dai_data->channel_mode[3]);
  6685. dev_dbg(&pdev->dev, "%s: playback ch_max %d\n",
  6686. __func__, dai_driver->playback.channels_max);
  6687. rtn:
  6688. return rc;
  6689. }
  6690. static const struct snd_soc_component_driver msm_q6_meta_mi2s_dai_component = {
  6691. .name = "msm-dai-q6-meta-mi2s",
  6692. };
  6693. static int msm_dai_q6_meta_mi2s_dev_probe(struct platform_device *pdev)
  6694. {
  6695. struct msm_dai_q6_meta_mi2s_dai_data *dai_data;
  6696. const char *q6_meta_mi2s_dev_id = "qcom,msm-dai-q6-meta-mi2s-dev-id";
  6697. u32 dev_id = 0;
  6698. u32 meta_mi2s_intf = 0;
  6699. struct msm_meta_mi2s_pdata *meta_mi2s_pdata;
  6700. int rc;
  6701. rc = of_property_read_u32(pdev->dev.of_node, q6_meta_mi2s_dev_id,
  6702. &dev_id);
  6703. if (rc) {
  6704. dev_err(&pdev->dev,
  6705. "%s: missing %s in dt node\n", __func__,
  6706. q6_meta_mi2s_dev_id);
  6707. goto rtn;
  6708. }
  6709. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  6710. dev_id);
  6711. switch (dev_id) {
  6712. case AFE_PORT_ID_PRIMARY_META_MI2S_RX:
  6713. meta_mi2s_intf = 0;
  6714. break;
  6715. case AFE_PORT_ID_SECONDARY_META_MI2S_RX:
  6716. meta_mi2s_intf = 1;
  6717. break;
  6718. default:
  6719. dev_err(&pdev->dev,
  6720. "%s: Invalid META MI2S ID 0x%x from Device Tree\n",
  6721. __func__, dev_id);
  6722. rc = -ENXIO;
  6723. goto rtn;
  6724. }
  6725. pdev->id = dev_id;
  6726. meta_mi2s_pdata = kzalloc(sizeof(struct msm_meta_mi2s_pdata),
  6727. GFP_KERNEL);
  6728. if (!meta_mi2s_pdata) {
  6729. rc = -ENOMEM;
  6730. goto rtn;
  6731. }
  6732. rc = of_property_read_u32(pdev->dev.of_node,
  6733. "qcom,msm-mi2s-num-members",
  6734. &meta_mi2s_pdata->num_member_ports);
  6735. if (rc) {
  6736. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  6737. __func__, "qcom,msm-mi2s-num-members");
  6738. goto free_pdata;
  6739. }
  6740. if (meta_mi2s_pdata->num_member_ports >
  6741. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  6742. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  6743. __func__, meta_mi2s_pdata->num_member_ports);
  6744. goto free_pdata;
  6745. }
  6746. rc = of_property_read_u32_array(pdev->dev.of_node,
  6747. "qcom,msm-mi2s-member-id",
  6748. meta_mi2s_pdata->member_port,
  6749. meta_mi2s_pdata->num_member_ports);
  6750. if (rc) {
  6751. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  6752. __func__, "qcom,msm-mi2s-member-id");
  6753. goto free_pdata;
  6754. }
  6755. rc = of_property_read_u32_array(pdev->dev.of_node,
  6756. "qcom,msm-mi2s-rx-lines",
  6757. meta_mi2s_pdata->sd_lines,
  6758. meta_mi2s_pdata->num_member_ports);
  6759. if (rc) {
  6760. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n",
  6761. __func__, "qcom,msm-mi2s-rx-lines");
  6762. goto free_pdata;
  6763. }
  6764. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  6765. dev_name(&pdev->dev), meta_mi2s_pdata->num_member_ports);
  6766. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  6767. meta_mi2s_pdata->member_port[0],
  6768. meta_mi2s_pdata->member_port[1],
  6769. meta_mi2s_pdata->member_port[2],
  6770. meta_mi2s_pdata->member_port[3]);
  6771. dev_dbg(&pdev->dev, "sd-lines array (0x%x, 0x%x, 0x%x, 0x%x)\n",
  6772. meta_mi2s_pdata->sd_lines[0],
  6773. meta_mi2s_pdata->sd_lines[1],
  6774. meta_mi2s_pdata->sd_lines[2],
  6775. meta_mi2s_pdata->sd_lines[3]);
  6776. meta_mi2s_pdata->intf_id = meta_mi2s_intf;
  6777. dai_data = kzalloc(sizeof(struct msm_dai_q6_meta_mi2s_dai_data),
  6778. GFP_KERNEL);
  6779. if (!dai_data) {
  6780. rc = -ENOMEM;
  6781. goto free_pdata;
  6782. } else
  6783. dev_set_drvdata(&pdev->dev, dai_data);
  6784. pdev->dev.platform_data = meta_mi2s_pdata;
  6785. rc = msm_dai_q6_meta_mi2s_platform_data_validation(pdev,
  6786. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf]);
  6787. if (rc < 0)
  6788. goto free_dai_data;
  6789. rc = snd_soc_register_component(&pdev->dev,
  6790. &msm_q6_meta_mi2s_dai_component,
  6791. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf], 1);
  6792. if (rc < 0)
  6793. goto err_register;
  6794. return 0;
  6795. err_register:
  6796. dev_err(&pdev->dev, "fail to %s\n", __func__);
  6797. free_dai_data:
  6798. kfree(dai_data);
  6799. free_pdata:
  6800. kfree(meta_mi2s_pdata);
  6801. rtn:
  6802. return rc;
  6803. }
  6804. static int msm_dai_q6_meta_mi2s_dev_remove(struct platform_device *pdev)
  6805. {
  6806. snd_soc_unregister_component(&pdev->dev);
  6807. return 0;
  6808. }
  6809. static const struct snd_soc_component_driver msm_dai_q6_component = {
  6810. .name = "msm-dai-q6-dev",
  6811. };
  6812. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  6813. {
  6814. int rc, id, i, len;
  6815. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6816. char stream_name[80];
  6817. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6818. if (rc) {
  6819. dev_err(&pdev->dev,
  6820. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6821. return rc;
  6822. }
  6823. pdev->id = id;
  6824. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6825. dev_name(&pdev->dev), pdev->id);
  6826. switch (id) {
  6827. case SLIMBUS_0_RX:
  6828. strlcpy(stream_name, "Slimbus Playback", 80);
  6829. goto register_slim_playback;
  6830. case SLIMBUS_2_RX:
  6831. strlcpy(stream_name, "Slimbus2 Playback", 80);
  6832. goto register_slim_playback;
  6833. case SLIMBUS_1_RX:
  6834. strlcpy(stream_name, "Slimbus1 Playback", 80);
  6835. goto register_slim_playback;
  6836. case SLIMBUS_3_RX:
  6837. strlcpy(stream_name, "Slimbus3 Playback", 80);
  6838. goto register_slim_playback;
  6839. case SLIMBUS_4_RX:
  6840. strlcpy(stream_name, "Slimbus4 Playback", 80);
  6841. goto register_slim_playback;
  6842. case SLIMBUS_5_RX:
  6843. strlcpy(stream_name, "Slimbus5 Playback", 80);
  6844. goto register_slim_playback;
  6845. case SLIMBUS_6_RX:
  6846. strlcpy(stream_name, "Slimbus6 Playback", 80);
  6847. goto register_slim_playback;
  6848. case SLIMBUS_7_RX:
  6849. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  6850. goto register_slim_playback;
  6851. case SLIMBUS_8_RX:
  6852. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  6853. goto register_slim_playback;
  6854. case SLIMBUS_9_RX:
  6855. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  6856. goto register_slim_playback;
  6857. register_slim_playback:
  6858. rc = -ENODEV;
  6859. len = strnlen(stream_name, 80);
  6860. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  6861. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  6862. !strcmp(stream_name,
  6863. msm_dai_q6_slimbus_rx_dai[i]
  6864. .playback.stream_name)) {
  6865. rc = snd_soc_register_component(&pdev->dev,
  6866. &msm_dai_q6_component,
  6867. &msm_dai_q6_slimbus_rx_dai[i], 1);
  6868. break;
  6869. }
  6870. }
  6871. if (rc)
  6872. pr_err("%s: Device not found stream name %s\n",
  6873. __func__, stream_name);
  6874. break;
  6875. case SLIMBUS_0_TX:
  6876. strlcpy(stream_name, "Slimbus Capture", 80);
  6877. goto register_slim_capture;
  6878. case SLIMBUS_1_TX:
  6879. strlcpy(stream_name, "Slimbus1 Capture", 80);
  6880. goto register_slim_capture;
  6881. case SLIMBUS_2_TX:
  6882. strlcpy(stream_name, "Slimbus2 Capture", 80);
  6883. goto register_slim_capture;
  6884. case SLIMBUS_3_TX:
  6885. strlcpy(stream_name, "Slimbus3 Capture", 80);
  6886. goto register_slim_capture;
  6887. case SLIMBUS_4_TX:
  6888. strlcpy(stream_name, "Slimbus4 Capture", 80);
  6889. goto register_slim_capture;
  6890. case SLIMBUS_5_TX:
  6891. strlcpy(stream_name, "Slimbus5 Capture", 80);
  6892. goto register_slim_capture;
  6893. case SLIMBUS_6_TX:
  6894. strlcpy(stream_name, "Slimbus6 Capture", 80);
  6895. goto register_slim_capture;
  6896. case SLIMBUS_7_TX:
  6897. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  6898. goto register_slim_capture;
  6899. case SLIMBUS_8_TX:
  6900. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  6901. goto register_slim_capture;
  6902. case SLIMBUS_9_TX:
  6903. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  6904. goto register_slim_capture;
  6905. register_slim_capture:
  6906. rc = -ENODEV;
  6907. len = strnlen(stream_name, 80);
  6908. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  6909. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  6910. !strcmp(stream_name,
  6911. msm_dai_q6_slimbus_tx_dai[i]
  6912. .capture.stream_name)) {
  6913. rc = snd_soc_register_component(&pdev->dev,
  6914. &msm_dai_q6_component,
  6915. &msm_dai_q6_slimbus_tx_dai[i], 1);
  6916. break;
  6917. }
  6918. }
  6919. if (rc)
  6920. pr_err("%s: Device not found stream name %s\n",
  6921. __func__, stream_name);
  6922. break;
  6923. case AFE_LOOPBACK_TX:
  6924. rc = snd_soc_register_component(&pdev->dev,
  6925. &msm_dai_q6_component,
  6926. &msm_dai_q6_afe_lb_tx_dai[0],
  6927. 1);
  6928. break;
  6929. case INT_BT_SCO_RX:
  6930. rc = snd_soc_register_component(&pdev->dev,
  6931. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  6932. break;
  6933. case INT_BT_SCO_TX:
  6934. rc = snd_soc_register_component(&pdev->dev,
  6935. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  6936. break;
  6937. case INT_BT_A2DP_RX:
  6938. rc = snd_soc_register_component(&pdev->dev,
  6939. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  6940. break;
  6941. case INT_FM_RX:
  6942. rc = snd_soc_register_component(&pdev->dev,
  6943. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  6944. break;
  6945. case INT_FM_TX:
  6946. rc = snd_soc_register_component(&pdev->dev,
  6947. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  6948. break;
  6949. case AFE_PORT_ID_USB_RX:
  6950. rc = snd_soc_register_component(&pdev->dev,
  6951. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  6952. break;
  6953. case AFE_PORT_ID_USB_TX:
  6954. rc = snd_soc_register_component(&pdev->dev,
  6955. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  6956. break;
  6957. case RT_PROXY_DAI_001_RX:
  6958. strlcpy(stream_name, "AFE Playback", 80);
  6959. goto register_afe_playback;
  6960. case RT_PROXY_DAI_002_RX:
  6961. strlcpy(stream_name, "AFE-PROXY RX", 80);
  6962. register_afe_playback:
  6963. rc = -ENODEV;
  6964. len = strnlen(stream_name, 80);
  6965. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  6966. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  6967. !strcmp(stream_name,
  6968. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  6969. rc = snd_soc_register_component(&pdev->dev,
  6970. &msm_dai_q6_component,
  6971. &msm_dai_q6_afe_rx_dai[i], 1);
  6972. break;
  6973. }
  6974. }
  6975. if (rc)
  6976. pr_err("%s: Device not found stream name %s\n",
  6977. __func__, stream_name);
  6978. break;
  6979. case RT_PROXY_DAI_001_TX:
  6980. strlcpy(stream_name, "AFE-PROXY TX", 80);
  6981. goto register_afe_capture;
  6982. case RT_PROXY_DAI_002_TX:
  6983. strlcpy(stream_name, "AFE Capture", 80);
  6984. register_afe_capture:
  6985. rc = -ENODEV;
  6986. len = strnlen(stream_name, 80);
  6987. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  6988. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  6989. !strcmp(stream_name,
  6990. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  6991. rc = snd_soc_register_component(&pdev->dev,
  6992. &msm_dai_q6_component,
  6993. &msm_dai_q6_afe_tx_dai[i], 1);
  6994. break;
  6995. }
  6996. }
  6997. if (rc)
  6998. pr_err("%s: Device not found stream name %s\n",
  6999. __func__, stream_name);
  7000. break;
  7001. case RT_PROXY_DAI_003_TX:
  7002. rc = snd_soc_register_component(&pdev->dev,
  7003. &msm_dai_q6_component, &msm_dai_q6_afe_cap_dai, 1);
  7004. break;
  7005. case VOICE_PLAYBACK_TX:
  7006. strlcpy(stream_name, "Voice Farend Playback", 80);
  7007. goto register_voice_playback;
  7008. case VOICE2_PLAYBACK_TX:
  7009. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  7010. register_voice_playback:
  7011. rc = -ENODEV;
  7012. len = strnlen(stream_name, 80);
  7013. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  7014. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  7015. && !strcmp(stream_name,
  7016. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  7017. rc = snd_soc_register_component(&pdev->dev,
  7018. &msm_dai_q6_component,
  7019. &msm_dai_q6_voc_playback_dai[i], 1);
  7020. break;
  7021. }
  7022. }
  7023. if (rc)
  7024. pr_err("%s Device not found stream name %s\n",
  7025. __func__, stream_name);
  7026. break;
  7027. case VOICE_RECORD_RX:
  7028. strlcpy(stream_name, "Voice Downlink Capture", 80);
  7029. goto register_uplink_capture;
  7030. case VOICE_RECORD_TX:
  7031. strlcpy(stream_name, "Voice Uplink Capture", 80);
  7032. register_uplink_capture:
  7033. rc = -ENODEV;
  7034. len = strnlen(stream_name, 80);
  7035. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  7036. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  7037. && !strcmp(stream_name,
  7038. msm_dai_q6_incall_record_dai[i].
  7039. capture.stream_name)) {
  7040. rc = snd_soc_register_component(&pdev->dev,
  7041. &msm_dai_q6_component,
  7042. &msm_dai_q6_incall_record_dai[i], 1);
  7043. break;
  7044. }
  7045. }
  7046. if (rc)
  7047. pr_err("%s: Device not found stream name %s\n",
  7048. __func__, stream_name);
  7049. break;
  7050. case RT_PROXY_PORT_002_RX:
  7051. rc = snd_soc_register_component(&pdev->dev,
  7052. &msm_dai_q6_component, &msm_dai_q6_proxy_rx_dai, 1);
  7053. break;
  7054. case RT_PROXY_PORT_002_TX:
  7055. rc = snd_soc_register_component(&pdev->dev,
  7056. &msm_dai_q6_component, &msm_dai_q6_proxy_tx_dai, 1);
  7057. break;
  7058. default:
  7059. rc = -ENODEV;
  7060. break;
  7061. }
  7062. return rc;
  7063. }
  7064. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  7065. {
  7066. snd_soc_unregister_component(&pdev->dev);
  7067. return 0;
  7068. }
  7069. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  7070. { .compatible = "qcom,msm-dai-q6-dev", },
  7071. { }
  7072. };
  7073. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  7074. static struct platform_driver msm_dai_q6_dev = {
  7075. .probe = msm_dai_q6_dev_probe,
  7076. .remove = msm_dai_q6_dev_remove,
  7077. .driver = {
  7078. .name = "msm-dai-q6-dev",
  7079. .owner = THIS_MODULE,
  7080. .of_match_table = msm_dai_q6_dev_dt_match,
  7081. .suppress_bind_attrs = true,
  7082. },
  7083. };
  7084. static int msm_dai_q6_probe(struct platform_device *pdev)
  7085. {
  7086. int rc;
  7087. pr_debug("%s: dev name %s, id:%d\n", __func__,
  7088. dev_name(&pdev->dev), pdev->id);
  7089. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7090. if (rc) {
  7091. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7092. __func__, rc);
  7093. } else
  7094. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7095. return rc;
  7096. }
  7097. static int msm_dai_q6_remove(struct platform_device *pdev)
  7098. {
  7099. of_platform_depopulate(&pdev->dev);
  7100. return 0;
  7101. }
  7102. static const struct of_device_id msm_dai_q6_dt_match[] = {
  7103. { .compatible = "qcom,msm-dai-q6", },
  7104. { }
  7105. };
  7106. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  7107. static struct platform_driver msm_dai_q6 = {
  7108. .probe = msm_dai_q6_probe,
  7109. .remove = msm_dai_q6_remove,
  7110. .driver = {
  7111. .name = "msm-dai-q6",
  7112. .owner = THIS_MODULE,
  7113. .of_match_table = msm_dai_q6_dt_match,
  7114. .suppress_bind_attrs = true,
  7115. },
  7116. };
  7117. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  7118. {
  7119. int rc;
  7120. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7121. if (rc) {
  7122. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7123. __func__, rc);
  7124. } else
  7125. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7126. return rc;
  7127. }
  7128. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  7129. {
  7130. return 0;
  7131. }
  7132. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  7133. { .compatible = "qcom,msm-dai-mi2s", },
  7134. { }
  7135. };
  7136. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  7137. static struct platform_driver msm_dai_mi2s_q6 = {
  7138. .probe = msm_dai_mi2s_q6_probe,
  7139. .remove = msm_dai_mi2s_q6_remove,
  7140. .driver = {
  7141. .name = "msm-dai-mi2s",
  7142. .owner = THIS_MODULE,
  7143. .of_match_table = msm_dai_mi2s_dt_match,
  7144. .suppress_bind_attrs = true,
  7145. },
  7146. };
  7147. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  7148. { .compatible = "qcom,msm-dai-q6-mi2s", },
  7149. { }
  7150. };
  7151. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  7152. static struct platform_driver msm_dai_q6_mi2s_driver = {
  7153. .probe = msm_dai_q6_mi2s_dev_probe,
  7154. .remove = msm_dai_q6_mi2s_dev_remove,
  7155. .driver = {
  7156. .name = "msm-dai-q6-mi2s",
  7157. .owner = THIS_MODULE,
  7158. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  7159. .suppress_bind_attrs = true,
  7160. },
  7161. };
  7162. static const struct of_device_id msm_dai_q6_meta_mi2s_dev_dt_match[] = {
  7163. { .compatible = "qcom,msm-dai-q6-meta-mi2s", },
  7164. { }
  7165. };
  7166. MODULE_DEVICE_TABLE(of, msm_dai_q6_meta_mi2s_dev_dt_match);
  7167. static struct platform_driver msm_dai_q6_meta_mi2s_driver = {
  7168. .probe = msm_dai_q6_meta_mi2s_dev_probe,
  7169. .remove = msm_dai_q6_meta_mi2s_dev_remove,
  7170. .driver = {
  7171. .name = "msm-dai-q6-meta-mi2s",
  7172. .owner = THIS_MODULE,
  7173. .of_match_table = msm_dai_q6_meta_mi2s_dev_dt_match,
  7174. .suppress_bind_attrs = true,
  7175. },
  7176. };
  7177. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  7178. {
  7179. int rc, id;
  7180. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  7181. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  7182. if (rc) {
  7183. dev_err(&pdev->dev,
  7184. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  7185. return rc;
  7186. }
  7187. pdev->id = id;
  7188. pr_debug("%s: dev name %s, id:%d\n", __func__,
  7189. dev_name(&pdev->dev), pdev->id);
  7190. switch (pdev->id) {
  7191. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  7192. rc = snd_soc_register_component(&pdev->dev,
  7193. &msm_dai_spdif_q6_component,
  7194. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  7195. break;
  7196. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  7197. rc = snd_soc_register_component(&pdev->dev,
  7198. &msm_dai_spdif_q6_component,
  7199. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  7200. break;
  7201. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  7202. rc = snd_soc_register_component(&pdev->dev,
  7203. &msm_dai_spdif_q6_component,
  7204. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  7205. break;
  7206. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  7207. rc = snd_soc_register_component(&pdev->dev,
  7208. &msm_dai_spdif_q6_component,
  7209. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  7210. break;
  7211. default:
  7212. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  7213. rc = -ENODEV;
  7214. break;
  7215. }
  7216. return rc;
  7217. }
  7218. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  7219. {
  7220. snd_soc_unregister_component(&pdev->dev);
  7221. return 0;
  7222. }
  7223. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  7224. {.compatible = "qcom,msm-dai-q6-spdif"},
  7225. {}
  7226. };
  7227. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  7228. static struct platform_driver msm_dai_q6_spdif_driver = {
  7229. .probe = msm_dai_q6_spdif_dev_probe,
  7230. .remove = msm_dai_q6_spdif_dev_remove,
  7231. .driver = {
  7232. .name = "msm-dai-q6-spdif",
  7233. .owner = THIS_MODULE,
  7234. .of_match_table = msm_dai_q6_spdif_dt_match,
  7235. .suppress_bind_attrs = true,
  7236. },
  7237. };
  7238. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  7239. struct afe_clk_set *clk_set, u32 mode)
  7240. {
  7241. switch (group_id) {
  7242. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  7243. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  7244. if (mode)
  7245. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  7246. else
  7247. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  7248. break;
  7249. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  7250. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  7251. if (mode)
  7252. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  7253. else
  7254. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  7255. break;
  7256. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  7257. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  7258. if (mode)
  7259. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  7260. else
  7261. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  7262. break;
  7263. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  7264. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  7265. if (mode)
  7266. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  7267. else
  7268. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  7269. break;
  7270. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  7271. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  7272. if (mode)
  7273. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  7274. else
  7275. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  7276. break;
  7277. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  7278. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  7279. if (mode)
  7280. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  7281. else
  7282. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  7283. break;
  7284. default:
  7285. return -EINVAL;
  7286. }
  7287. return 0;
  7288. }
  7289. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  7290. {
  7291. int rc = 0;
  7292. const uint32_t *port_id_array = NULL;
  7293. uint32_t array_length = 0;
  7294. int i = 0;
  7295. int group_idx = 0;
  7296. u32 clk_mode = 0;
  7297. /* extract tdm group info into static */
  7298. rc = of_property_read_u32(pdev->dev.of_node,
  7299. "qcom,msm-cpudai-tdm-group-id",
  7300. (u32 *)&tdm_group_cfg.group_id);
  7301. if (rc) {
  7302. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  7303. __func__, "qcom,msm-cpudai-tdm-group-id");
  7304. goto rtn;
  7305. }
  7306. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  7307. __func__, tdm_group_cfg.group_id);
  7308. rc = of_property_read_u32(pdev->dev.of_node,
  7309. "qcom,msm-cpudai-tdm-group-num-ports",
  7310. &num_tdm_group_ports);
  7311. if (rc) {
  7312. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  7313. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  7314. goto rtn;
  7315. }
  7316. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  7317. __func__, num_tdm_group_ports);
  7318. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  7319. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  7320. __func__, num_tdm_group_ports,
  7321. AFE_GROUP_DEVICE_NUM_PORTS);
  7322. rc = -EINVAL;
  7323. goto rtn;
  7324. }
  7325. port_id_array = of_get_property(pdev->dev.of_node,
  7326. "qcom,msm-cpudai-tdm-group-port-id",
  7327. &array_length);
  7328. if (port_id_array == NULL) {
  7329. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  7330. __func__);
  7331. rc = -EINVAL;
  7332. goto rtn;
  7333. }
  7334. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  7335. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  7336. __func__, array_length,
  7337. sizeof(uint32_t) * num_tdm_group_ports);
  7338. rc = -EINVAL;
  7339. goto rtn;
  7340. }
  7341. for (i = 0; i < num_tdm_group_ports; i++)
  7342. tdm_group_cfg.port_id[i] =
  7343. (u16)be32_to_cpu(port_id_array[i]);
  7344. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  7345. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  7346. tdm_group_cfg.port_id[i] =
  7347. AFE_PORT_INVALID;
  7348. /* extract tdm clk info into static */
  7349. rc = of_property_read_u32(pdev->dev.of_node,
  7350. "qcom,msm-cpudai-tdm-clk-rate",
  7351. &tdm_clk_set.clk_freq_in_hz);
  7352. if (rc) {
  7353. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  7354. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  7355. goto rtn;
  7356. }
  7357. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  7358. __func__, tdm_clk_set.clk_freq_in_hz);
  7359. /* initialize static tdm clk attribute to default value */
  7360. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  7361. /* extract tdm clk attribute into static */
  7362. if (of_find_property(pdev->dev.of_node,
  7363. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  7364. rc = of_property_read_u16(pdev->dev.of_node,
  7365. "qcom,msm-cpudai-tdm-clk-attribute",
  7366. &tdm_clk_set.clk_attri);
  7367. if (rc) {
  7368. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  7369. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  7370. goto rtn;
  7371. }
  7372. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  7373. __func__, tdm_clk_set.clk_attri);
  7374. } else
  7375. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  7376. /* extract tdm lane cfg to static */
  7377. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  7378. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  7379. if (of_find_property(pdev->dev.of_node,
  7380. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  7381. rc = of_property_read_u16(pdev->dev.of_node,
  7382. "qcom,msm-cpudai-tdm-lane-mask",
  7383. &tdm_lane_cfg.lane_mask);
  7384. if (rc) {
  7385. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  7386. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  7387. goto rtn;
  7388. }
  7389. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  7390. __func__, tdm_lane_cfg.lane_mask);
  7391. } else
  7392. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  7393. /* extract tdm clk src master/slave info into static */
  7394. rc = of_property_read_u32(pdev->dev.of_node,
  7395. "qcom,msm-cpudai-tdm-clk-internal",
  7396. &clk_mode);
  7397. if (rc) {
  7398. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  7399. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  7400. goto rtn;
  7401. }
  7402. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  7403. __func__, clk_mode);
  7404. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  7405. &tdm_clk_set, clk_mode);
  7406. if (rc) {
  7407. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  7408. __func__, tdm_group_cfg.group_id);
  7409. goto rtn;
  7410. }
  7411. /* other initializations within device group */
  7412. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  7413. if (group_idx < 0) {
  7414. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  7415. __func__, tdm_group_cfg.group_id);
  7416. rc = -EINVAL;
  7417. goto rtn;
  7418. }
  7419. atomic_set(&tdm_group_ref[group_idx], 0);
  7420. /* probe child node info */
  7421. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7422. if (rc) {
  7423. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7424. __func__, rc);
  7425. goto rtn;
  7426. } else
  7427. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7428. rtn:
  7429. return rc;
  7430. }
  7431. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  7432. {
  7433. return 0;
  7434. }
  7435. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  7436. { .compatible = "qcom,msm-dai-tdm", },
  7437. {}
  7438. };
  7439. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  7440. static struct platform_driver msm_dai_tdm_q6 = {
  7441. .probe = msm_dai_tdm_q6_probe,
  7442. .remove = msm_dai_tdm_q6_remove,
  7443. .driver = {
  7444. .name = "msm-dai-tdm",
  7445. .owner = THIS_MODULE,
  7446. .of_match_table = msm_dai_tdm_dt_match,
  7447. .suppress_bind_attrs = true,
  7448. },
  7449. };
  7450. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  7451. struct snd_ctl_elem_value *ucontrol)
  7452. {
  7453. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7454. int value = ucontrol->value.integer.value[0];
  7455. switch (value) {
  7456. case 0:
  7457. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  7458. break;
  7459. case 1:
  7460. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  7461. break;
  7462. case 2:
  7463. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  7464. break;
  7465. default:
  7466. pr_err("%s: data_format invalid\n", __func__);
  7467. break;
  7468. }
  7469. pr_debug("%s: data_format = %d\n",
  7470. __func__, dai_data->port_cfg.tdm.data_format);
  7471. return 0;
  7472. }
  7473. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  7474. struct snd_ctl_elem_value *ucontrol)
  7475. {
  7476. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7477. ucontrol->value.integer.value[0] =
  7478. dai_data->port_cfg.tdm.data_format;
  7479. pr_debug("%s: data_format = %d\n",
  7480. __func__, dai_data->port_cfg.tdm.data_format);
  7481. return 0;
  7482. }
  7483. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  7484. struct snd_ctl_elem_value *ucontrol)
  7485. {
  7486. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7487. int value = ucontrol->value.integer.value[0];
  7488. dai_data->port_cfg.custom_tdm_header.header_type = value;
  7489. pr_debug("%s: header_type = %d\n",
  7490. __func__,
  7491. dai_data->port_cfg.custom_tdm_header.header_type);
  7492. return 0;
  7493. }
  7494. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  7495. struct snd_ctl_elem_value *ucontrol)
  7496. {
  7497. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7498. ucontrol->value.integer.value[0] =
  7499. dai_data->port_cfg.custom_tdm_header.header_type;
  7500. pr_debug("%s: header_type = %d\n",
  7501. __func__,
  7502. dai_data->port_cfg.custom_tdm_header.header_type);
  7503. return 0;
  7504. }
  7505. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  7506. struct snd_ctl_elem_value *ucontrol)
  7507. {
  7508. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7509. int i = 0;
  7510. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7511. dai_data->port_cfg.custom_tdm_header.header[i] =
  7512. (u16)ucontrol->value.integer.value[i];
  7513. pr_debug("%s: header #%d = 0x%x\n",
  7514. __func__, i,
  7515. dai_data->port_cfg.custom_tdm_header.header[i]);
  7516. }
  7517. return 0;
  7518. }
  7519. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  7520. struct snd_ctl_elem_value *ucontrol)
  7521. {
  7522. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7523. int i = 0;
  7524. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7525. ucontrol->value.integer.value[i] =
  7526. dai_data->port_cfg.custom_tdm_header.header[i];
  7527. pr_debug("%s: header #%d = 0x%x\n",
  7528. __func__, i,
  7529. dai_data->port_cfg.custom_tdm_header.header[i]);
  7530. }
  7531. return 0;
  7532. }
  7533. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  7534. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  7535. msm_dai_q6_tdm_data_format_get,
  7536. msm_dai_q6_tdm_data_format_put),
  7537. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  7538. msm_dai_q6_tdm_data_format_get,
  7539. msm_dai_q6_tdm_data_format_put),
  7540. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  7541. msm_dai_q6_tdm_data_format_get,
  7542. msm_dai_q6_tdm_data_format_put),
  7543. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  7544. msm_dai_q6_tdm_data_format_get,
  7545. msm_dai_q6_tdm_data_format_put),
  7546. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  7547. msm_dai_q6_tdm_data_format_get,
  7548. msm_dai_q6_tdm_data_format_put),
  7549. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  7550. msm_dai_q6_tdm_data_format_get,
  7551. msm_dai_q6_tdm_data_format_put),
  7552. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  7553. msm_dai_q6_tdm_data_format_get,
  7554. msm_dai_q6_tdm_data_format_put),
  7555. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  7556. msm_dai_q6_tdm_data_format_get,
  7557. msm_dai_q6_tdm_data_format_put),
  7558. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  7559. msm_dai_q6_tdm_data_format_get,
  7560. msm_dai_q6_tdm_data_format_put),
  7561. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  7562. msm_dai_q6_tdm_data_format_get,
  7563. msm_dai_q6_tdm_data_format_put),
  7564. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  7565. msm_dai_q6_tdm_data_format_get,
  7566. msm_dai_q6_tdm_data_format_put),
  7567. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  7568. msm_dai_q6_tdm_data_format_get,
  7569. msm_dai_q6_tdm_data_format_put),
  7570. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  7571. msm_dai_q6_tdm_data_format_get,
  7572. msm_dai_q6_tdm_data_format_put),
  7573. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  7574. msm_dai_q6_tdm_data_format_get,
  7575. msm_dai_q6_tdm_data_format_put),
  7576. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  7577. msm_dai_q6_tdm_data_format_get,
  7578. msm_dai_q6_tdm_data_format_put),
  7579. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  7580. msm_dai_q6_tdm_data_format_get,
  7581. msm_dai_q6_tdm_data_format_put),
  7582. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  7583. msm_dai_q6_tdm_data_format_get,
  7584. msm_dai_q6_tdm_data_format_put),
  7585. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  7586. msm_dai_q6_tdm_data_format_get,
  7587. msm_dai_q6_tdm_data_format_put),
  7588. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  7589. msm_dai_q6_tdm_data_format_get,
  7590. msm_dai_q6_tdm_data_format_put),
  7591. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  7592. msm_dai_q6_tdm_data_format_get,
  7593. msm_dai_q6_tdm_data_format_put),
  7594. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  7595. msm_dai_q6_tdm_data_format_get,
  7596. msm_dai_q6_tdm_data_format_put),
  7597. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  7598. msm_dai_q6_tdm_data_format_get,
  7599. msm_dai_q6_tdm_data_format_put),
  7600. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  7601. msm_dai_q6_tdm_data_format_get,
  7602. msm_dai_q6_tdm_data_format_put),
  7603. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  7604. msm_dai_q6_tdm_data_format_get,
  7605. msm_dai_q6_tdm_data_format_put),
  7606. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  7607. msm_dai_q6_tdm_data_format_get,
  7608. msm_dai_q6_tdm_data_format_put),
  7609. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  7610. msm_dai_q6_tdm_data_format_get,
  7611. msm_dai_q6_tdm_data_format_put),
  7612. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  7613. msm_dai_q6_tdm_data_format_get,
  7614. msm_dai_q6_tdm_data_format_put),
  7615. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  7616. msm_dai_q6_tdm_data_format_get,
  7617. msm_dai_q6_tdm_data_format_put),
  7618. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  7619. msm_dai_q6_tdm_data_format_get,
  7620. msm_dai_q6_tdm_data_format_put),
  7621. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  7622. msm_dai_q6_tdm_data_format_get,
  7623. msm_dai_q6_tdm_data_format_put),
  7624. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  7625. msm_dai_q6_tdm_data_format_get,
  7626. msm_dai_q6_tdm_data_format_put),
  7627. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  7628. msm_dai_q6_tdm_data_format_get,
  7629. msm_dai_q6_tdm_data_format_put),
  7630. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7631. msm_dai_q6_tdm_data_format_get,
  7632. msm_dai_q6_tdm_data_format_put),
  7633. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7634. msm_dai_q6_tdm_data_format_get,
  7635. msm_dai_q6_tdm_data_format_put),
  7636. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7637. msm_dai_q6_tdm_data_format_get,
  7638. msm_dai_q6_tdm_data_format_put),
  7639. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7640. msm_dai_q6_tdm_data_format_get,
  7641. msm_dai_q6_tdm_data_format_put),
  7642. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7643. msm_dai_q6_tdm_data_format_get,
  7644. msm_dai_q6_tdm_data_format_put),
  7645. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7646. msm_dai_q6_tdm_data_format_get,
  7647. msm_dai_q6_tdm_data_format_put),
  7648. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7649. msm_dai_q6_tdm_data_format_get,
  7650. msm_dai_q6_tdm_data_format_put),
  7651. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7652. msm_dai_q6_tdm_data_format_get,
  7653. msm_dai_q6_tdm_data_format_put),
  7654. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7655. msm_dai_q6_tdm_data_format_get,
  7656. msm_dai_q6_tdm_data_format_put),
  7657. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7658. msm_dai_q6_tdm_data_format_get,
  7659. msm_dai_q6_tdm_data_format_put),
  7660. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7661. msm_dai_q6_tdm_data_format_get,
  7662. msm_dai_q6_tdm_data_format_put),
  7663. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7664. msm_dai_q6_tdm_data_format_get,
  7665. msm_dai_q6_tdm_data_format_put),
  7666. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7667. msm_dai_q6_tdm_data_format_get,
  7668. msm_dai_q6_tdm_data_format_put),
  7669. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7670. msm_dai_q6_tdm_data_format_get,
  7671. msm_dai_q6_tdm_data_format_put),
  7672. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7673. msm_dai_q6_tdm_data_format_get,
  7674. msm_dai_q6_tdm_data_format_put),
  7675. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7676. msm_dai_q6_tdm_data_format_get,
  7677. msm_dai_q6_tdm_data_format_put),
  7678. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7679. msm_dai_q6_tdm_data_format_get,
  7680. msm_dai_q6_tdm_data_format_put),
  7681. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7682. msm_dai_q6_tdm_data_format_get,
  7683. msm_dai_q6_tdm_data_format_put),
  7684. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7685. msm_dai_q6_tdm_data_format_get,
  7686. msm_dai_q6_tdm_data_format_put),
  7687. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7688. msm_dai_q6_tdm_data_format_get,
  7689. msm_dai_q6_tdm_data_format_put),
  7690. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7691. msm_dai_q6_tdm_data_format_get,
  7692. msm_dai_q6_tdm_data_format_put),
  7693. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7694. msm_dai_q6_tdm_data_format_get,
  7695. msm_dai_q6_tdm_data_format_put),
  7696. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7697. msm_dai_q6_tdm_data_format_get,
  7698. msm_dai_q6_tdm_data_format_put),
  7699. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7700. msm_dai_q6_tdm_data_format_get,
  7701. msm_dai_q6_tdm_data_format_put),
  7702. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7703. msm_dai_q6_tdm_data_format_get,
  7704. msm_dai_q6_tdm_data_format_put),
  7705. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7706. msm_dai_q6_tdm_data_format_get,
  7707. msm_dai_q6_tdm_data_format_put),
  7708. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7709. msm_dai_q6_tdm_data_format_get,
  7710. msm_dai_q6_tdm_data_format_put),
  7711. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7712. msm_dai_q6_tdm_data_format_get,
  7713. msm_dai_q6_tdm_data_format_put),
  7714. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7715. msm_dai_q6_tdm_data_format_get,
  7716. msm_dai_q6_tdm_data_format_put),
  7717. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7718. msm_dai_q6_tdm_data_format_get,
  7719. msm_dai_q6_tdm_data_format_put),
  7720. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7721. msm_dai_q6_tdm_data_format_get,
  7722. msm_dai_q6_tdm_data_format_put),
  7723. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7724. msm_dai_q6_tdm_data_format_get,
  7725. msm_dai_q6_tdm_data_format_put),
  7726. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7727. msm_dai_q6_tdm_data_format_get,
  7728. msm_dai_q6_tdm_data_format_put),
  7729. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7730. msm_dai_q6_tdm_data_format_get,
  7731. msm_dai_q6_tdm_data_format_put),
  7732. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7733. msm_dai_q6_tdm_data_format_get,
  7734. msm_dai_q6_tdm_data_format_put),
  7735. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7736. msm_dai_q6_tdm_data_format_get,
  7737. msm_dai_q6_tdm_data_format_put),
  7738. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7739. msm_dai_q6_tdm_data_format_get,
  7740. msm_dai_q6_tdm_data_format_put),
  7741. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7742. msm_dai_q6_tdm_data_format_get,
  7743. msm_dai_q6_tdm_data_format_put),
  7744. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7745. msm_dai_q6_tdm_data_format_get,
  7746. msm_dai_q6_tdm_data_format_put),
  7747. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7748. msm_dai_q6_tdm_data_format_get,
  7749. msm_dai_q6_tdm_data_format_put),
  7750. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7751. msm_dai_q6_tdm_data_format_get,
  7752. msm_dai_q6_tdm_data_format_put),
  7753. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7754. msm_dai_q6_tdm_data_format_get,
  7755. msm_dai_q6_tdm_data_format_put),
  7756. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7757. msm_dai_q6_tdm_data_format_get,
  7758. msm_dai_q6_tdm_data_format_put),
  7759. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7760. msm_dai_q6_tdm_data_format_get,
  7761. msm_dai_q6_tdm_data_format_put),
  7762. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7763. msm_dai_q6_tdm_data_format_get,
  7764. msm_dai_q6_tdm_data_format_put),
  7765. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7766. msm_dai_q6_tdm_data_format_get,
  7767. msm_dai_q6_tdm_data_format_put),
  7768. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7769. msm_dai_q6_tdm_data_format_get,
  7770. msm_dai_q6_tdm_data_format_put),
  7771. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7772. msm_dai_q6_tdm_data_format_get,
  7773. msm_dai_q6_tdm_data_format_put),
  7774. SOC_ENUM_EXT("SEN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7775. msm_dai_q6_tdm_data_format_get,
  7776. msm_dai_q6_tdm_data_format_put),
  7777. SOC_ENUM_EXT("SEN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7778. msm_dai_q6_tdm_data_format_get,
  7779. msm_dai_q6_tdm_data_format_put),
  7780. SOC_ENUM_EXT("SEN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7781. msm_dai_q6_tdm_data_format_get,
  7782. msm_dai_q6_tdm_data_format_put),
  7783. SOC_ENUM_EXT("SEN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7784. msm_dai_q6_tdm_data_format_get,
  7785. msm_dai_q6_tdm_data_format_put),
  7786. SOC_ENUM_EXT("SEN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7787. msm_dai_q6_tdm_data_format_get,
  7788. msm_dai_q6_tdm_data_format_put),
  7789. SOC_ENUM_EXT("SEN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7790. msm_dai_q6_tdm_data_format_get,
  7791. msm_dai_q6_tdm_data_format_put),
  7792. SOC_ENUM_EXT("SEN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7793. msm_dai_q6_tdm_data_format_get,
  7794. msm_dai_q6_tdm_data_format_put),
  7795. SOC_ENUM_EXT("SEN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7796. msm_dai_q6_tdm_data_format_get,
  7797. msm_dai_q6_tdm_data_format_put),
  7798. SOC_ENUM_EXT("SEN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7799. msm_dai_q6_tdm_data_format_get,
  7800. msm_dai_q6_tdm_data_format_put),
  7801. SOC_ENUM_EXT("SEN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7802. msm_dai_q6_tdm_data_format_get,
  7803. msm_dai_q6_tdm_data_format_put),
  7804. SOC_ENUM_EXT("SEN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7805. msm_dai_q6_tdm_data_format_get,
  7806. msm_dai_q6_tdm_data_format_put),
  7807. SOC_ENUM_EXT("SEN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7808. msm_dai_q6_tdm_data_format_get,
  7809. msm_dai_q6_tdm_data_format_put),
  7810. SOC_ENUM_EXT("SEN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7811. msm_dai_q6_tdm_data_format_get,
  7812. msm_dai_q6_tdm_data_format_put),
  7813. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7814. msm_dai_q6_tdm_data_format_get,
  7815. msm_dai_q6_tdm_data_format_put),
  7816. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7817. msm_dai_q6_tdm_data_format_get,
  7818. msm_dai_q6_tdm_data_format_put),
  7819. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7820. msm_dai_q6_tdm_data_format_get,
  7821. msm_dai_q6_tdm_data_format_put),
  7822. };
  7823. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  7824. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  7825. msm_dai_q6_tdm_header_type_get,
  7826. msm_dai_q6_tdm_header_type_put),
  7827. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  7828. msm_dai_q6_tdm_header_type_get,
  7829. msm_dai_q6_tdm_header_type_put),
  7830. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  7831. msm_dai_q6_tdm_header_type_get,
  7832. msm_dai_q6_tdm_header_type_put),
  7833. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  7834. msm_dai_q6_tdm_header_type_get,
  7835. msm_dai_q6_tdm_header_type_put),
  7836. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  7837. msm_dai_q6_tdm_header_type_get,
  7838. msm_dai_q6_tdm_header_type_put),
  7839. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  7840. msm_dai_q6_tdm_header_type_get,
  7841. msm_dai_q6_tdm_header_type_put),
  7842. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  7843. msm_dai_q6_tdm_header_type_get,
  7844. msm_dai_q6_tdm_header_type_put),
  7845. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  7846. msm_dai_q6_tdm_header_type_get,
  7847. msm_dai_q6_tdm_header_type_put),
  7848. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  7849. msm_dai_q6_tdm_header_type_get,
  7850. msm_dai_q6_tdm_header_type_put),
  7851. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  7852. msm_dai_q6_tdm_header_type_get,
  7853. msm_dai_q6_tdm_header_type_put),
  7854. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  7855. msm_dai_q6_tdm_header_type_get,
  7856. msm_dai_q6_tdm_header_type_put),
  7857. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  7858. msm_dai_q6_tdm_header_type_get,
  7859. msm_dai_q6_tdm_header_type_put),
  7860. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  7861. msm_dai_q6_tdm_header_type_get,
  7862. msm_dai_q6_tdm_header_type_put),
  7863. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  7864. msm_dai_q6_tdm_header_type_get,
  7865. msm_dai_q6_tdm_header_type_put),
  7866. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  7867. msm_dai_q6_tdm_header_type_get,
  7868. msm_dai_q6_tdm_header_type_put),
  7869. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  7870. msm_dai_q6_tdm_header_type_get,
  7871. msm_dai_q6_tdm_header_type_put),
  7872. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  7873. msm_dai_q6_tdm_header_type_get,
  7874. msm_dai_q6_tdm_header_type_put),
  7875. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  7876. msm_dai_q6_tdm_header_type_get,
  7877. msm_dai_q6_tdm_header_type_put),
  7878. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  7879. msm_dai_q6_tdm_header_type_get,
  7880. msm_dai_q6_tdm_header_type_put),
  7881. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  7882. msm_dai_q6_tdm_header_type_get,
  7883. msm_dai_q6_tdm_header_type_put),
  7884. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  7885. msm_dai_q6_tdm_header_type_get,
  7886. msm_dai_q6_tdm_header_type_put),
  7887. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  7888. msm_dai_q6_tdm_header_type_get,
  7889. msm_dai_q6_tdm_header_type_put),
  7890. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  7891. msm_dai_q6_tdm_header_type_get,
  7892. msm_dai_q6_tdm_header_type_put),
  7893. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  7894. msm_dai_q6_tdm_header_type_get,
  7895. msm_dai_q6_tdm_header_type_put),
  7896. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  7897. msm_dai_q6_tdm_header_type_get,
  7898. msm_dai_q6_tdm_header_type_put),
  7899. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  7900. msm_dai_q6_tdm_header_type_get,
  7901. msm_dai_q6_tdm_header_type_put),
  7902. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  7903. msm_dai_q6_tdm_header_type_get,
  7904. msm_dai_q6_tdm_header_type_put),
  7905. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  7906. msm_dai_q6_tdm_header_type_get,
  7907. msm_dai_q6_tdm_header_type_put),
  7908. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  7909. msm_dai_q6_tdm_header_type_get,
  7910. msm_dai_q6_tdm_header_type_put),
  7911. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  7912. msm_dai_q6_tdm_header_type_get,
  7913. msm_dai_q6_tdm_header_type_put),
  7914. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  7915. msm_dai_q6_tdm_header_type_get,
  7916. msm_dai_q6_tdm_header_type_put),
  7917. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  7918. msm_dai_q6_tdm_header_type_get,
  7919. msm_dai_q6_tdm_header_type_put),
  7920. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7921. msm_dai_q6_tdm_header_type_get,
  7922. msm_dai_q6_tdm_header_type_put),
  7923. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7924. msm_dai_q6_tdm_header_type_get,
  7925. msm_dai_q6_tdm_header_type_put),
  7926. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7927. msm_dai_q6_tdm_header_type_get,
  7928. msm_dai_q6_tdm_header_type_put),
  7929. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7930. msm_dai_q6_tdm_header_type_get,
  7931. msm_dai_q6_tdm_header_type_put),
  7932. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7933. msm_dai_q6_tdm_header_type_get,
  7934. msm_dai_q6_tdm_header_type_put),
  7935. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7936. msm_dai_q6_tdm_header_type_get,
  7937. msm_dai_q6_tdm_header_type_put),
  7938. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7939. msm_dai_q6_tdm_header_type_get,
  7940. msm_dai_q6_tdm_header_type_put),
  7941. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7942. msm_dai_q6_tdm_header_type_get,
  7943. msm_dai_q6_tdm_header_type_put),
  7944. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7945. msm_dai_q6_tdm_header_type_get,
  7946. msm_dai_q6_tdm_header_type_put),
  7947. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7948. msm_dai_q6_tdm_header_type_get,
  7949. msm_dai_q6_tdm_header_type_put),
  7950. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7951. msm_dai_q6_tdm_header_type_get,
  7952. msm_dai_q6_tdm_header_type_put),
  7953. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  7954. msm_dai_q6_tdm_header_type_get,
  7955. msm_dai_q6_tdm_header_type_put),
  7956. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  7957. msm_dai_q6_tdm_header_type_get,
  7958. msm_dai_q6_tdm_header_type_put),
  7959. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  7960. msm_dai_q6_tdm_header_type_get,
  7961. msm_dai_q6_tdm_header_type_put),
  7962. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  7963. msm_dai_q6_tdm_header_type_get,
  7964. msm_dai_q6_tdm_header_type_put),
  7965. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  7966. msm_dai_q6_tdm_header_type_get,
  7967. msm_dai_q6_tdm_header_type_put),
  7968. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7969. msm_dai_q6_tdm_header_type_get,
  7970. msm_dai_q6_tdm_header_type_put),
  7971. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7972. msm_dai_q6_tdm_header_type_get,
  7973. msm_dai_q6_tdm_header_type_put),
  7974. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7975. msm_dai_q6_tdm_header_type_get,
  7976. msm_dai_q6_tdm_header_type_put),
  7977. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7978. msm_dai_q6_tdm_header_type_get,
  7979. msm_dai_q6_tdm_header_type_put),
  7980. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7981. msm_dai_q6_tdm_header_type_get,
  7982. msm_dai_q6_tdm_header_type_put),
  7983. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7984. msm_dai_q6_tdm_header_type_get,
  7985. msm_dai_q6_tdm_header_type_put),
  7986. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7987. msm_dai_q6_tdm_header_type_get,
  7988. msm_dai_q6_tdm_header_type_put),
  7989. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7990. msm_dai_q6_tdm_header_type_get,
  7991. msm_dai_q6_tdm_header_type_put),
  7992. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7993. msm_dai_q6_tdm_header_type_get,
  7994. msm_dai_q6_tdm_header_type_put),
  7995. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7996. msm_dai_q6_tdm_header_type_get,
  7997. msm_dai_q6_tdm_header_type_put),
  7998. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7999. msm_dai_q6_tdm_header_type_get,
  8000. msm_dai_q6_tdm_header_type_put),
  8001. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  8002. msm_dai_q6_tdm_header_type_get,
  8003. msm_dai_q6_tdm_header_type_put),
  8004. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  8005. msm_dai_q6_tdm_header_type_get,
  8006. msm_dai_q6_tdm_header_type_put),
  8007. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  8008. msm_dai_q6_tdm_header_type_get,
  8009. msm_dai_q6_tdm_header_type_put),
  8010. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  8011. msm_dai_q6_tdm_header_type_get,
  8012. msm_dai_q6_tdm_header_type_put),
  8013. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  8014. msm_dai_q6_tdm_header_type_get,
  8015. msm_dai_q6_tdm_header_type_put),
  8016. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  8017. msm_dai_q6_tdm_header_type_get,
  8018. msm_dai_q6_tdm_header_type_put),
  8019. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  8020. msm_dai_q6_tdm_header_type_get,
  8021. msm_dai_q6_tdm_header_type_put),
  8022. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  8023. msm_dai_q6_tdm_header_type_get,
  8024. msm_dai_q6_tdm_header_type_put),
  8025. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  8026. msm_dai_q6_tdm_header_type_get,
  8027. msm_dai_q6_tdm_header_type_put),
  8028. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  8029. msm_dai_q6_tdm_header_type_get,
  8030. msm_dai_q6_tdm_header_type_put),
  8031. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  8032. msm_dai_q6_tdm_header_type_get,
  8033. msm_dai_q6_tdm_header_type_put),
  8034. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  8035. msm_dai_q6_tdm_header_type_get,
  8036. msm_dai_q6_tdm_header_type_put),
  8037. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  8038. msm_dai_q6_tdm_header_type_get,
  8039. msm_dai_q6_tdm_header_type_put),
  8040. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  8041. msm_dai_q6_tdm_header_type_get,
  8042. msm_dai_q6_tdm_header_type_put),
  8043. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  8044. msm_dai_q6_tdm_header_type_get,
  8045. msm_dai_q6_tdm_header_type_put),
  8046. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  8047. msm_dai_q6_tdm_header_type_get,
  8048. msm_dai_q6_tdm_header_type_put),
  8049. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  8050. msm_dai_q6_tdm_header_type_get,
  8051. msm_dai_q6_tdm_header_type_put),
  8052. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  8053. msm_dai_q6_tdm_header_type_get,
  8054. msm_dai_q6_tdm_header_type_put),
  8055. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  8056. msm_dai_q6_tdm_header_type_get,
  8057. msm_dai_q6_tdm_header_type_put),
  8058. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  8059. msm_dai_q6_tdm_header_type_get,
  8060. msm_dai_q6_tdm_header_type_put),
  8061. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  8062. msm_dai_q6_tdm_header_type_get,
  8063. msm_dai_q6_tdm_header_type_put),
  8064. SOC_ENUM_EXT("SEN_TDM_RX_0 Header Type", tdm_config_enum[1],
  8065. msm_dai_q6_tdm_header_type_get,
  8066. msm_dai_q6_tdm_header_type_put),
  8067. SOC_ENUM_EXT("SEN_TDM_RX_1 Header Type", tdm_config_enum[1],
  8068. msm_dai_q6_tdm_header_type_get,
  8069. msm_dai_q6_tdm_header_type_put),
  8070. SOC_ENUM_EXT("SEN_TDM_RX_2 Header Type", tdm_config_enum[1],
  8071. msm_dai_q6_tdm_header_type_get,
  8072. msm_dai_q6_tdm_header_type_put),
  8073. SOC_ENUM_EXT("SEN_TDM_RX_3 Header Type", tdm_config_enum[1],
  8074. msm_dai_q6_tdm_header_type_get,
  8075. msm_dai_q6_tdm_header_type_put),
  8076. SOC_ENUM_EXT("SEN_TDM_RX_4 Header Type", tdm_config_enum[1],
  8077. msm_dai_q6_tdm_header_type_get,
  8078. msm_dai_q6_tdm_header_type_put),
  8079. SOC_ENUM_EXT("SEN_TDM_RX_5 Header Type", tdm_config_enum[1],
  8080. msm_dai_q6_tdm_header_type_get,
  8081. msm_dai_q6_tdm_header_type_put),
  8082. SOC_ENUM_EXT("SEN_TDM_RX_6 Header Type", tdm_config_enum[1],
  8083. msm_dai_q6_tdm_header_type_get,
  8084. msm_dai_q6_tdm_header_type_put),
  8085. SOC_ENUM_EXT("SEN_TDM_RX_7 Header Type", tdm_config_enum[1],
  8086. msm_dai_q6_tdm_header_type_get,
  8087. msm_dai_q6_tdm_header_type_put),
  8088. SOC_ENUM_EXT("SEN_TDM_TX_0 Header Type", tdm_config_enum[1],
  8089. msm_dai_q6_tdm_header_type_get,
  8090. msm_dai_q6_tdm_header_type_put),
  8091. SOC_ENUM_EXT("SEN_TDM_TX_1 Header Type", tdm_config_enum[1],
  8092. msm_dai_q6_tdm_header_type_get,
  8093. msm_dai_q6_tdm_header_type_put),
  8094. SOC_ENUM_EXT("SEN_TDM_TX_2 Header Type", tdm_config_enum[1],
  8095. msm_dai_q6_tdm_header_type_get,
  8096. msm_dai_q6_tdm_header_type_put),
  8097. SOC_ENUM_EXT("SEN_TDM_TX_3 Header Type", tdm_config_enum[1],
  8098. msm_dai_q6_tdm_header_type_get,
  8099. msm_dai_q6_tdm_header_type_put),
  8100. SOC_ENUM_EXT("SEN_TDM_TX_4 Header Type", tdm_config_enum[1],
  8101. msm_dai_q6_tdm_header_type_get,
  8102. msm_dai_q6_tdm_header_type_put),
  8103. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  8104. msm_dai_q6_tdm_header_type_get,
  8105. msm_dai_q6_tdm_header_type_put),
  8106. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  8107. msm_dai_q6_tdm_header_type_get,
  8108. msm_dai_q6_tdm_header_type_put),
  8109. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  8110. msm_dai_q6_tdm_header_type_get,
  8111. msm_dai_q6_tdm_header_type_put),
  8112. };
  8113. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  8114. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  8115. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8116. msm_dai_q6_tdm_header_get,
  8117. msm_dai_q6_tdm_header_put),
  8118. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  8119. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8120. msm_dai_q6_tdm_header_get,
  8121. msm_dai_q6_tdm_header_put),
  8122. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  8123. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8124. msm_dai_q6_tdm_header_get,
  8125. msm_dai_q6_tdm_header_put),
  8126. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  8127. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8128. msm_dai_q6_tdm_header_get,
  8129. msm_dai_q6_tdm_header_put),
  8130. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  8131. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8132. msm_dai_q6_tdm_header_get,
  8133. msm_dai_q6_tdm_header_put),
  8134. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  8135. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8136. msm_dai_q6_tdm_header_get,
  8137. msm_dai_q6_tdm_header_put),
  8138. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  8139. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8140. msm_dai_q6_tdm_header_get,
  8141. msm_dai_q6_tdm_header_put),
  8142. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  8143. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8144. msm_dai_q6_tdm_header_get,
  8145. msm_dai_q6_tdm_header_put),
  8146. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  8147. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8148. msm_dai_q6_tdm_header_get,
  8149. msm_dai_q6_tdm_header_put),
  8150. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  8151. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8152. msm_dai_q6_tdm_header_get,
  8153. msm_dai_q6_tdm_header_put),
  8154. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  8155. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8156. msm_dai_q6_tdm_header_get,
  8157. msm_dai_q6_tdm_header_put),
  8158. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  8159. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8160. msm_dai_q6_tdm_header_get,
  8161. msm_dai_q6_tdm_header_put),
  8162. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  8163. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8164. msm_dai_q6_tdm_header_get,
  8165. msm_dai_q6_tdm_header_put),
  8166. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  8167. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8168. msm_dai_q6_tdm_header_get,
  8169. msm_dai_q6_tdm_header_put),
  8170. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  8171. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8172. msm_dai_q6_tdm_header_get,
  8173. msm_dai_q6_tdm_header_put),
  8174. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  8175. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8176. msm_dai_q6_tdm_header_get,
  8177. msm_dai_q6_tdm_header_put),
  8178. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  8179. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8180. msm_dai_q6_tdm_header_get,
  8181. msm_dai_q6_tdm_header_put),
  8182. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  8183. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8184. msm_dai_q6_tdm_header_get,
  8185. msm_dai_q6_tdm_header_put),
  8186. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  8187. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8188. msm_dai_q6_tdm_header_get,
  8189. msm_dai_q6_tdm_header_put),
  8190. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  8191. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8192. msm_dai_q6_tdm_header_get,
  8193. msm_dai_q6_tdm_header_put),
  8194. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  8195. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8196. msm_dai_q6_tdm_header_get,
  8197. msm_dai_q6_tdm_header_put),
  8198. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  8199. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8200. msm_dai_q6_tdm_header_get,
  8201. msm_dai_q6_tdm_header_put),
  8202. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  8203. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8204. msm_dai_q6_tdm_header_get,
  8205. msm_dai_q6_tdm_header_put),
  8206. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  8207. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8208. msm_dai_q6_tdm_header_get,
  8209. msm_dai_q6_tdm_header_put),
  8210. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  8211. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8212. msm_dai_q6_tdm_header_get,
  8213. msm_dai_q6_tdm_header_put),
  8214. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  8215. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8216. msm_dai_q6_tdm_header_get,
  8217. msm_dai_q6_tdm_header_put),
  8218. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  8219. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8220. msm_dai_q6_tdm_header_get,
  8221. msm_dai_q6_tdm_header_put),
  8222. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  8223. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8224. msm_dai_q6_tdm_header_get,
  8225. msm_dai_q6_tdm_header_put),
  8226. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  8227. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8228. msm_dai_q6_tdm_header_get,
  8229. msm_dai_q6_tdm_header_put),
  8230. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  8231. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8232. msm_dai_q6_tdm_header_get,
  8233. msm_dai_q6_tdm_header_put),
  8234. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  8235. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8236. msm_dai_q6_tdm_header_get,
  8237. msm_dai_q6_tdm_header_put),
  8238. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  8239. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8240. msm_dai_q6_tdm_header_get,
  8241. msm_dai_q6_tdm_header_put),
  8242. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  8243. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8244. msm_dai_q6_tdm_header_get,
  8245. msm_dai_q6_tdm_header_put),
  8246. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  8247. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8248. msm_dai_q6_tdm_header_get,
  8249. msm_dai_q6_tdm_header_put),
  8250. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  8251. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8252. msm_dai_q6_tdm_header_get,
  8253. msm_dai_q6_tdm_header_put),
  8254. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  8255. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8256. msm_dai_q6_tdm_header_get,
  8257. msm_dai_q6_tdm_header_put),
  8258. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  8259. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8260. msm_dai_q6_tdm_header_get,
  8261. msm_dai_q6_tdm_header_put),
  8262. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  8263. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8264. msm_dai_q6_tdm_header_get,
  8265. msm_dai_q6_tdm_header_put),
  8266. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  8267. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8268. msm_dai_q6_tdm_header_get,
  8269. msm_dai_q6_tdm_header_put),
  8270. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  8271. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8272. msm_dai_q6_tdm_header_get,
  8273. msm_dai_q6_tdm_header_put),
  8274. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  8275. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8276. msm_dai_q6_tdm_header_get,
  8277. msm_dai_q6_tdm_header_put),
  8278. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  8279. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8280. msm_dai_q6_tdm_header_get,
  8281. msm_dai_q6_tdm_header_put),
  8282. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  8283. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8284. msm_dai_q6_tdm_header_get,
  8285. msm_dai_q6_tdm_header_put),
  8286. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  8287. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8288. msm_dai_q6_tdm_header_get,
  8289. msm_dai_q6_tdm_header_put),
  8290. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  8291. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8292. msm_dai_q6_tdm_header_get,
  8293. msm_dai_q6_tdm_header_put),
  8294. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  8295. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8296. msm_dai_q6_tdm_header_get,
  8297. msm_dai_q6_tdm_header_put),
  8298. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  8299. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8300. msm_dai_q6_tdm_header_get,
  8301. msm_dai_q6_tdm_header_put),
  8302. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  8303. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8304. msm_dai_q6_tdm_header_get,
  8305. msm_dai_q6_tdm_header_put),
  8306. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  8307. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8308. msm_dai_q6_tdm_header_get,
  8309. msm_dai_q6_tdm_header_put),
  8310. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  8311. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8312. msm_dai_q6_tdm_header_get,
  8313. msm_dai_q6_tdm_header_put),
  8314. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  8315. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8316. msm_dai_q6_tdm_header_get,
  8317. msm_dai_q6_tdm_header_put),
  8318. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  8319. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8320. msm_dai_q6_tdm_header_get,
  8321. msm_dai_q6_tdm_header_put),
  8322. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  8323. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8324. msm_dai_q6_tdm_header_get,
  8325. msm_dai_q6_tdm_header_put),
  8326. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  8327. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8328. msm_dai_q6_tdm_header_get,
  8329. msm_dai_q6_tdm_header_put),
  8330. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  8331. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8332. msm_dai_q6_tdm_header_get,
  8333. msm_dai_q6_tdm_header_put),
  8334. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  8335. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8336. msm_dai_q6_tdm_header_get,
  8337. msm_dai_q6_tdm_header_put),
  8338. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  8339. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8340. msm_dai_q6_tdm_header_get,
  8341. msm_dai_q6_tdm_header_put),
  8342. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  8343. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8344. msm_dai_q6_tdm_header_get,
  8345. msm_dai_q6_tdm_header_put),
  8346. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  8347. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8348. msm_dai_q6_tdm_header_get,
  8349. msm_dai_q6_tdm_header_put),
  8350. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  8351. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8352. msm_dai_q6_tdm_header_get,
  8353. msm_dai_q6_tdm_header_put),
  8354. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  8355. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8356. msm_dai_q6_tdm_header_get,
  8357. msm_dai_q6_tdm_header_put),
  8358. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  8359. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8360. msm_dai_q6_tdm_header_get,
  8361. msm_dai_q6_tdm_header_put),
  8362. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  8363. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8364. msm_dai_q6_tdm_header_get,
  8365. msm_dai_q6_tdm_header_put),
  8366. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  8367. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8368. msm_dai_q6_tdm_header_get,
  8369. msm_dai_q6_tdm_header_put),
  8370. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  8371. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8372. msm_dai_q6_tdm_header_get,
  8373. msm_dai_q6_tdm_header_put),
  8374. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  8375. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8376. msm_dai_q6_tdm_header_get,
  8377. msm_dai_q6_tdm_header_put),
  8378. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  8379. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8380. msm_dai_q6_tdm_header_get,
  8381. msm_dai_q6_tdm_header_put),
  8382. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  8383. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8384. msm_dai_q6_tdm_header_get,
  8385. msm_dai_q6_tdm_header_put),
  8386. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  8387. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8388. msm_dai_q6_tdm_header_get,
  8389. msm_dai_q6_tdm_header_put),
  8390. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  8391. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8392. msm_dai_q6_tdm_header_get,
  8393. msm_dai_q6_tdm_header_put),
  8394. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  8395. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8396. msm_dai_q6_tdm_header_get,
  8397. msm_dai_q6_tdm_header_put),
  8398. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  8399. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8400. msm_dai_q6_tdm_header_get,
  8401. msm_dai_q6_tdm_header_put),
  8402. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  8403. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8404. msm_dai_q6_tdm_header_get,
  8405. msm_dai_q6_tdm_header_put),
  8406. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  8407. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8408. msm_dai_q6_tdm_header_get,
  8409. msm_dai_q6_tdm_header_put),
  8410. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  8411. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8412. msm_dai_q6_tdm_header_get,
  8413. msm_dai_q6_tdm_header_put),
  8414. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  8415. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8416. msm_dai_q6_tdm_header_get,
  8417. msm_dai_q6_tdm_header_put),
  8418. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  8419. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8420. msm_dai_q6_tdm_header_get,
  8421. msm_dai_q6_tdm_header_put),
  8422. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  8423. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8424. msm_dai_q6_tdm_header_get,
  8425. msm_dai_q6_tdm_header_put),
  8426. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  8427. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8428. msm_dai_q6_tdm_header_get,
  8429. msm_dai_q6_tdm_header_put),
  8430. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  8431. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8432. msm_dai_q6_tdm_header_get,
  8433. msm_dai_q6_tdm_header_put),
  8434. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_0 Header",
  8435. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8436. msm_dai_q6_tdm_header_get,
  8437. msm_dai_q6_tdm_header_put),
  8438. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_1 Header",
  8439. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8440. msm_dai_q6_tdm_header_get,
  8441. msm_dai_q6_tdm_header_put),
  8442. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_2 Header",
  8443. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8444. msm_dai_q6_tdm_header_get,
  8445. msm_dai_q6_tdm_header_put),
  8446. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_3 Header",
  8447. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8448. msm_dai_q6_tdm_header_get,
  8449. msm_dai_q6_tdm_header_put),
  8450. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_4 Header",
  8451. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8452. msm_dai_q6_tdm_header_get,
  8453. msm_dai_q6_tdm_header_put),
  8454. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_5 Header",
  8455. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8456. msm_dai_q6_tdm_header_get,
  8457. msm_dai_q6_tdm_header_put),
  8458. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_6 Header",
  8459. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8460. msm_dai_q6_tdm_header_get,
  8461. msm_dai_q6_tdm_header_put),
  8462. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_7 Header",
  8463. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8464. msm_dai_q6_tdm_header_get,
  8465. msm_dai_q6_tdm_header_put),
  8466. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_0 Header",
  8467. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8468. msm_dai_q6_tdm_header_get,
  8469. msm_dai_q6_tdm_header_put),
  8470. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_1 Header",
  8471. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8472. msm_dai_q6_tdm_header_get,
  8473. msm_dai_q6_tdm_header_put),
  8474. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_2 Header",
  8475. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8476. msm_dai_q6_tdm_header_get,
  8477. msm_dai_q6_tdm_header_put),
  8478. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_3 Header",
  8479. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8480. msm_dai_q6_tdm_header_get,
  8481. msm_dai_q6_tdm_header_put),
  8482. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_4 Header",
  8483. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8484. msm_dai_q6_tdm_header_get,
  8485. msm_dai_q6_tdm_header_put),
  8486. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_5 Header",
  8487. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8488. msm_dai_q6_tdm_header_get,
  8489. msm_dai_q6_tdm_header_put),
  8490. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_6 Header",
  8491. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8492. msm_dai_q6_tdm_header_get,
  8493. msm_dai_q6_tdm_header_put),
  8494. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_7 Header",
  8495. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8496. msm_dai_q6_tdm_header_get,
  8497. msm_dai_q6_tdm_header_put),
  8498. };
  8499. static int msm_dai_q6_tdm_set_clk(
  8500. struct msm_dai_q6_tdm_dai_data *dai_data,
  8501. u16 port_id, bool enable)
  8502. {
  8503. int rc = 0;
  8504. dai_data->clk_set.enable = enable;
  8505. rc = afe_set_lpass_clock_v2(port_id,
  8506. &dai_data->clk_set);
  8507. if (rc < 0)
  8508. pr_err("%s: afe lpass clock failed, err:%d\n",
  8509. __func__, rc);
  8510. return rc;
  8511. }
  8512. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  8513. {
  8514. int rc = 0;
  8515. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  8516. struct snd_kcontrol *data_format_kcontrol = NULL;
  8517. struct snd_kcontrol *header_type_kcontrol = NULL;
  8518. struct snd_kcontrol *header_kcontrol = NULL;
  8519. int port_idx = 0;
  8520. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  8521. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  8522. const struct snd_kcontrol_new *header_ctrl = NULL;
  8523. tdm_dai_data = dev_get_drvdata(dai->dev);
  8524. msm_dai_q6_set_dai_id(dai);
  8525. port_idx = msm_dai_q6_get_port_idx(dai->id);
  8526. if (port_idx < 0) {
  8527. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8528. __func__, dai->id);
  8529. rc = -EINVAL;
  8530. goto rtn;
  8531. }
  8532. data_format_ctrl =
  8533. &tdm_config_controls_data_format[port_idx];
  8534. header_type_ctrl =
  8535. &tdm_config_controls_header_type[port_idx];
  8536. header_ctrl =
  8537. &tdm_config_controls_header[port_idx];
  8538. if (data_format_ctrl) {
  8539. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  8540. tdm_dai_data);
  8541. rc = snd_ctl_add(dai->component->card->snd_card,
  8542. data_format_kcontrol);
  8543. if (rc < 0) {
  8544. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  8545. __func__, dai->name);
  8546. goto rtn;
  8547. }
  8548. }
  8549. if (header_type_ctrl) {
  8550. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  8551. tdm_dai_data);
  8552. rc = snd_ctl_add(dai->component->card->snd_card,
  8553. header_type_kcontrol);
  8554. if (rc < 0) {
  8555. if (data_format_kcontrol)
  8556. snd_ctl_remove(dai->component->card->snd_card,
  8557. data_format_kcontrol);
  8558. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  8559. __func__, dai->name);
  8560. goto rtn;
  8561. }
  8562. }
  8563. if (header_ctrl) {
  8564. header_kcontrol = snd_ctl_new1(header_ctrl,
  8565. tdm_dai_data);
  8566. rc = snd_ctl_add(dai->component->card->snd_card,
  8567. header_kcontrol);
  8568. if (rc < 0) {
  8569. if (header_type_kcontrol)
  8570. snd_ctl_remove(dai->component->card->snd_card,
  8571. header_type_kcontrol);
  8572. if (data_format_kcontrol)
  8573. snd_ctl_remove(dai->component->card->snd_card,
  8574. data_format_kcontrol);
  8575. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  8576. __func__, dai->name);
  8577. goto rtn;
  8578. }
  8579. }
  8580. if (tdm_dai_data->is_island_dai)
  8581. rc = msm_dai_q6_add_island_mx_ctls(
  8582. dai->component->card->snd_card,
  8583. dai->name,
  8584. dai->id, (void *)tdm_dai_data);
  8585. rc = msm_dai_q6_dai_add_route(dai);
  8586. rtn:
  8587. return rc;
  8588. }
  8589. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  8590. {
  8591. int rc = 0;
  8592. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  8593. dev_get_drvdata(dai->dev);
  8594. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  8595. int group_idx = 0;
  8596. atomic_t *group_ref = NULL;
  8597. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8598. if (group_idx < 0) {
  8599. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8600. __func__, dai->id);
  8601. return -EINVAL;
  8602. }
  8603. group_ref = &tdm_group_ref[group_idx];
  8604. /* If AFE port is still up, close it */
  8605. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  8606. rc = afe_close(dai->id); /* can block */
  8607. if (rc < 0) {
  8608. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8609. __func__, dai->id);
  8610. }
  8611. atomic_dec(group_ref);
  8612. clear_bit(STATUS_PORT_STARTED,
  8613. tdm_dai_data->status_mask);
  8614. if (atomic_read(group_ref) == 0) {
  8615. rc = afe_port_group_enable(group_id,
  8616. NULL, false, NULL);
  8617. if (rc < 0) {
  8618. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  8619. group_id);
  8620. }
  8621. }
  8622. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8623. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  8624. dai->id, false);
  8625. if (rc < 0) {
  8626. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8627. __func__, dai->id);
  8628. }
  8629. }
  8630. }
  8631. return 0;
  8632. }
  8633. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  8634. unsigned int tx_mask,
  8635. unsigned int rx_mask,
  8636. int slots, int slot_width)
  8637. {
  8638. int rc = 0;
  8639. struct msm_dai_q6_tdm_dai_data *dai_data =
  8640. dev_get_drvdata(dai->dev);
  8641. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8642. &dai_data->group_cfg.tdm_cfg;
  8643. unsigned int cap_mask;
  8644. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8645. /* HW only supports 16 and 32 bit slot width configuration */
  8646. if ((slot_width != 16) && (slot_width != 32)) {
  8647. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  8648. __func__, slot_width);
  8649. return -EINVAL;
  8650. }
  8651. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  8652. switch (slots) {
  8653. case 1:
  8654. cap_mask = 0x01;
  8655. break;
  8656. case 2:
  8657. cap_mask = 0x03;
  8658. break;
  8659. case 4:
  8660. cap_mask = 0x0F;
  8661. break;
  8662. case 8:
  8663. cap_mask = 0xFF;
  8664. break;
  8665. case 16:
  8666. cap_mask = 0xFFFF;
  8667. break;
  8668. case 32:
  8669. cap_mask = 0xFFFFFFFF;
  8670. break;
  8671. default:
  8672. dev_err(dai->dev, "%s: invalid slots %d\n",
  8673. __func__, slots);
  8674. return -EINVAL;
  8675. }
  8676. switch (dai->id) {
  8677. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8678. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8679. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8680. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8681. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8682. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8683. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8684. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8685. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8686. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8687. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8688. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8689. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8690. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8691. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8692. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8693. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8694. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8695. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8696. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8697. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8698. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8699. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8700. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8701. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8702. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8703. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8704. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8705. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8706. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8707. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8708. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8709. case AFE_PORT_ID_QUINARY_TDM_RX:
  8710. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8711. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8712. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8713. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8714. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8715. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8716. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8717. case AFE_PORT_ID_SENARY_TDM_RX:
  8718. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8719. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8720. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8721. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8722. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8723. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8724. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8725. tdm_group->nslots_per_frame = slots;
  8726. tdm_group->slot_width = slot_width;
  8727. tdm_group->slot_mask = rx_mask & cap_mask;
  8728. break;
  8729. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8730. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8731. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8732. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8733. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8734. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8735. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8736. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8737. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8738. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8739. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8740. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8741. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8742. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8743. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8744. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8745. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8746. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8747. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8748. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8749. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8750. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8751. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8752. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8753. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8754. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8755. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8756. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8757. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8758. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8759. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8760. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8761. case AFE_PORT_ID_QUINARY_TDM_TX:
  8762. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8763. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8764. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8765. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8766. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8767. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8768. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8769. case AFE_PORT_ID_SENARY_TDM_TX:
  8770. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8771. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8772. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8773. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8774. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8775. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8776. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8777. tdm_group->nslots_per_frame = slots;
  8778. tdm_group->slot_width = slot_width;
  8779. tdm_group->slot_mask = tx_mask & cap_mask;
  8780. break;
  8781. default:
  8782. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8783. __func__, dai->id);
  8784. return -EINVAL;
  8785. }
  8786. return rc;
  8787. }
  8788. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  8789. int clk_id, unsigned int freq, int dir)
  8790. {
  8791. struct msm_dai_q6_tdm_dai_data *dai_data =
  8792. dev_get_drvdata(dai->dev);
  8793. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  8794. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  8795. dai_data->clk_set.clk_freq_in_hz = freq;
  8796. } else {
  8797. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8798. __func__, dai->id);
  8799. return -EINVAL;
  8800. }
  8801. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  8802. __func__, dai->id, freq);
  8803. return 0;
  8804. }
  8805. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  8806. unsigned int tx_num, unsigned int *tx_slot,
  8807. unsigned int rx_num, unsigned int *rx_slot)
  8808. {
  8809. int rc = 0;
  8810. struct msm_dai_q6_tdm_dai_data *dai_data =
  8811. dev_get_drvdata(dai->dev);
  8812. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8813. &dai_data->port_cfg.slot_mapping;
  8814. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8815. &dai_data->port_cfg.slot_mapping_v2;
  8816. int i = 0;
  8817. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8818. switch (dai->id) {
  8819. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8820. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8821. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8822. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8823. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8824. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8825. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8826. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8827. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8828. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8829. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8830. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8831. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8832. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8833. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8834. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8835. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8836. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8837. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8838. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8839. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8840. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8841. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8842. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8843. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8844. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8845. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8846. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8847. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8848. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8849. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8850. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8851. case AFE_PORT_ID_QUINARY_TDM_RX:
  8852. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8853. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8854. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8855. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8856. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8857. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8858. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8859. case AFE_PORT_ID_SENARY_TDM_RX:
  8860. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8861. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8862. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8863. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8864. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8865. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8866. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8867. if (q6core_get_avcs_api_version_per_service(
  8868. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8869. if (!rx_slot) {
  8870. dev_err(dai->dev, "%s: rx slot not found\n",
  8871. __func__);
  8872. return -EINVAL;
  8873. }
  8874. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8875. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8876. __func__,
  8877. rx_num);
  8878. return -EINVAL;
  8879. }
  8880. for (i = 0; i < rx_num; i++)
  8881. slot_mapping_v2->offset[i] = rx_slot[i];
  8882. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8883. i++)
  8884. slot_mapping_v2->offset[i] =
  8885. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8886. slot_mapping_v2->num_channel = rx_num;
  8887. } else {
  8888. if (!rx_slot) {
  8889. dev_err(dai->dev, "%s: rx slot not found\n",
  8890. __func__);
  8891. return -EINVAL;
  8892. }
  8893. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8894. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8895. __func__,
  8896. rx_num);
  8897. return -EINVAL;
  8898. }
  8899. for (i = 0; i < rx_num; i++)
  8900. slot_mapping->offset[i] = rx_slot[i];
  8901. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8902. slot_mapping->offset[i] =
  8903. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8904. slot_mapping->num_channel = rx_num;
  8905. }
  8906. break;
  8907. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8908. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8909. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8910. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8911. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8912. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8913. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8914. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8915. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8916. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8917. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8918. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8919. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8920. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8921. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8922. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8923. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8924. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8925. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8926. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8927. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8928. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8929. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8930. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8931. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8932. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8933. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8934. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8935. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8936. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8937. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8938. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8939. case AFE_PORT_ID_QUINARY_TDM_TX:
  8940. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8941. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8942. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8943. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8944. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8945. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8946. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8947. case AFE_PORT_ID_SENARY_TDM_TX:
  8948. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8949. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8950. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8951. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8952. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8953. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8954. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8955. if (q6core_get_avcs_api_version_per_service(
  8956. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8957. if (!tx_slot) {
  8958. dev_err(dai->dev, "%s: tx slot not found\n",
  8959. __func__);
  8960. return -EINVAL;
  8961. }
  8962. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8963. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8964. __func__,
  8965. tx_num);
  8966. return -EINVAL;
  8967. }
  8968. for (i = 0; i < tx_num; i++)
  8969. slot_mapping_v2->offset[i] = tx_slot[i];
  8970. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8971. i++)
  8972. slot_mapping_v2->offset[i] =
  8973. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8974. slot_mapping_v2->num_channel = tx_num;
  8975. } else {
  8976. if (!tx_slot) {
  8977. dev_err(dai->dev, "%s: tx slot not found\n",
  8978. __func__);
  8979. return -EINVAL;
  8980. }
  8981. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8982. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8983. __func__,
  8984. tx_num);
  8985. return -EINVAL;
  8986. }
  8987. for (i = 0; i < tx_num; i++)
  8988. slot_mapping->offset[i] = tx_slot[i];
  8989. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8990. slot_mapping->offset[i] =
  8991. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8992. slot_mapping->num_channel = tx_num;
  8993. }
  8994. break;
  8995. default:
  8996. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8997. __func__, dai->id);
  8998. return -EINVAL;
  8999. }
  9000. return rc;
  9001. }
  9002. static unsigned int tdm_param_set_slot_mask(u16 *slot_offset, int slot_width,
  9003. int slots_per_frame)
  9004. {
  9005. unsigned int i = 0;
  9006. unsigned int slot_index = 0;
  9007. unsigned long slot_mask = 0;
  9008. unsigned int slot_width_bytes = slot_width / 8;
  9009. unsigned int channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT;
  9010. if (q6core_get_avcs_api_version_per_service(
  9011. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  9012. channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  9013. if (slot_width_bytes == 0) {
  9014. pr_err("%s: slot width is zero\n", __func__);
  9015. return slot_mask;
  9016. }
  9017. for (i = 0; i < channel_count; i++) {
  9018. if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) {
  9019. slot_index = slot_offset[i] / slot_width_bytes;
  9020. if (slot_index < slots_per_frame)
  9021. set_bit(slot_index, &slot_mask);
  9022. else {
  9023. pr_err("%s: invalid slot map setting\n",
  9024. __func__);
  9025. return 0;
  9026. }
  9027. } else {
  9028. break;
  9029. }
  9030. }
  9031. return slot_mask;
  9032. }
  9033. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  9034. struct snd_pcm_hw_params *params,
  9035. struct snd_soc_dai *dai)
  9036. {
  9037. struct msm_dai_q6_tdm_dai_data *dai_data =
  9038. dev_get_drvdata(dai->dev);
  9039. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  9040. &dai_data->group_cfg.tdm_cfg;
  9041. struct afe_param_id_tdm_cfg *tdm =
  9042. &dai_data->port_cfg.tdm;
  9043. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  9044. &dai_data->port_cfg.slot_mapping;
  9045. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  9046. &dai_data->port_cfg.slot_mapping_v2;
  9047. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  9048. &dai_data->port_cfg.custom_tdm_header;
  9049. pr_debug("%s: dev_name: %s\n",
  9050. __func__, dev_name(dai->dev));
  9051. if ((params_channels(params) == 0) ||
  9052. (params_channels(params) > 32)) {
  9053. dev_err(dai->dev, "%s: invalid param channels %d\n",
  9054. __func__, params_channels(params));
  9055. return -EINVAL;
  9056. }
  9057. switch (params_format(params)) {
  9058. case SNDRV_PCM_FORMAT_S16_LE:
  9059. dai_data->bitwidth = 16;
  9060. break;
  9061. case SNDRV_PCM_FORMAT_S24_LE:
  9062. case SNDRV_PCM_FORMAT_S24_3LE:
  9063. dai_data->bitwidth = 24;
  9064. break;
  9065. case SNDRV_PCM_FORMAT_S32_LE:
  9066. dai_data->bitwidth = 32;
  9067. break;
  9068. default:
  9069. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  9070. __func__, params_format(params));
  9071. return -EINVAL;
  9072. }
  9073. dai_data->channels = params_channels(params);
  9074. dai_data->rate = params_rate(params);
  9075. /*
  9076. * update tdm group config param
  9077. * NOTE: group config is set to the same as slot config.
  9078. */
  9079. tdm_group->bit_width = tdm_group->slot_width;
  9080. /*
  9081. * for multi lane scenario
  9082. * Total number of active channels = number of active lanes * number of active slots.
  9083. */
  9084. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  9085. tdm_group->num_channels = tdm_group->nslots_per_frame
  9086. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  9087. else
  9088. tdm_group->num_channels = tdm_group->nslots_per_frame;
  9089. tdm_group->sample_rate = dai_data->rate;
  9090. pr_debug("%s: TDM GROUP:\n"
  9091. "num_channels=%d sample_rate=%d bit_width=%d\n"
  9092. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  9093. __func__,
  9094. tdm_group->num_channels,
  9095. tdm_group->sample_rate,
  9096. tdm_group->bit_width,
  9097. tdm_group->nslots_per_frame,
  9098. tdm_group->slot_width,
  9099. tdm_group->slot_mask);
  9100. pr_debug("%s: TDM GROUP:\n"
  9101. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  9102. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  9103. __func__,
  9104. tdm_group->port_id[0],
  9105. tdm_group->port_id[1],
  9106. tdm_group->port_id[2],
  9107. tdm_group->port_id[3],
  9108. tdm_group->port_id[4],
  9109. tdm_group->port_id[5],
  9110. tdm_group->port_id[6],
  9111. tdm_group->port_id[7]);
  9112. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  9113. __func__,
  9114. tdm_group->group_id,
  9115. dai_data->lane_cfg.lane_mask);
  9116. /*
  9117. * update tdm config param
  9118. * NOTE: channels/rate/bitwidth are per stream property
  9119. */
  9120. tdm->num_channels = dai_data->channels;
  9121. tdm->sample_rate = dai_data->rate;
  9122. tdm->bit_width = dai_data->bitwidth;
  9123. /*
  9124. * port slot config is the same as group slot config
  9125. * port slot mask should be set according to offset
  9126. */
  9127. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  9128. tdm->slot_width = tdm_group->slot_width;
  9129. if (q6core_get_avcs_api_version_per_service(
  9130. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  9131. tdm->slot_mask = tdm_param_set_slot_mask(
  9132. slot_mapping_v2->offset,
  9133. tdm_group->slot_width,
  9134. tdm_group->nslots_per_frame);
  9135. else
  9136. tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset,
  9137. tdm_group->slot_width,
  9138. tdm_group->nslots_per_frame);
  9139. pr_debug("%s: TDM:\n"
  9140. "num_channels=%d sample_rate=%d bit_width=%d\n"
  9141. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  9142. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  9143. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  9144. __func__,
  9145. tdm->num_channels,
  9146. tdm->sample_rate,
  9147. tdm->bit_width,
  9148. tdm->nslots_per_frame,
  9149. tdm->slot_width,
  9150. tdm->slot_mask,
  9151. tdm->data_format,
  9152. tdm->sync_mode,
  9153. tdm->sync_src,
  9154. tdm->ctrl_data_out_enable,
  9155. tdm->ctrl_invert_sync_pulse,
  9156. tdm->ctrl_sync_data_delay);
  9157. if (q6core_get_avcs_api_version_per_service(
  9158. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  9159. /*
  9160. * update slot mapping v2 config param
  9161. * NOTE: channels/rate/bitwidth are per stream property
  9162. */
  9163. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  9164. pr_debug("%s: SLOT MAPPING_V2:\n"
  9165. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  9166. __func__,
  9167. slot_mapping_v2->num_channel,
  9168. slot_mapping_v2->bitwidth,
  9169. slot_mapping_v2->data_align_type);
  9170. pr_debug("%s: SLOT MAPPING V2:\n"
  9171. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  9172. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  9173. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  9174. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  9175. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  9176. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  9177. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  9178. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  9179. __func__,
  9180. slot_mapping_v2->offset[0],
  9181. slot_mapping_v2->offset[1],
  9182. slot_mapping_v2->offset[2],
  9183. slot_mapping_v2->offset[3],
  9184. slot_mapping_v2->offset[4],
  9185. slot_mapping_v2->offset[5],
  9186. slot_mapping_v2->offset[6],
  9187. slot_mapping_v2->offset[7],
  9188. slot_mapping_v2->offset[8],
  9189. slot_mapping_v2->offset[9],
  9190. slot_mapping_v2->offset[10],
  9191. slot_mapping_v2->offset[11],
  9192. slot_mapping_v2->offset[12],
  9193. slot_mapping_v2->offset[13],
  9194. slot_mapping_v2->offset[14],
  9195. slot_mapping_v2->offset[15],
  9196. slot_mapping_v2->offset[16],
  9197. slot_mapping_v2->offset[17],
  9198. slot_mapping_v2->offset[18],
  9199. slot_mapping_v2->offset[19],
  9200. slot_mapping_v2->offset[20],
  9201. slot_mapping_v2->offset[21],
  9202. slot_mapping_v2->offset[22],
  9203. slot_mapping_v2->offset[23],
  9204. slot_mapping_v2->offset[24],
  9205. slot_mapping_v2->offset[25],
  9206. slot_mapping_v2->offset[26],
  9207. slot_mapping_v2->offset[27],
  9208. slot_mapping_v2->offset[28],
  9209. slot_mapping_v2->offset[29],
  9210. slot_mapping_v2->offset[30],
  9211. slot_mapping_v2->offset[31]);
  9212. } else {
  9213. /*
  9214. * update slot mapping config param
  9215. * NOTE: channels/rate/bitwidth are per stream property
  9216. */
  9217. slot_mapping->bitwidth = dai_data->bitwidth;
  9218. pr_debug("%s: SLOT MAPPING:\n"
  9219. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  9220. __func__,
  9221. slot_mapping->num_channel,
  9222. slot_mapping->bitwidth,
  9223. slot_mapping->data_align_type);
  9224. pr_debug("%s: SLOT MAPPING:\n"
  9225. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  9226. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  9227. __func__,
  9228. slot_mapping->offset[0],
  9229. slot_mapping->offset[1],
  9230. slot_mapping->offset[2],
  9231. slot_mapping->offset[3],
  9232. slot_mapping->offset[4],
  9233. slot_mapping->offset[5],
  9234. slot_mapping->offset[6],
  9235. slot_mapping->offset[7]);
  9236. }
  9237. /*
  9238. * update custom header config param
  9239. * NOTE: channels/rate/bitwidth are per playback stream property.
  9240. * custom tdm header only applicable to playback stream.
  9241. */
  9242. if (custom_tdm_header->header_type !=
  9243. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  9244. pr_debug("%s: CUSTOM TDM HEADER:\n"
  9245. "start_offset=0x%x header_width=%d\n"
  9246. "num_frame_repeat=%d header_type=0x%x\n",
  9247. __func__,
  9248. custom_tdm_header->start_offset,
  9249. custom_tdm_header->header_width,
  9250. custom_tdm_header->num_frame_repeat,
  9251. custom_tdm_header->header_type);
  9252. pr_debug("%s: CUSTOM TDM HEADER:\n"
  9253. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  9254. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  9255. __func__,
  9256. custom_tdm_header->header[0],
  9257. custom_tdm_header->header[1],
  9258. custom_tdm_header->header[2],
  9259. custom_tdm_header->header[3],
  9260. custom_tdm_header->header[4],
  9261. custom_tdm_header->header[5],
  9262. custom_tdm_header->header[6],
  9263. custom_tdm_header->header[7]);
  9264. }
  9265. return 0;
  9266. }
  9267. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  9268. struct snd_soc_dai *dai)
  9269. {
  9270. int rc = 0;
  9271. struct msm_dai_q6_tdm_dai_data *dai_data =
  9272. dev_get_drvdata(dai->dev);
  9273. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  9274. int group_idx = 0;
  9275. atomic_t *group_ref = NULL;
  9276. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  9277. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  9278. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  9279. dev_dbg(dai->dev,
  9280. "%s: Custom tdm header not supported\n", __func__);
  9281. group_idx = msm_dai_q6_get_group_idx(dai->id);
  9282. if (group_idx < 0) {
  9283. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  9284. __func__, dai->id);
  9285. return -EINVAL;
  9286. }
  9287. mutex_lock(&tdm_mutex);
  9288. group_ref = &tdm_group_ref[group_idx];
  9289. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9290. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9291. /* TX and RX share the same clk. So enable the clk
  9292. * per TDM interface. */
  9293. rc = msm_dai_q6_tdm_set_clk(dai_data,
  9294. dai->id, true);
  9295. if (rc < 0) {
  9296. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  9297. __func__, dai->id);
  9298. goto rtn;
  9299. }
  9300. }
  9301. /* PORT START should be set if prepare called
  9302. * in active state.
  9303. */
  9304. if (atomic_read(group_ref) == 0) {
  9305. /*
  9306. * if only one port, don't do group enable as there
  9307. * is no group need for only one port
  9308. */
  9309. if (dai_data->num_group_ports > 1) {
  9310. rc = afe_port_group_enable(group_id,
  9311. &dai_data->group_cfg, true,
  9312. &dai_data->lane_cfg);
  9313. if (rc < 0) {
  9314. dev_err(dai->dev,
  9315. "%s: fail to enable AFE group 0x%x\n",
  9316. __func__, group_id);
  9317. goto rtn;
  9318. }
  9319. }
  9320. }
  9321. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  9322. dai_data->rate, dai_data->num_group_ports);
  9323. if (rc < 0) {
  9324. if (atomic_read(group_ref) == 0) {
  9325. afe_port_group_enable(group_id,
  9326. NULL, false, NULL);
  9327. }
  9328. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9329. msm_dai_q6_tdm_set_clk(dai_data,
  9330. dai->id, false);
  9331. }
  9332. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  9333. __func__, dai->id);
  9334. } else {
  9335. set_bit(STATUS_PORT_STARTED,
  9336. dai_data->status_mask);
  9337. atomic_inc(group_ref);
  9338. }
  9339. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  9340. /* NOTE: AFE should error out if HW resource contention */
  9341. }
  9342. rtn:
  9343. mutex_unlock(&tdm_mutex);
  9344. return rc;
  9345. }
  9346. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  9347. struct snd_soc_dai *dai)
  9348. {
  9349. int rc = 0;
  9350. struct msm_dai_q6_tdm_dai_data *dai_data =
  9351. dev_get_drvdata(dai->dev);
  9352. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  9353. int group_idx = 0;
  9354. atomic_t *group_ref = NULL;
  9355. group_idx = msm_dai_q6_get_group_idx(dai->id);
  9356. if (group_idx < 0) {
  9357. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  9358. __func__, dai->id);
  9359. return;
  9360. }
  9361. mutex_lock(&tdm_mutex);
  9362. group_ref = &tdm_group_ref[group_idx];
  9363. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9364. rc = afe_close(dai->id);
  9365. if (rc < 0) {
  9366. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  9367. __func__, dai->id);
  9368. }
  9369. atomic_dec(group_ref);
  9370. clear_bit(STATUS_PORT_STARTED,
  9371. dai_data->status_mask);
  9372. if (atomic_read(group_ref) == 0) {
  9373. rc = afe_port_group_enable(group_id,
  9374. NULL, false, NULL);
  9375. if (rc < 0) {
  9376. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  9377. __func__, group_id);
  9378. }
  9379. }
  9380. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9381. rc = msm_dai_q6_tdm_set_clk(dai_data,
  9382. dai->id, false);
  9383. if (rc < 0) {
  9384. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  9385. __func__, dai->id);
  9386. }
  9387. }
  9388. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  9389. /* NOTE: AFE should error out if HW resource contention */
  9390. }
  9391. mutex_unlock(&tdm_mutex);
  9392. }
  9393. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  9394. .prepare = msm_dai_q6_tdm_prepare,
  9395. .hw_params = msm_dai_q6_tdm_hw_params,
  9396. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  9397. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  9398. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  9399. .shutdown = msm_dai_q6_tdm_shutdown,
  9400. };
  9401. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  9402. {
  9403. .playback = {
  9404. .stream_name = "Primary TDM0 Playback",
  9405. .aif_name = "PRI_TDM_RX_0",
  9406. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9407. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9408. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9409. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9410. SNDRV_PCM_FMTBIT_S24_LE |
  9411. SNDRV_PCM_FMTBIT_S32_LE,
  9412. .channels_min = 1,
  9413. .channels_max = 16,
  9414. .rate_min = 8000,
  9415. .rate_max = 352800,
  9416. },
  9417. .name = "PRI_TDM_RX_0",
  9418. .ops = &msm_dai_q6_tdm_ops,
  9419. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  9420. .probe = msm_dai_q6_dai_tdm_probe,
  9421. .remove = msm_dai_q6_dai_tdm_remove,
  9422. },
  9423. {
  9424. .playback = {
  9425. .stream_name = "Primary TDM1 Playback",
  9426. .aif_name = "PRI_TDM_RX_1",
  9427. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9428. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9429. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9430. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9431. SNDRV_PCM_FMTBIT_S24_LE |
  9432. SNDRV_PCM_FMTBIT_S32_LE,
  9433. .channels_min = 1,
  9434. .channels_max = 16,
  9435. .rate_min = 8000,
  9436. .rate_max = 352800,
  9437. },
  9438. .name = "PRI_TDM_RX_1",
  9439. .ops = &msm_dai_q6_tdm_ops,
  9440. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  9441. .probe = msm_dai_q6_dai_tdm_probe,
  9442. .remove = msm_dai_q6_dai_tdm_remove,
  9443. },
  9444. {
  9445. .playback = {
  9446. .stream_name = "Primary TDM2 Playback",
  9447. .aif_name = "PRI_TDM_RX_2",
  9448. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9449. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9450. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9451. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9452. SNDRV_PCM_FMTBIT_S24_LE |
  9453. SNDRV_PCM_FMTBIT_S32_LE,
  9454. .channels_min = 1,
  9455. .channels_max = 16,
  9456. .rate_min = 8000,
  9457. .rate_max = 352800,
  9458. },
  9459. .name = "PRI_TDM_RX_2",
  9460. .ops = &msm_dai_q6_tdm_ops,
  9461. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  9462. .probe = msm_dai_q6_dai_tdm_probe,
  9463. .remove = msm_dai_q6_dai_tdm_remove,
  9464. },
  9465. {
  9466. .playback = {
  9467. .stream_name = "Primary TDM3 Playback",
  9468. .aif_name = "PRI_TDM_RX_3",
  9469. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9470. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9471. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9472. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9473. SNDRV_PCM_FMTBIT_S24_LE |
  9474. SNDRV_PCM_FMTBIT_S32_LE,
  9475. .channels_min = 1,
  9476. .channels_max = 16,
  9477. .rate_min = 8000,
  9478. .rate_max = 352800,
  9479. },
  9480. .name = "PRI_TDM_RX_3",
  9481. .ops = &msm_dai_q6_tdm_ops,
  9482. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  9483. .probe = msm_dai_q6_dai_tdm_probe,
  9484. .remove = msm_dai_q6_dai_tdm_remove,
  9485. },
  9486. {
  9487. .playback = {
  9488. .stream_name = "Primary TDM4 Playback",
  9489. .aif_name = "PRI_TDM_RX_4",
  9490. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9491. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9492. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9493. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9494. SNDRV_PCM_FMTBIT_S24_LE |
  9495. SNDRV_PCM_FMTBIT_S32_LE,
  9496. .channels_min = 1,
  9497. .channels_max = 16,
  9498. .rate_min = 8000,
  9499. .rate_max = 352800,
  9500. },
  9501. .name = "PRI_TDM_RX_4",
  9502. .ops = &msm_dai_q6_tdm_ops,
  9503. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  9504. .probe = msm_dai_q6_dai_tdm_probe,
  9505. .remove = msm_dai_q6_dai_tdm_remove,
  9506. },
  9507. {
  9508. .playback = {
  9509. .stream_name = "Primary TDM5 Playback",
  9510. .aif_name = "PRI_TDM_RX_5",
  9511. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9512. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9513. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9514. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9515. SNDRV_PCM_FMTBIT_S24_LE |
  9516. SNDRV_PCM_FMTBIT_S32_LE,
  9517. .channels_min = 1,
  9518. .channels_max = 16,
  9519. .rate_min = 8000,
  9520. .rate_max = 352800,
  9521. },
  9522. .name = "PRI_TDM_RX_5",
  9523. .ops = &msm_dai_q6_tdm_ops,
  9524. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  9525. .probe = msm_dai_q6_dai_tdm_probe,
  9526. .remove = msm_dai_q6_dai_tdm_remove,
  9527. },
  9528. {
  9529. .playback = {
  9530. .stream_name = "Primary TDM6 Playback",
  9531. .aif_name = "PRI_TDM_RX_6",
  9532. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9533. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9534. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9535. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9536. SNDRV_PCM_FMTBIT_S24_LE |
  9537. SNDRV_PCM_FMTBIT_S32_LE,
  9538. .channels_min = 1,
  9539. .channels_max = 16,
  9540. .rate_min = 8000,
  9541. .rate_max = 352800,
  9542. },
  9543. .name = "PRI_TDM_RX_6",
  9544. .ops = &msm_dai_q6_tdm_ops,
  9545. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  9546. .probe = msm_dai_q6_dai_tdm_probe,
  9547. .remove = msm_dai_q6_dai_tdm_remove,
  9548. },
  9549. {
  9550. .playback = {
  9551. .stream_name = "Primary TDM7 Playback",
  9552. .aif_name = "PRI_TDM_RX_7",
  9553. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9554. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9555. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9556. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9557. SNDRV_PCM_FMTBIT_S24_LE |
  9558. SNDRV_PCM_FMTBIT_S32_LE,
  9559. .channels_min = 1,
  9560. .channels_max = 16,
  9561. .rate_min = 8000,
  9562. .rate_max = 352800,
  9563. },
  9564. .name = "PRI_TDM_RX_7",
  9565. .ops = &msm_dai_q6_tdm_ops,
  9566. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  9567. .probe = msm_dai_q6_dai_tdm_probe,
  9568. .remove = msm_dai_q6_dai_tdm_remove,
  9569. },
  9570. {
  9571. .capture = {
  9572. .stream_name = "Primary TDM0 Capture",
  9573. .aif_name = "PRI_TDM_TX_0",
  9574. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9575. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9576. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9577. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9578. SNDRV_PCM_FMTBIT_S24_LE |
  9579. SNDRV_PCM_FMTBIT_S32_LE,
  9580. .channels_min = 1,
  9581. .channels_max = 16,
  9582. .rate_min = 8000,
  9583. .rate_max = 352800,
  9584. },
  9585. .name = "PRI_TDM_TX_0",
  9586. .ops = &msm_dai_q6_tdm_ops,
  9587. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  9588. .probe = msm_dai_q6_dai_tdm_probe,
  9589. .remove = msm_dai_q6_dai_tdm_remove,
  9590. },
  9591. {
  9592. .capture = {
  9593. .stream_name = "Primary TDM1 Capture",
  9594. .aif_name = "PRI_TDM_TX_1",
  9595. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9596. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9597. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9598. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9599. SNDRV_PCM_FMTBIT_S24_LE |
  9600. SNDRV_PCM_FMTBIT_S32_LE,
  9601. .channels_min = 1,
  9602. .channels_max = 16,
  9603. .rate_min = 8000,
  9604. .rate_max = 352800,
  9605. },
  9606. .name = "PRI_TDM_TX_1",
  9607. .ops = &msm_dai_q6_tdm_ops,
  9608. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  9609. .probe = msm_dai_q6_dai_tdm_probe,
  9610. .remove = msm_dai_q6_dai_tdm_remove,
  9611. },
  9612. {
  9613. .capture = {
  9614. .stream_name = "Primary TDM2 Capture",
  9615. .aif_name = "PRI_TDM_TX_2",
  9616. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9617. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9618. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9619. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9620. SNDRV_PCM_FMTBIT_S24_LE |
  9621. SNDRV_PCM_FMTBIT_S32_LE,
  9622. .channels_min = 1,
  9623. .channels_max = 16,
  9624. .rate_min = 8000,
  9625. .rate_max = 352800,
  9626. },
  9627. .name = "PRI_TDM_TX_2",
  9628. .ops = &msm_dai_q6_tdm_ops,
  9629. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  9630. .probe = msm_dai_q6_dai_tdm_probe,
  9631. .remove = msm_dai_q6_dai_tdm_remove,
  9632. },
  9633. {
  9634. .capture = {
  9635. .stream_name = "Primary TDM3 Capture",
  9636. .aif_name = "PRI_TDM_TX_3",
  9637. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9638. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9639. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9640. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9641. SNDRV_PCM_FMTBIT_S24_LE |
  9642. SNDRV_PCM_FMTBIT_S32_LE,
  9643. .channels_min = 1,
  9644. .channels_max = 16,
  9645. .rate_min = 8000,
  9646. .rate_max = 352800,
  9647. },
  9648. .name = "PRI_TDM_TX_3",
  9649. .ops = &msm_dai_q6_tdm_ops,
  9650. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  9651. .probe = msm_dai_q6_dai_tdm_probe,
  9652. .remove = msm_dai_q6_dai_tdm_remove,
  9653. },
  9654. {
  9655. .capture = {
  9656. .stream_name = "Primary TDM4 Capture",
  9657. .aif_name = "PRI_TDM_TX_4",
  9658. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9659. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9660. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9661. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9662. SNDRV_PCM_FMTBIT_S24_LE |
  9663. SNDRV_PCM_FMTBIT_S32_LE,
  9664. .channels_min = 1,
  9665. .channels_max = 16,
  9666. .rate_min = 8000,
  9667. .rate_max = 352800,
  9668. },
  9669. .name = "PRI_TDM_TX_4",
  9670. .ops = &msm_dai_q6_tdm_ops,
  9671. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  9672. .probe = msm_dai_q6_dai_tdm_probe,
  9673. .remove = msm_dai_q6_dai_tdm_remove,
  9674. },
  9675. {
  9676. .capture = {
  9677. .stream_name = "Primary TDM5 Capture",
  9678. .aif_name = "PRI_TDM_TX_5",
  9679. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9680. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9681. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9682. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9683. SNDRV_PCM_FMTBIT_S24_LE |
  9684. SNDRV_PCM_FMTBIT_S32_LE,
  9685. .channels_min = 1,
  9686. .channels_max = 16,
  9687. .rate_min = 8000,
  9688. .rate_max = 352800,
  9689. },
  9690. .name = "PRI_TDM_TX_5",
  9691. .ops = &msm_dai_q6_tdm_ops,
  9692. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  9693. .probe = msm_dai_q6_dai_tdm_probe,
  9694. .remove = msm_dai_q6_dai_tdm_remove,
  9695. },
  9696. {
  9697. .capture = {
  9698. .stream_name = "Primary TDM6 Capture",
  9699. .aif_name = "PRI_TDM_TX_6",
  9700. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9701. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9702. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9704. SNDRV_PCM_FMTBIT_S24_LE |
  9705. SNDRV_PCM_FMTBIT_S32_LE,
  9706. .channels_min = 1,
  9707. .channels_max = 16,
  9708. .rate_min = 8000,
  9709. .rate_max = 352800,
  9710. },
  9711. .name = "PRI_TDM_TX_6",
  9712. .ops = &msm_dai_q6_tdm_ops,
  9713. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  9714. .probe = msm_dai_q6_dai_tdm_probe,
  9715. .remove = msm_dai_q6_dai_tdm_remove,
  9716. },
  9717. {
  9718. .capture = {
  9719. .stream_name = "Primary TDM7 Capture",
  9720. .aif_name = "PRI_TDM_TX_7",
  9721. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9722. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9723. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9724. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9725. SNDRV_PCM_FMTBIT_S24_LE |
  9726. SNDRV_PCM_FMTBIT_S32_LE,
  9727. .channels_min = 1,
  9728. .channels_max = 16,
  9729. .rate_min = 8000,
  9730. .rate_max = 352800,
  9731. },
  9732. .name = "PRI_TDM_TX_7",
  9733. .ops = &msm_dai_q6_tdm_ops,
  9734. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  9735. .probe = msm_dai_q6_dai_tdm_probe,
  9736. .remove = msm_dai_q6_dai_tdm_remove,
  9737. },
  9738. {
  9739. .playback = {
  9740. .stream_name = "Secondary TDM0 Playback",
  9741. .aif_name = "SEC_TDM_RX_0",
  9742. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9743. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9744. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9745. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9746. SNDRV_PCM_FMTBIT_S24_LE |
  9747. SNDRV_PCM_FMTBIT_S32_LE,
  9748. .channels_min = 1,
  9749. .channels_max = 16,
  9750. .rate_min = 8000,
  9751. .rate_max = 352800,
  9752. },
  9753. .name = "SEC_TDM_RX_0",
  9754. .ops = &msm_dai_q6_tdm_ops,
  9755. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  9756. .probe = msm_dai_q6_dai_tdm_probe,
  9757. .remove = msm_dai_q6_dai_tdm_remove,
  9758. },
  9759. {
  9760. .playback = {
  9761. .stream_name = "Secondary TDM1 Playback",
  9762. .aif_name = "SEC_TDM_RX_1",
  9763. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9764. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9765. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9766. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9767. SNDRV_PCM_FMTBIT_S24_LE |
  9768. SNDRV_PCM_FMTBIT_S32_LE,
  9769. .channels_min = 1,
  9770. .channels_max = 16,
  9771. .rate_min = 8000,
  9772. .rate_max = 352800,
  9773. },
  9774. .name = "SEC_TDM_RX_1",
  9775. .ops = &msm_dai_q6_tdm_ops,
  9776. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  9777. .probe = msm_dai_q6_dai_tdm_probe,
  9778. .remove = msm_dai_q6_dai_tdm_remove,
  9779. },
  9780. {
  9781. .playback = {
  9782. .stream_name = "Secondary TDM2 Playback",
  9783. .aif_name = "SEC_TDM_RX_2",
  9784. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9785. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9786. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9787. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9788. SNDRV_PCM_FMTBIT_S24_LE |
  9789. SNDRV_PCM_FMTBIT_S32_LE,
  9790. .channels_min = 1,
  9791. .channels_max = 16,
  9792. .rate_min = 8000,
  9793. .rate_max = 352800,
  9794. },
  9795. .name = "SEC_TDM_RX_2",
  9796. .ops = &msm_dai_q6_tdm_ops,
  9797. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  9798. .probe = msm_dai_q6_dai_tdm_probe,
  9799. .remove = msm_dai_q6_dai_tdm_remove,
  9800. },
  9801. {
  9802. .playback = {
  9803. .stream_name = "Secondary TDM3 Playback",
  9804. .aif_name = "SEC_TDM_RX_3",
  9805. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9806. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9807. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9808. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9809. SNDRV_PCM_FMTBIT_S24_LE |
  9810. SNDRV_PCM_FMTBIT_S32_LE,
  9811. .channels_min = 1,
  9812. .channels_max = 16,
  9813. .rate_min = 8000,
  9814. .rate_max = 352800,
  9815. },
  9816. .name = "SEC_TDM_RX_3",
  9817. .ops = &msm_dai_q6_tdm_ops,
  9818. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  9819. .probe = msm_dai_q6_dai_tdm_probe,
  9820. .remove = msm_dai_q6_dai_tdm_remove,
  9821. },
  9822. {
  9823. .playback = {
  9824. .stream_name = "Secondary TDM4 Playback",
  9825. .aif_name = "SEC_TDM_RX_4",
  9826. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9827. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9828. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9829. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9830. SNDRV_PCM_FMTBIT_S24_LE |
  9831. SNDRV_PCM_FMTBIT_S32_LE,
  9832. .channels_min = 1,
  9833. .channels_max = 16,
  9834. .rate_min = 8000,
  9835. .rate_max = 352800,
  9836. },
  9837. .name = "SEC_TDM_RX_4",
  9838. .ops = &msm_dai_q6_tdm_ops,
  9839. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  9840. .probe = msm_dai_q6_dai_tdm_probe,
  9841. .remove = msm_dai_q6_dai_tdm_remove,
  9842. },
  9843. {
  9844. .playback = {
  9845. .stream_name = "Secondary TDM5 Playback",
  9846. .aif_name = "SEC_TDM_RX_5",
  9847. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9848. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9849. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9850. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9851. SNDRV_PCM_FMTBIT_S24_LE |
  9852. SNDRV_PCM_FMTBIT_S32_LE,
  9853. .channels_min = 1,
  9854. .channels_max = 16,
  9855. .rate_min = 8000,
  9856. .rate_max = 352800,
  9857. },
  9858. .name = "SEC_TDM_RX_5",
  9859. .ops = &msm_dai_q6_tdm_ops,
  9860. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  9861. .probe = msm_dai_q6_dai_tdm_probe,
  9862. .remove = msm_dai_q6_dai_tdm_remove,
  9863. },
  9864. {
  9865. .playback = {
  9866. .stream_name = "Secondary TDM6 Playback",
  9867. .aif_name = "SEC_TDM_RX_6",
  9868. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9869. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9870. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9871. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9872. SNDRV_PCM_FMTBIT_S24_LE |
  9873. SNDRV_PCM_FMTBIT_S32_LE,
  9874. .channels_min = 1,
  9875. .channels_max = 16,
  9876. .rate_min = 8000,
  9877. .rate_max = 352800,
  9878. },
  9879. .name = "SEC_TDM_RX_6",
  9880. .ops = &msm_dai_q6_tdm_ops,
  9881. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  9882. .probe = msm_dai_q6_dai_tdm_probe,
  9883. .remove = msm_dai_q6_dai_tdm_remove,
  9884. },
  9885. {
  9886. .playback = {
  9887. .stream_name = "Secondary TDM7 Playback",
  9888. .aif_name = "SEC_TDM_RX_7",
  9889. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9890. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9891. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9892. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9893. SNDRV_PCM_FMTBIT_S24_LE |
  9894. SNDRV_PCM_FMTBIT_S32_LE,
  9895. .channels_min = 1,
  9896. .channels_max = 16,
  9897. .rate_min = 8000,
  9898. .rate_max = 352800,
  9899. },
  9900. .name = "SEC_TDM_RX_7",
  9901. .ops = &msm_dai_q6_tdm_ops,
  9902. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  9903. .probe = msm_dai_q6_dai_tdm_probe,
  9904. .remove = msm_dai_q6_dai_tdm_remove,
  9905. },
  9906. {
  9907. .capture = {
  9908. .stream_name = "Secondary TDM0 Capture",
  9909. .aif_name = "SEC_TDM_TX_0",
  9910. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9911. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9912. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9913. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9914. SNDRV_PCM_FMTBIT_S24_LE |
  9915. SNDRV_PCM_FMTBIT_S32_LE,
  9916. .channels_min = 1,
  9917. .channels_max = 16,
  9918. .rate_min = 8000,
  9919. .rate_max = 352800,
  9920. },
  9921. .name = "SEC_TDM_TX_0",
  9922. .ops = &msm_dai_q6_tdm_ops,
  9923. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  9924. .probe = msm_dai_q6_dai_tdm_probe,
  9925. .remove = msm_dai_q6_dai_tdm_remove,
  9926. },
  9927. {
  9928. .capture = {
  9929. .stream_name = "Secondary TDM1 Capture",
  9930. .aif_name = "SEC_TDM_TX_1",
  9931. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9932. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9933. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9934. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9935. SNDRV_PCM_FMTBIT_S24_LE |
  9936. SNDRV_PCM_FMTBIT_S32_LE,
  9937. .channels_min = 1,
  9938. .channels_max = 16,
  9939. .rate_min = 8000,
  9940. .rate_max = 352800,
  9941. },
  9942. .name = "SEC_TDM_TX_1",
  9943. .ops = &msm_dai_q6_tdm_ops,
  9944. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  9945. .probe = msm_dai_q6_dai_tdm_probe,
  9946. .remove = msm_dai_q6_dai_tdm_remove,
  9947. },
  9948. {
  9949. .capture = {
  9950. .stream_name = "Secondary TDM2 Capture",
  9951. .aif_name = "SEC_TDM_TX_2",
  9952. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9953. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9954. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9955. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9956. SNDRV_PCM_FMTBIT_S24_LE |
  9957. SNDRV_PCM_FMTBIT_S32_LE,
  9958. .channels_min = 1,
  9959. .channels_max = 16,
  9960. .rate_min = 8000,
  9961. .rate_max = 352800,
  9962. },
  9963. .name = "SEC_TDM_TX_2",
  9964. .ops = &msm_dai_q6_tdm_ops,
  9965. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  9966. .probe = msm_dai_q6_dai_tdm_probe,
  9967. .remove = msm_dai_q6_dai_tdm_remove,
  9968. },
  9969. {
  9970. .capture = {
  9971. .stream_name = "Secondary TDM3 Capture",
  9972. .aif_name = "SEC_TDM_TX_3",
  9973. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9974. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9975. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9976. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9977. SNDRV_PCM_FMTBIT_S24_LE |
  9978. SNDRV_PCM_FMTBIT_S32_LE,
  9979. .channels_min = 1,
  9980. .channels_max = 16,
  9981. .rate_min = 8000,
  9982. .rate_max = 352800,
  9983. },
  9984. .name = "SEC_TDM_TX_3",
  9985. .ops = &msm_dai_q6_tdm_ops,
  9986. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  9987. .probe = msm_dai_q6_dai_tdm_probe,
  9988. .remove = msm_dai_q6_dai_tdm_remove,
  9989. },
  9990. {
  9991. .capture = {
  9992. .stream_name = "Secondary TDM4 Capture",
  9993. .aif_name = "SEC_TDM_TX_4",
  9994. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9995. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9996. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9997. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9998. SNDRV_PCM_FMTBIT_S24_LE |
  9999. SNDRV_PCM_FMTBIT_S32_LE,
  10000. .channels_min = 1,
  10001. .channels_max = 16,
  10002. .rate_min = 8000,
  10003. .rate_max = 352800,
  10004. },
  10005. .name = "SEC_TDM_TX_4",
  10006. .ops = &msm_dai_q6_tdm_ops,
  10007. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  10008. .probe = msm_dai_q6_dai_tdm_probe,
  10009. .remove = msm_dai_q6_dai_tdm_remove,
  10010. },
  10011. {
  10012. .capture = {
  10013. .stream_name = "Secondary TDM5 Capture",
  10014. .aif_name = "SEC_TDM_TX_5",
  10015. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10016. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10017. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10018. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10019. SNDRV_PCM_FMTBIT_S24_LE |
  10020. SNDRV_PCM_FMTBIT_S32_LE,
  10021. .channels_min = 1,
  10022. .channels_max = 16,
  10023. .rate_min = 8000,
  10024. .rate_max = 352800,
  10025. },
  10026. .name = "SEC_TDM_TX_5",
  10027. .ops = &msm_dai_q6_tdm_ops,
  10028. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  10029. .probe = msm_dai_q6_dai_tdm_probe,
  10030. .remove = msm_dai_q6_dai_tdm_remove,
  10031. },
  10032. {
  10033. .capture = {
  10034. .stream_name = "Secondary TDM6 Capture",
  10035. .aif_name = "SEC_TDM_TX_6",
  10036. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10037. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10038. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10039. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10040. SNDRV_PCM_FMTBIT_S24_LE |
  10041. SNDRV_PCM_FMTBIT_S32_LE,
  10042. .channels_min = 1,
  10043. .channels_max = 16,
  10044. .rate_min = 8000,
  10045. .rate_max = 352800,
  10046. },
  10047. .name = "SEC_TDM_TX_6",
  10048. .ops = &msm_dai_q6_tdm_ops,
  10049. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  10050. .probe = msm_dai_q6_dai_tdm_probe,
  10051. .remove = msm_dai_q6_dai_tdm_remove,
  10052. },
  10053. {
  10054. .capture = {
  10055. .stream_name = "Secondary TDM7 Capture",
  10056. .aif_name = "SEC_TDM_TX_7",
  10057. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10058. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10059. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10060. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10061. SNDRV_PCM_FMTBIT_S24_LE |
  10062. SNDRV_PCM_FMTBIT_S32_LE,
  10063. .channels_min = 1,
  10064. .channels_max = 16,
  10065. .rate_min = 8000,
  10066. .rate_max = 352800,
  10067. },
  10068. .name = "SEC_TDM_TX_7",
  10069. .ops = &msm_dai_q6_tdm_ops,
  10070. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  10071. .probe = msm_dai_q6_dai_tdm_probe,
  10072. .remove = msm_dai_q6_dai_tdm_remove,
  10073. },
  10074. {
  10075. .playback = {
  10076. .stream_name = "Tertiary TDM0 Playback",
  10077. .aif_name = "TERT_TDM_RX_0",
  10078. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10079. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10080. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10081. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10082. SNDRV_PCM_FMTBIT_S24_LE |
  10083. SNDRV_PCM_FMTBIT_S32_LE,
  10084. .channels_min = 1,
  10085. .channels_max = 16,
  10086. .rate_min = 8000,
  10087. .rate_max = 352800,
  10088. },
  10089. .name = "TERT_TDM_RX_0",
  10090. .ops = &msm_dai_q6_tdm_ops,
  10091. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  10092. .probe = msm_dai_q6_dai_tdm_probe,
  10093. .remove = msm_dai_q6_dai_tdm_remove,
  10094. },
  10095. {
  10096. .playback = {
  10097. .stream_name = "Tertiary TDM1 Playback",
  10098. .aif_name = "TERT_TDM_RX_1",
  10099. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10100. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10101. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10102. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10103. SNDRV_PCM_FMTBIT_S24_LE |
  10104. SNDRV_PCM_FMTBIT_S32_LE,
  10105. .channels_min = 1,
  10106. .channels_max = 16,
  10107. .rate_min = 8000,
  10108. .rate_max = 352800,
  10109. },
  10110. .name = "TERT_TDM_RX_1",
  10111. .ops = &msm_dai_q6_tdm_ops,
  10112. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  10113. .probe = msm_dai_q6_dai_tdm_probe,
  10114. .remove = msm_dai_q6_dai_tdm_remove,
  10115. },
  10116. {
  10117. .playback = {
  10118. .stream_name = "Tertiary TDM2 Playback",
  10119. .aif_name = "TERT_TDM_RX_2",
  10120. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10121. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10122. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10123. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10124. SNDRV_PCM_FMTBIT_S24_LE |
  10125. SNDRV_PCM_FMTBIT_S32_LE,
  10126. .channels_min = 1,
  10127. .channels_max = 16,
  10128. .rate_min = 8000,
  10129. .rate_max = 352800,
  10130. },
  10131. .name = "TERT_TDM_RX_2",
  10132. .ops = &msm_dai_q6_tdm_ops,
  10133. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  10134. .probe = msm_dai_q6_dai_tdm_probe,
  10135. .remove = msm_dai_q6_dai_tdm_remove,
  10136. },
  10137. {
  10138. .playback = {
  10139. .stream_name = "Tertiary TDM3 Playback",
  10140. .aif_name = "TERT_TDM_RX_3",
  10141. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10142. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10143. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10144. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10145. SNDRV_PCM_FMTBIT_S24_LE |
  10146. SNDRV_PCM_FMTBIT_S32_LE,
  10147. .channels_min = 1,
  10148. .channels_max = 16,
  10149. .rate_min = 8000,
  10150. .rate_max = 352800,
  10151. },
  10152. .name = "TERT_TDM_RX_3",
  10153. .ops = &msm_dai_q6_tdm_ops,
  10154. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  10155. .probe = msm_dai_q6_dai_tdm_probe,
  10156. .remove = msm_dai_q6_dai_tdm_remove,
  10157. },
  10158. {
  10159. .playback = {
  10160. .stream_name = "Tertiary TDM4 Playback",
  10161. .aif_name = "TERT_TDM_RX_4",
  10162. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10163. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10164. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10165. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10166. SNDRV_PCM_FMTBIT_S24_LE |
  10167. SNDRV_PCM_FMTBIT_S32_LE,
  10168. .channels_min = 1,
  10169. .channels_max = 16,
  10170. .rate_min = 8000,
  10171. .rate_max = 352800,
  10172. },
  10173. .name = "TERT_TDM_RX_4",
  10174. .ops = &msm_dai_q6_tdm_ops,
  10175. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  10176. .probe = msm_dai_q6_dai_tdm_probe,
  10177. .remove = msm_dai_q6_dai_tdm_remove,
  10178. },
  10179. {
  10180. .playback = {
  10181. .stream_name = "Tertiary TDM5 Playback",
  10182. .aif_name = "TERT_TDM_RX_5",
  10183. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10184. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10185. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10186. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10187. SNDRV_PCM_FMTBIT_S24_LE |
  10188. SNDRV_PCM_FMTBIT_S32_LE,
  10189. .channels_min = 1,
  10190. .channels_max = 16,
  10191. .rate_min = 8000,
  10192. .rate_max = 352800,
  10193. },
  10194. .name = "TERT_TDM_RX_5",
  10195. .ops = &msm_dai_q6_tdm_ops,
  10196. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  10197. .probe = msm_dai_q6_dai_tdm_probe,
  10198. .remove = msm_dai_q6_dai_tdm_remove,
  10199. },
  10200. {
  10201. .playback = {
  10202. .stream_name = "Tertiary TDM6 Playback",
  10203. .aif_name = "TERT_TDM_RX_6",
  10204. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10205. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10206. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10207. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10208. SNDRV_PCM_FMTBIT_S24_LE |
  10209. SNDRV_PCM_FMTBIT_S32_LE,
  10210. .channels_min = 1,
  10211. .channels_max = 16,
  10212. .rate_min = 8000,
  10213. .rate_max = 352800,
  10214. },
  10215. .name = "TERT_TDM_RX_6",
  10216. .ops = &msm_dai_q6_tdm_ops,
  10217. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  10218. .probe = msm_dai_q6_dai_tdm_probe,
  10219. .remove = msm_dai_q6_dai_tdm_remove,
  10220. },
  10221. {
  10222. .playback = {
  10223. .stream_name = "Tertiary TDM7 Playback",
  10224. .aif_name = "TERT_TDM_RX_7",
  10225. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10226. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10227. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10228. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10229. SNDRV_PCM_FMTBIT_S24_LE |
  10230. SNDRV_PCM_FMTBIT_S32_LE,
  10231. .channels_min = 1,
  10232. .channels_max = 16,
  10233. .rate_min = 8000,
  10234. .rate_max = 352800,
  10235. },
  10236. .name = "TERT_TDM_RX_7",
  10237. .ops = &msm_dai_q6_tdm_ops,
  10238. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  10239. .probe = msm_dai_q6_dai_tdm_probe,
  10240. .remove = msm_dai_q6_dai_tdm_remove,
  10241. },
  10242. {
  10243. .capture = {
  10244. .stream_name = "Tertiary TDM0 Capture",
  10245. .aif_name = "TERT_TDM_TX_0",
  10246. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10247. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10248. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10249. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10250. SNDRV_PCM_FMTBIT_S24_LE |
  10251. SNDRV_PCM_FMTBIT_S32_LE,
  10252. .channels_min = 1,
  10253. .channels_max = 16,
  10254. .rate_min = 8000,
  10255. .rate_max = 352800,
  10256. },
  10257. .name = "TERT_TDM_TX_0",
  10258. .ops = &msm_dai_q6_tdm_ops,
  10259. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  10260. .probe = msm_dai_q6_dai_tdm_probe,
  10261. .remove = msm_dai_q6_dai_tdm_remove,
  10262. },
  10263. {
  10264. .capture = {
  10265. .stream_name = "Tertiary TDM1 Capture",
  10266. .aif_name = "TERT_TDM_TX_1",
  10267. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10268. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10269. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10270. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10271. SNDRV_PCM_FMTBIT_S24_LE |
  10272. SNDRV_PCM_FMTBIT_S32_LE,
  10273. .channels_min = 1,
  10274. .channels_max = 16,
  10275. .rate_min = 8000,
  10276. .rate_max = 352800,
  10277. },
  10278. .name = "TERT_TDM_TX_1",
  10279. .ops = &msm_dai_q6_tdm_ops,
  10280. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  10281. .probe = msm_dai_q6_dai_tdm_probe,
  10282. .remove = msm_dai_q6_dai_tdm_remove,
  10283. },
  10284. {
  10285. .capture = {
  10286. .stream_name = "Tertiary TDM2 Capture",
  10287. .aif_name = "TERT_TDM_TX_2",
  10288. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10289. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10290. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10291. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10292. SNDRV_PCM_FMTBIT_S24_LE |
  10293. SNDRV_PCM_FMTBIT_S32_LE,
  10294. .channels_min = 1,
  10295. .channels_max = 16,
  10296. .rate_min = 8000,
  10297. .rate_max = 352800,
  10298. },
  10299. .name = "TERT_TDM_TX_2",
  10300. .ops = &msm_dai_q6_tdm_ops,
  10301. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  10302. .probe = msm_dai_q6_dai_tdm_probe,
  10303. .remove = msm_dai_q6_dai_tdm_remove,
  10304. },
  10305. {
  10306. .capture = {
  10307. .stream_name = "Tertiary TDM3 Capture",
  10308. .aif_name = "TERT_TDM_TX_3",
  10309. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10310. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10311. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10312. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10313. SNDRV_PCM_FMTBIT_S24_LE |
  10314. SNDRV_PCM_FMTBIT_S32_LE,
  10315. .channels_min = 1,
  10316. .channels_max = 16,
  10317. .rate_min = 8000,
  10318. .rate_max = 352800,
  10319. },
  10320. .name = "TERT_TDM_TX_3",
  10321. .ops = &msm_dai_q6_tdm_ops,
  10322. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  10323. .probe = msm_dai_q6_dai_tdm_probe,
  10324. .remove = msm_dai_q6_dai_tdm_remove,
  10325. },
  10326. {
  10327. .capture = {
  10328. .stream_name = "Tertiary TDM4 Capture",
  10329. .aif_name = "TERT_TDM_TX_4",
  10330. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10331. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10332. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10333. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10334. SNDRV_PCM_FMTBIT_S24_LE |
  10335. SNDRV_PCM_FMTBIT_S32_LE,
  10336. .channels_min = 1,
  10337. .channels_max = 16,
  10338. .rate_min = 8000,
  10339. .rate_max = 352800,
  10340. },
  10341. .name = "TERT_TDM_TX_4",
  10342. .ops = &msm_dai_q6_tdm_ops,
  10343. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  10344. .probe = msm_dai_q6_dai_tdm_probe,
  10345. .remove = msm_dai_q6_dai_tdm_remove,
  10346. },
  10347. {
  10348. .capture = {
  10349. .stream_name = "Tertiary TDM5 Capture",
  10350. .aif_name = "TERT_TDM_TX_5",
  10351. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10352. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10353. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10354. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10355. SNDRV_PCM_FMTBIT_S24_LE |
  10356. SNDRV_PCM_FMTBIT_S32_LE,
  10357. .channels_min = 1,
  10358. .channels_max = 16,
  10359. .rate_min = 8000,
  10360. .rate_max = 352800,
  10361. },
  10362. .name = "TERT_TDM_TX_5",
  10363. .ops = &msm_dai_q6_tdm_ops,
  10364. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  10365. .probe = msm_dai_q6_dai_tdm_probe,
  10366. .remove = msm_dai_q6_dai_tdm_remove,
  10367. },
  10368. {
  10369. .capture = {
  10370. .stream_name = "Tertiary TDM6 Capture",
  10371. .aif_name = "TERT_TDM_TX_6",
  10372. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10373. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10374. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10375. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10376. SNDRV_PCM_FMTBIT_S24_LE |
  10377. SNDRV_PCM_FMTBIT_S32_LE,
  10378. .channels_min = 1,
  10379. .channels_max = 16,
  10380. .rate_min = 8000,
  10381. .rate_max = 352800,
  10382. },
  10383. .name = "TERT_TDM_TX_6",
  10384. .ops = &msm_dai_q6_tdm_ops,
  10385. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  10386. .probe = msm_dai_q6_dai_tdm_probe,
  10387. .remove = msm_dai_q6_dai_tdm_remove,
  10388. },
  10389. {
  10390. .capture = {
  10391. .stream_name = "Tertiary TDM7 Capture",
  10392. .aif_name = "TERT_TDM_TX_7",
  10393. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10394. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10395. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10396. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10397. SNDRV_PCM_FMTBIT_S24_LE |
  10398. SNDRV_PCM_FMTBIT_S32_LE,
  10399. .channels_min = 1,
  10400. .channels_max = 16,
  10401. .rate_min = 8000,
  10402. .rate_max = 352800,
  10403. },
  10404. .name = "TERT_TDM_TX_7",
  10405. .ops = &msm_dai_q6_tdm_ops,
  10406. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  10407. .probe = msm_dai_q6_dai_tdm_probe,
  10408. .remove = msm_dai_q6_dai_tdm_remove,
  10409. },
  10410. {
  10411. .playback = {
  10412. .stream_name = "Quaternary TDM0 Playback",
  10413. .aif_name = "QUAT_TDM_RX_0",
  10414. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10415. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10416. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10417. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10418. SNDRV_PCM_FMTBIT_S24_LE |
  10419. SNDRV_PCM_FMTBIT_S32_LE,
  10420. .channels_min = 1,
  10421. .channels_max = 16,
  10422. .rate_min = 8000,
  10423. .rate_max = 352800,
  10424. },
  10425. .name = "QUAT_TDM_RX_0",
  10426. .ops = &msm_dai_q6_tdm_ops,
  10427. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  10428. .probe = msm_dai_q6_dai_tdm_probe,
  10429. .remove = msm_dai_q6_dai_tdm_remove,
  10430. },
  10431. {
  10432. .playback = {
  10433. .stream_name = "Quaternary TDM1 Playback",
  10434. .aif_name = "QUAT_TDM_RX_1",
  10435. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10436. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10437. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10438. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10439. SNDRV_PCM_FMTBIT_S24_LE |
  10440. SNDRV_PCM_FMTBIT_S32_LE,
  10441. .channels_min = 1,
  10442. .channels_max = 16,
  10443. .rate_min = 8000,
  10444. .rate_max = 352800,
  10445. },
  10446. .name = "QUAT_TDM_RX_1",
  10447. .ops = &msm_dai_q6_tdm_ops,
  10448. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  10449. .probe = msm_dai_q6_dai_tdm_probe,
  10450. .remove = msm_dai_q6_dai_tdm_remove,
  10451. },
  10452. {
  10453. .playback = {
  10454. .stream_name = "Quaternary TDM2 Playback",
  10455. .aif_name = "QUAT_TDM_RX_2",
  10456. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10457. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10458. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10459. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10460. SNDRV_PCM_FMTBIT_S24_LE |
  10461. SNDRV_PCM_FMTBIT_S32_LE,
  10462. .channels_min = 1,
  10463. .channels_max = 16,
  10464. .rate_min = 8000,
  10465. .rate_max = 352800,
  10466. },
  10467. .name = "QUAT_TDM_RX_2",
  10468. .ops = &msm_dai_q6_tdm_ops,
  10469. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  10470. .probe = msm_dai_q6_dai_tdm_probe,
  10471. .remove = msm_dai_q6_dai_tdm_remove,
  10472. },
  10473. {
  10474. .playback = {
  10475. .stream_name = "Quaternary TDM3 Playback",
  10476. .aif_name = "QUAT_TDM_RX_3",
  10477. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10478. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10479. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10480. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10481. SNDRV_PCM_FMTBIT_S24_LE |
  10482. SNDRV_PCM_FMTBIT_S32_LE,
  10483. .channels_min = 1,
  10484. .channels_max = 16,
  10485. .rate_min = 8000,
  10486. .rate_max = 352800,
  10487. },
  10488. .name = "QUAT_TDM_RX_3",
  10489. .ops = &msm_dai_q6_tdm_ops,
  10490. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  10491. .probe = msm_dai_q6_dai_tdm_probe,
  10492. .remove = msm_dai_q6_dai_tdm_remove,
  10493. },
  10494. {
  10495. .playback = {
  10496. .stream_name = "Quaternary TDM4 Playback",
  10497. .aif_name = "QUAT_TDM_RX_4",
  10498. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10499. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10500. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10501. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10502. SNDRV_PCM_FMTBIT_S24_LE |
  10503. SNDRV_PCM_FMTBIT_S32_LE,
  10504. .channels_min = 1,
  10505. .channels_max = 16,
  10506. .rate_min = 8000,
  10507. .rate_max = 352800,
  10508. },
  10509. .name = "QUAT_TDM_RX_4",
  10510. .ops = &msm_dai_q6_tdm_ops,
  10511. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  10512. .probe = msm_dai_q6_dai_tdm_probe,
  10513. .remove = msm_dai_q6_dai_tdm_remove,
  10514. },
  10515. {
  10516. .playback = {
  10517. .stream_name = "Quaternary TDM5 Playback",
  10518. .aif_name = "QUAT_TDM_RX_5",
  10519. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10520. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10521. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10522. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10523. SNDRV_PCM_FMTBIT_S24_LE |
  10524. SNDRV_PCM_FMTBIT_S32_LE,
  10525. .channels_min = 1,
  10526. .channels_max = 16,
  10527. .rate_min = 8000,
  10528. .rate_max = 352800,
  10529. },
  10530. .name = "QUAT_TDM_RX_5",
  10531. .ops = &msm_dai_q6_tdm_ops,
  10532. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  10533. .probe = msm_dai_q6_dai_tdm_probe,
  10534. .remove = msm_dai_q6_dai_tdm_remove,
  10535. },
  10536. {
  10537. .playback = {
  10538. .stream_name = "Quaternary TDM6 Playback",
  10539. .aif_name = "QUAT_TDM_RX_6",
  10540. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10541. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10542. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10544. SNDRV_PCM_FMTBIT_S24_LE |
  10545. SNDRV_PCM_FMTBIT_S32_LE,
  10546. .channels_min = 1,
  10547. .channels_max = 16,
  10548. .rate_min = 8000,
  10549. .rate_max = 352800,
  10550. },
  10551. .name = "QUAT_TDM_RX_6",
  10552. .ops = &msm_dai_q6_tdm_ops,
  10553. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  10554. .probe = msm_dai_q6_dai_tdm_probe,
  10555. .remove = msm_dai_q6_dai_tdm_remove,
  10556. },
  10557. {
  10558. .playback = {
  10559. .stream_name = "Quaternary TDM7 Playback",
  10560. .aif_name = "QUAT_TDM_RX_7",
  10561. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10562. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10563. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10564. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10565. SNDRV_PCM_FMTBIT_S24_LE |
  10566. SNDRV_PCM_FMTBIT_S32_LE,
  10567. .channels_min = 1,
  10568. .channels_max = 16,
  10569. .rate_min = 8000,
  10570. .rate_max = 352800,
  10571. },
  10572. .name = "QUAT_TDM_RX_7",
  10573. .ops = &msm_dai_q6_tdm_ops,
  10574. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  10575. .probe = msm_dai_q6_dai_tdm_probe,
  10576. .remove = msm_dai_q6_dai_tdm_remove,
  10577. },
  10578. {
  10579. .capture = {
  10580. .stream_name = "Quaternary TDM0 Capture",
  10581. .aif_name = "QUAT_TDM_TX_0",
  10582. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10583. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10584. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10585. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10586. SNDRV_PCM_FMTBIT_S24_LE |
  10587. SNDRV_PCM_FMTBIT_S32_LE,
  10588. .channels_min = 1,
  10589. .channels_max = 16,
  10590. .rate_min = 8000,
  10591. .rate_max = 352800,
  10592. },
  10593. .name = "QUAT_TDM_TX_0",
  10594. .ops = &msm_dai_q6_tdm_ops,
  10595. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  10596. .probe = msm_dai_q6_dai_tdm_probe,
  10597. .remove = msm_dai_q6_dai_tdm_remove,
  10598. },
  10599. {
  10600. .capture = {
  10601. .stream_name = "Quaternary TDM1 Capture",
  10602. .aif_name = "QUAT_TDM_TX_1",
  10603. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10604. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10605. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10606. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10607. SNDRV_PCM_FMTBIT_S24_LE |
  10608. SNDRV_PCM_FMTBIT_S32_LE,
  10609. .channels_min = 1,
  10610. .channels_max = 16,
  10611. .rate_min = 8000,
  10612. .rate_max = 352800,
  10613. },
  10614. .name = "QUAT_TDM_TX_1",
  10615. .ops = &msm_dai_q6_tdm_ops,
  10616. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  10617. .probe = msm_dai_q6_dai_tdm_probe,
  10618. .remove = msm_dai_q6_dai_tdm_remove,
  10619. },
  10620. {
  10621. .capture = {
  10622. .stream_name = "Quaternary TDM2 Capture",
  10623. .aif_name = "QUAT_TDM_TX_2",
  10624. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10625. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10626. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10627. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10628. SNDRV_PCM_FMTBIT_S24_LE |
  10629. SNDRV_PCM_FMTBIT_S32_LE,
  10630. .channels_min = 1,
  10631. .channels_max = 16,
  10632. .rate_min = 8000,
  10633. .rate_max = 352800,
  10634. },
  10635. .name = "QUAT_TDM_TX_2",
  10636. .ops = &msm_dai_q6_tdm_ops,
  10637. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  10638. .probe = msm_dai_q6_dai_tdm_probe,
  10639. .remove = msm_dai_q6_dai_tdm_remove,
  10640. },
  10641. {
  10642. .capture = {
  10643. .stream_name = "Quaternary TDM3 Capture",
  10644. .aif_name = "QUAT_TDM_TX_3",
  10645. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10646. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10647. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10648. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10649. SNDRV_PCM_FMTBIT_S24_LE |
  10650. SNDRV_PCM_FMTBIT_S32_LE,
  10651. .channels_min = 1,
  10652. .channels_max = 16,
  10653. .rate_min = 8000,
  10654. .rate_max = 352800,
  10655. },
  10656. .name = "QUAT_TDM_TX_3",
  10657. .ops = &msm_dai_q6_tdm_ops,
  10658. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  10659. .probe = msm_dai_q6_dai_tdm_probe,
  10660. .remove = msm_dai_q6_dai_tdm_remove,
  10661. },
  10662. {
  10663. .capture = {
  10664. .stream_name = "Quaternary TDM4 Capture",
  10665. .aif_name = "QUAT_TDM_TX_4",
  10666. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10667. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10668. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10669. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10670. SNDRV_PCM_FMTBIT_S24_LE |
  10671. SNDRV_PCM_FMTBIT_S32_LE,
  10672. .channels_min = 1,
  10673. .channels_max = 16,
  10674. .rate_min = 8000,
  10675. .rate_max = 352800,
  10676. },
  10677. .name = "QUAT_TDM_TX_4",
  10678. .ops = &msm_dai_q6_tdm_ops,
  10679. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  10680. .probe = msm_dai_q6_dai_tdm_probe,
  10681. .remove = msm_dai_q6_dai_tdm_remove,
  10682. },
  10683. {
  10684. .capture = {
  10685. .stream_name = "Quaternary TDM5 Capture",
  10686. .aif_name = "QUAT_TDM_TX_5",
  10687. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10688. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10689. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10690. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10691. SNDRV_PCM_FMTBIT_S24_LE |
  10692. SNDRV_PCM_FMTBIT_S32_LE,
  10693. .channels_min = 1,
  10694. .channels_max = 16,
  10695. .rate_min = 8000,
  10696. .rate_max = 352800,
  10697. },
  10698. .name = "QUAT_TDM_TX_5",
  10699. .ops = &msm_dai_q6_tdm_ops,
  10700. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  10701. .probe = msm_dai_q6_dai_tdm_probe,
  10702. .remove = msm_dai_q6_dai_tdm_remove,
  10703. },
  10704. {
  10705. .capture = {
  10706. .stream_name = "Quaternary TDM6 Capture",
  10707. .aif_name = "QUAT_TDM_TX_6",
  10708. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10709. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10710. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10711. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10712. SNDRV_PCM_FMTBIT_S24_LE |
  10713. SNDRV_PCM_FMTBIT_S32_LE,
  10714. .channels_min = 1,
  10715. .channels_max = 16,
  10716. .rate_min = 8000,
  10717. .rate_max = 352800,
  10718. },
  10719. .name = "QUAT_TDM_TX_6",
  10720. .ops = &msm_dai_q6_tdm_ops,
  10721. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  10722. .probe = msm_dai_q6_dai_tdm_probe,
  10723. .remove = msm_dai_q6_dai_tdm_remove,
  10724. },
  10725. {
  10726. .capture = {
  10727. .stream_name = "Quaternary TDM7 Capture",
  10728. .aif_name = "QUAT_TDM_TX_7",
  10729. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10730. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10731. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10732. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10733. SNDRV_PCM_FMTBIT_S24_LE |
  10734. SNDRV_PCM_FMTBIT_S32_LE,
  10735. .channels_min = 1,
  10736. .channels_max = 16,
  10737. .rate_min = 8000,
  10738. .rate_max = 352800,
  10739. },
  10740. .name = "QUAT_TDM_TX_7",
  10741. .ops = &msm_dai_q6_tdm_ops,
  10742. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  10743. .probe = msm_dai_q6_dai_tdm_probe,
  10744. .remove = msm_dai_q6_dai_tdm_remove,
  10745. },
  10746. {
  10747. .playback = {
  10748. .stream_name = "Quinary TDM0 Playback",
  10749. .aif_name = "QUIN_TDM_RX_0",
  10750. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10751. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10752. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10753. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10754. SNDRV_PCM_FMTBIT_S24_LE |
  10755. SNDRV_PCM_FMTBIT_S32_LE,
  10756. .channels_min = 1,
  10757. .channels_max = 16,
  10758. .rate_min = 8000,
  10759. .rate_max = 352800,
  10760. },
  10761. .name = "QUIN_TDM_RX_0",
  10762. .ops = &msm_dai_q6_tdm_ops,
  10763. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  10764. .probe = msm_dai_q6_dai_tdm_probe,
  10765. .remove = msm_dai_q6_dai_tdm_remove,
  10766. },
  10767. {
  10768. .playback = {
  10769. .stream_name = "Quinary TDM1 Playback",
  10770. .aif_name = "QUIN_TDM_RX_1",
  10771. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10772. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10773. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10774. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10775. SNDRV_PCM_FMTBIT_S24_LE |
  10776. SNDRV_PCM_FMTBIT_S32_LE,
  10777. .channels_min = 1,
  10778. .channels_max = 16,
  10779. .rate_min = 8000,
  10780. .rate_max = 352800,
  10781. },
  10782. .name = "QUIN_TDM_RX_1",
  10783. .ops = &msm_dai_q6_tdm_ops,
  10784. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  10785. .probe = msm_dai_q6_dai_tdm_probe,
  10786. .remove = msm_dai_q6_dai_tdm_remove,
  10787. },
  10788. {
  10789. .playback = {
  10790. .stream_name = "Quinary TDM2 Playback",
  10791. .aif_name = "QUIN_TDM_RX_2",
  10792. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10793. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10794. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10795. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10796. SNDRV_PCM_FMTBIT_S24_LE |
  10797. SNDRV_PCM_FMTBIT_S32_LE,
  10798. .channels_min = 1,
  10799. .channels_max = 16,
  10800. .rate_min = 8000,
  10801. .rate_max = 352800,
  10802. },
  10803. .name = "QUIN_TDM_RX_2",
  10804. .ops = &msm_dai_q6_tdm_ops,
  10805. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  10806. .probe = msm_dai_q6_dai_tdm_probe,
  10807. .remove = msm_dai_q6_dai_tdm_remove,
  10808. },
  10809. {
  10810. .playback = {
  10811. .stream_name = "Quinary TDM3 Playback",
  10812. .aif_name = "QUIN_TDM_RX_3",
  10813. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10814. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10815. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10816. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10817. SNDRV_PCM_FMTBIT_S24_LE |
  10818. SNDRV_PCM_FMTBIT_S32_LE,
  10819. .channels_min = 1,
  10820. .channels_max = 16,
  10821. .rate_min = 8000,
  10822. .rate_max = 352800,
  10823. },
  10824. .name = "QUIN_TDM_RX_3",
  10825. .ops = &msm_dai_q6_tdm_ops,
  10826. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  10827. .probe = msm_dai_q6_dai_tdm_probe,
  10828. .remove = msm_dai_q6_dai_tdm_remove,
  10829. },
  10830. {
  10831. .playback = {
  10832. .stream_name = "Quinary TDM4 Playback",
  10833. .aif_name = "QUIN_TDM_RX_4",
  10834. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10835. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10836. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10837. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10838. SNDRV_PCM_FMTBIT_S24_LE |
  10839. SNDRV_PCM_FMTBIT_S32_LE,
  10840. .channels_min = 1,
  10841. .channels_max = 16,
  10842. .rate_min = 8000,
  10843. .rate_max = 352800,
  10844. },
  10845. .name = "QUIN_TDM_RX_4",
  10846. .ops = &msm_dai_q6_tdm_ops,
  10847. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  10848. .probe = msm_dai_q6_dai_tdm_probe,
  10849. .remove = msm_dai_q6_dai_tdm_remove,
  10850. },
  10851. {
  10852. .playback = {
  10853. .stream_name = "Quinary TDM5 Playback",
  10854. .aif_name = "QUIN_TDM_RX_5",
  10855. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10856. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10857. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10858. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10859. SNDRV_PCM_FMTBIT_S24_LE |
  10860. SNDRV_PCM_FMTBIT_S32_LE,
  10861. .channels_min = 1,
  10862. .channels_max = 16,
  10863. .rate_min = 8000,
  10864. .rate_max = 352800,
  10865. },
  10866. .name = "QUIN_TDM_RX_5",
  10867. .ops = &msm_dai_q6_tdm_ops,
  10868. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  10869. .probe = msm_dai_q6_dai_tdm_probe,
  10870. .remove = msm_dai_q6_dai_tdm_remove,
  10871. },
  10872. {
  10873. .playback = {
  10874. .stream_name = "Quinary TDM6 Playback",
  10875. .aif_name = "QUIN_TDM_RX_6",
  10876. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10877. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10878. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10879. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10880. SNDRV_PCM_FMTBIT_S24_LE |
  10881. SNDRV_PCM_FMTBIT_S32_LE,
  10882. .channels_min = 1,
  10883. .channels_max = 16,
  10884. .rate_min = 8000,
  10885. .rate_max = 352800,
  10886. },
  10887. .name = "QUIN_TDM_RX_6",
  10888. .ops = &msm_dai_q6_tdm_ops,
  10889. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  10890. .probe = msm_dai_q6_dai_tdm_probe,
  10891. .remove = msm_dai_q6_dai_tdm_remove,
  10892. },
  10893. {
  10894. .playback = {
  10895. .stream_name = "Quinary TDM7 Playback",
  10896. .aif_name = "QUIN_TDM_RX_7",
  10897. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10898. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10899. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10900. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10901. SNDRV_PCM_FMTBIT_S24_LE |
  10902. SNDRV_PCM_FMTBIT_S32_LE,
  10903. .channels_min = 1,
  10904. .channels_max = 16,
  10905. .rate_min = 8000,
  10906. .rate_max = 352800,
  10907. },
  10908. .name = "QUIN_TDM_RX_7",
  10909. .ops = &msm_dai_q6_tdm_ops,
  10910. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  10911. .probe = msm_dai_q6_dai_tdm_probe,
  10912. .remove = msm_dai_q6_dai_tdm_remove,
  10913. },
  10914. {
  10915. .capture = {
  10916. .stream_name = "Quinary TDM0 Capture",
  10917. .aif_name = "QUIN_TDM_TX_0",
  10918. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10919. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10920. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10921. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10922. SNDRV_PCM_FMTBIT_S24_LE |
  10923. SNDRV_PCM_FMTBIT_S32_LE,
  10924. .channels_min = 1,
  10925. .channels_max = 16,
  10926. .rate_min = 8000,
  10927. .rate_max = 352800,
  10928. },
  10929. .name = "QUIN_TDM_TX_0",
  10930. .ops = &msm_dai_q6_tdm_ops,
  10931. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  10932. .probe = msm_dai_q6_dai_tdm_probe,
  10933. .remove = msm_dai_q6_dai_tdm_remove,
  10934. },
  10935. {
  10936. .capture = {
  10937. .stream_name = "Quinary TDM1 Capture",
  10938. .aif_name = "QUIN_TDM_TX_1",
  10939. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10940. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10941. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10942. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10943. SNDRV_PCM_FMTBIT_S24_LE |
  10944. SNDRV_PCM_FMTBIT_S32_LE,
  10945. .channels_min = 1,
  10946. .channels_max = 16,
  10947. .rate_min = 8000,
  10948. .rate_max = 352800,
  10949. },
  10950. .name = "QUIN_TDM_TX_1",
  10951. .ops = &msm_dai_q6_tdm_ops,
  10952. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  10953. .probe = msm_dai_q6_dai_tdm_probe,
  10954. .remove = msm_dai_q6_dai_tdm_remove,
  10955. },
  10956. {
  10957. .capture = {
  10958. .stream_name = "Quinary TDM2 Capture",
  10959. .aif_name = "QUIN_TDM_TX_2",
  10960. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10961. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10962. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10963. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10964. SNDRV_PCM_FMTBIT_S24_LE |
  10965. SNDRV_PCM_FMTBIT_S32_LE,
  10966. .channels_min = 1,
  10967. .channels_max = 16,
  10968. .rate_min = 8000,
  10969. .rate_max = 352800,
  10970. },
  10971. .name = "QUIN_TDM_TX_2",
  10972. .ops = &msm_dai_q6_tdm_ops,
  10973. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  10974. .probe = msm_dai_q6_dai_tdm_probe,
  10975. .remove = msm_dai_q6_dai_tdm_remove,
  10976. },
  10977. {
  10978. .capture = {
  10979. .stream_name = "Quinary TDM3 Capture",
  10980. .aif_name = "QUIN_TDM_TX_3",
  10981. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10982. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10983. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10984. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10985. SNDRV_PCM_FMTBIT_S24_LE |
  10986. SNDRV_PCM_FMTBIT_S32_LE,
  10987. .channels_min = 1,
  10988. .channels_max = 16,
  10989. .rate_min = 8000,
  10990. .rate_max = 352800,
  10991. },
  10992. .name = "QUIN_TDM_TX_3",
  10993. .ops = &msm_dai_q6_tdm_ops,
  10994. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  10995. .probe = msm_dai_q6_dai_tdm_probe,
  10996. .remove = msm_dai_q6_dai_tdm_remove,
  10997. },
  10998. {
  10999. .capture = {
  11000. .stream_name = "Quinary TDM4 Capture",
  11001. .aif_name = "QUIN_TDM_TX_4",
  11002. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11003. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11004. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11005. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11006. SNDRV_PCM_FMTBIT_S24_LE |
  11007. SNDRV_PCM_FMTBIT_S32_LE,
  11008. .channels_min = 1,
  11009. .channels_max = 16,
  11010. .rate_min = 8000,
  11011. .rate_max = 352800,
  11012. },
  11013. .name = "QUIN_TDM_TX_4",
  11014. .ops = &msm_dai_q6_tdm_ops,
  11015. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  11016. .probe = msm_dai_q6_dai_tdm_probe,
  11017. .remove = msm_dai_q6_dai_tdm_remove,
  11018. },
  11019. {
  11020. .capture = {
  11021. .stream_name = "Quinary TDM5 Capture",
  11022. .aif_name = "QUIN_TDM_TX_5",
  11023. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11024. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11025. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11026. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11027. SNDRV_PCM_FMTBIT_S24_LE |
  11028. SNDRV_PCM_FMTBIT_S32_LE,
  11029. .channels_min = 1,
  11030. .channels_max = 16,
  11031. .rate_min = 8000,
  11032. .rate_max = 352800,
  11033. },
  11034. .name = "QUIN_TDM_TX_5",
  11035. .ops = &msm_dai_q6_tdm_ops,
  11036. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  11037. .probe = msm_dai_q6_dai_tdm_probe,
  11038. .remove = msm_dai_q6_dai_tdm_remove,
  11039. },
  11040. {
  11041. .capture = {
  11042. .stream_name = "Quinary TDM6 Capture",
  11043. .aif_name = "QUIN_TDM_TX_6",
  11044. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11045. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11046. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11047. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11048. SNDRV_PCM_FMTBIT_S24_LE |
  11049. SNDRV_PCM_FMTBIT_S32_LE,
  11050. .channels_min = 1,
  11051. .channels_max = 16,
  11052. .rate_min = 8000,
  11053. .rate_max = 352800,
  11054. },
  11055. .name = "QUIN_TDM_TX_6",
  11056. .ops = &msm_dai_q6_tdm_ops,
  11057. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  11058. .probe = msm_dai_q6_dai_tdm_probe,
  11059. .remove = msm_dai_q6_dai_tdm_remove,
  11060. },
  11061. {
  11062. .capture = {
  11063. .stream_name = "Quinary TDM7 Capture",
  11064. .aif_name = "QUIN_TDM_TX_7",
  11065. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11066. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11067. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11068. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11069. SNDRV_PCM_FMTBIT_S24_LE |
  11070. SNDRV_PCM_FMTBIT_S32_LE,
  11071. .channels_min = 1,
  11072. .channels_max = 16,
  11073. .rate_min = 8000,
  11074. .rate_max = 352800,
  11075. },
  11076. .name = "QUIN_TDM_TX_7",
  11077. .ops = &msm_dai_q6_tdm_ops,
  11078. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  11079. .probe = msm_dai_q6_dai_tdm_probe,
  11080. .remove = msm_dai_q6_dai_tdm_remove,
  11081. },
  11082. {
  11083. .playback = {
  11084. .stream_name = "Senary TDM0 Playback",
  11085. .aif_name = "SEN_TDM_RX_0",
  11086. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11087. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11088. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11089. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11090. SNDRV_PCM_FMTBIT_S24_LE |
  11091. SNDRV_PCM_FMTBIT_S32_LE,
  11092. .channels_min = 1,
  11093. .channels_max = 8,
  11094. .rate_min = 8000,
  11095. .rate_max = 352800,
  11096. },
  11097. .name = "SEN_TDM_RX_0",
  11098. .ops = &msm_dai_q6_tdm_ops,
  11099. .id = AFE_PORT_ID_SENARY_TDM_RX,
  11100. .probe = msm_dai_q6_dai_tdm_probe,
  11101. .remove = msm_dai_q6_dai_tdm_remove,
  11102. },
  11103. {
  11104. .playback = {
  11105. .stream_name = "Senary TDM1 Playback",
  11106. .aif_name = "SEN_TDM_RX_1",
  11107. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11108. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11109. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11110. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11111. SNDRV_PCM_FMTBIT_S24_LE |
  11112. SNDRV_PCM_FMTBIT_S32_LE,
  11113. .channels_min = 1,
  11114. .channels_max = 8,
  11115. .rate_min = 8000,
  11116. .rate_max = 352800,
  11117. },
  11118. .name = "SEN_TDM_RX_1",
  11119. .ops = &msm_dai_q6_tdm_ops,
  11120. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  11121. .probe = msm_dai_q6_dai_tdm_probe,
  11122. .remove = msm_dai_q6_dai_tdm_remove,
  11123. },
  11124. {
  11125. .playback = {
  11126. .stream_name = "Senary TDM2 Playback",
  11127. .aif_name = "SEN_TDM_RX_2",
  11128. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11129. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11130. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11131. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11132. SNDRV_PCM_FMTBIT_S24_LE |
  11133. SNDRV_PCM_FMTBIT_S32_LE,
  11134. .channels_min = 1,
  11135. .channels_max = 8,
  11136. .rate_min = 8000,
  11137. .rate_max = 352800,
  11138. },
  11139. .name = "SEN_TDM_RX_2",
  11140. .ops = &msm_dai_q6_tdm_ops,
  11141. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  11142. .probe = msm_dai_q6_dai_tdm_probe,
  11143. .remove = msm_dai_q6_dai_tdm_remove,
  11144. },
  11145. {
  11146. .playback = {
  11147. .stream_name = "Senary TDM3 Playback",
  11148. .aif_name = "SEN_TDM_RX_3",
  11149. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11150. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11151. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11152. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11153. SNDRV_PCM_FMTBIT_S24_LE |
  11154. SNDRV_PCM_FMTBIT_S32_LE,
  11155. .channels_min = 1,
  11156. .channels_max = 8,
  11157. .rate_min = 8000,
  11158. .rate_max = 352800,
  11159. },
  11160. .name = "SEN_TDM_RX_3",
  11161. .ops = &msm_dai_q6_tdm_ops,
  11162. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  11163. .probe = msm_dai_q6_dai_tdm_probe,
  11164. .remove = msm_dai_q6_dai_tdm_remove,
  11165. },
  11166. {
  11167. .playback = {
  11168. .stream_name = "Senary TDM4 Playback",
  11169. .aif_name = "SEN_TDM_RX_4",
  11170. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11171. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11172. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11173. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11174. SNDRV_PCM_FMTBIT_S24_LE |
  11175. SNDRV_PCM_FMTBIT_S32_LE,
  11176. .channels_min = 1,
  11177. .channels_max = 8,
  11178. .rate_min = 8000,
  11179. .rate_max = 352800,
  11180. },
  11181. .name = "SEN_TDM_RX_4",
  11182. .ops = &msm_dai_q6_tdm_ops,
  11183. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  11184. .probe = msm_dai_q6_dai_tdm_probe,
  11185. .remove = msm_dai_q6_dai_tdm_remove,
  11186. },
  11187. {
  11188. .playback = {
  11189. .stream_name = "Senary TDM5 Playback",
  11190. .aif_name = "SEN_TDM_RX_5",
  11191. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11192. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11193. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11194. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11195. SNDRV_PCM_FMTBIT_S24_LE |
  11196. SNDRV_PCM_FMTBIT_S32_LE,
  11197. .channels_min = 1,
  11198. .channels_max = 8,
  11199. .rate_min = 8000,
  11200. .rate_max = 352800,
  11201. },
  11202. .name = "SEN_TDM_RX_5",
  11203. .ops = &msm_dai_q6_tdm_ops,
  11204. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  11205. .probe = msm_dai_q6_dai_tdm_probe,
  11206. .remove = msm_dai_q6_dai_tdm_remove,
  11207. },
  11208. {
  11209. .playback = {
  11210. .stream_name = "Senary TDM6 Playback",
  11211. .aif_name = "SEN_TDM_RX_6",
  11212. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11213. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11214. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11215. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11216. SNDRV_PCM_FMTBIT_S24_LE |
  11217. SNDRV_PCM_FMTBIT_S32_LE,
  11218. .channels_min = 1,
  11219. .channels_max = 8,
  11220. .rate_min = 8000,
  11221. .rate_max = 352800,
  11222. },
  11223. .name = "SEN_TDM_RX_6",
  11224. .ops = &msm_dai_q6_tdm_ops,
  11225. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  11226. .probe = msm_dai_q6_dai_tdm_probe,
  11227. .remove = msm_dai_q6_dai_tdm_remove,
  11228. },
  11229. {
  11230. .playback = {
  11231. .stream_name = "Senary TDM7 Playback",
  11232. .aif_name = "SEN_TDM_RX_7",
  11233. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11234. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11235. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11236. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11237. SNDRV_PCM_FMTBIT_S24_LE |
  11238. SNDRV_PCM_FMTBIT_S32_LE,
  11239. .channels_min = 1,
  11240. .channels_max = 8,
  11241. .rate_min = 8000,
  11242. .rate_max = 352800,
  11243. },
  11244. .name = "SEN_TDM_RX_7",
  11245. .ops = &msm_dai_q6_tdm_ops,
  11246. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  11247. .probe = msm_dai_q6_dai_tdm_probe,
  11248. .remove = msm_dai_q6_dai_tdm_remove,
  11249. },
  11250. {
  11251. .capture = {
  11252. .stream_name = "Senary TDM0 Capture",
  11253. .aif_name = "SEN_TDM_TX_0",
  11254. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11255. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11256. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11257. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11258. SNDRV_PCM_FMTBIT_S24_LE |
  11259. SNDRV_PCM_FMTBIT_S32_LE,
  11260. .channels_min = 1,
  11261. .channels_max = 8,
  11262. .rate_min = 8000,
  11263. .rate_max = 352800,
  11264. },
  11265. .name = "SEN_TDM_TX_0",
  11266. .ops = &msm_dai_q6_tdm_ops,
  11267. .id = AFE_PORT_ID_SENARY_TDM_TX,
  11268. .probe = msm_dai_q6_dai_tdm_probe,
  11269. .remove = msm_dai_q6_dai_tdm_remove,
  11270. },
  11271. {
  11272. .capture = {
  11273. .stream_name = "Senary TDM1 Capture",
  11274. .aif_name = "SEN_TDM_TX_1",
  11275. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11276. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11277. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11278. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11279. SNDRV_PCM_FMTBIT_S24_LE |
  11280. SNDRV_PCM_FMTBIT_S32_LE,
  11281. .channels_min = 1,
  11282. .channels_max = 8,
  11283. .rate_min = 8000,
  11284. .rate_max = 352800,
  11285. },
  11286. .name = "SEN_TDM_TX_1",
  11287. .ops = &msm_dai_q6_tdm_ops,
  11288. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  11289. .probe = msm_dai_q6_dai_tdm_probe,
  11290. .remove = msm_dai_q6_dai_tdm_remove,
  11291. },
  11292. {
  11293. .capture = {
  11294. .stream_name = "Senary TDM2 Capture",
  11295. .aif_name = "SEN_TDM_TX_2",
  11296. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11297. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11298. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11299. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11300. SNDRV_PCM_FMTBIT_S24_LE |
  11301. SNDRV_PCM_FMTBIT_S32_LE,
  11302. .channels_min = 1,
  11303. .channels_max = 8,
  11304. .rate_min = 8000,
  11305. .rate_max = 352800,
  11306. },
  11307. .name = "SEN_TDM_TX_2",
  11308. .ops = &msm_dai_q6_tdm_ops,
  11309. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  11310. .probe = msm_dai_q6_dai_tdm_probe,
  11311. .remove = msm_dai_q6_dai_tdm_remove,
  11312. },
  11313. {
  11314. .capture = {
  11315. .stream_name = "Senary TDM3 Capture",
  11316. .aif_name = "SEN_TDM_TX_3",
  11317. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11318. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11319. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11320. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11321. SNDRV_PCM_FMTBIT_S24_LE |
  11322. SNDRV_PCM_FMTBIT_S32_LE,
  11323. .channels_min = 1,
  11324. .channels_max = 8,
  11325. .rate_min = 8000,
  11326. .rate_max = 352800,
  11327. },
  11328. .name = "SEN_TDM_TX_3",
  11329. .ops = &msm_dai_q6_tdm_ops,
  11330. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  11331. .probe = msm_dai_q6_dai_tdm_probe,
  11332. .remove = msm_dai_q6_dai_tdm_remove,
  11333. },
  11334. {
  11335. .capture = {
  11336. .stream_name = "Senary TDM4 Capture",
  11337. .aif_name = "SEN_TDM_TX_4",
  11338. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11339. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11340. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11341. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11342. SNDRV_PCM_FMTBIT_S24_LE |
  11343. SNDRV_PCM_FMTBIT_S32_LE,
  11344. .channels_min = 1,
  11345. .channels_max = 8,
  11346. .rate_min = 8000,
  11347. .rate_max = 352800,
  11348. },
  11349. .name = "SEN_TDM_TX_4",
  11350. .ops = &msm_dai_q6_tdm_ops,
  11351. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  11352. .probe = msm_dai_q6_dai_tdm_probe,
  11353. .remove = msm_dai_q6_dai_tdm_remove,
  11354. },
  11355. {
  11356. .capture = {
  11357. .stream_name = "Senary TDM5 Capture",
  11358. .aif_name = "SEN_TDM_TX_5",
  11359. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11360. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11361. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11362. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11363. SNDRV_PCM_FMTBIT_S24_LE |
  11364. SNDRV_PCM_FMTBIT_S32_LE,
  11365. .channels_min = 1,
  11366. .channels_max = 8,
  11367. .rate_min = 8000,
  11368. .rate_max = 352800,
  11369. },
  11370. .name = "SEN_TDM_TX_5",
  11371. .ops = &msm_dai_q6_tdm_ops,
  11372. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  11373. .probe = msm_dai_q6_dai_tdm_probe,
  11374. .remove = msm_dai_q6_dai_tdm_remove,
  11375. },
  11376. {
  11377. .capture = {
  11378. .stream_name = "Senary TDM6 Capture",
  11379. .aif_name = "SEN_TDM_TX_6",
  11380. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11381. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11382. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11383. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11384. SNDRV_PCM_FMTBIT_S24_LE |
  11385. SNDRV_PCM_FMTBIT_S32_LE,
  11386. .channels_min = 1,
  11387. .channels_max = 8,
  11388. .rate_min = 8000,
  11389. .rate_max = 352800,
  11390. },
  11391. .name = "SEN_TDM_TX_6",
  11392. .ops = &msm_dai_q6_tdm_ops,
  11393. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  11394. .probe = msm_dai_q6_dai_tdm_probe,
  11395. .remove = msm_dai_q6_dai_tdm_remove,
  11396. },
  11397. {
  11398. .capture = {
  11399. .stream_name = "Senary TDM7 Capture",
  11400. .aif_name = "SEN_TDM_TX_7",
  11401. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11402. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11403. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11404. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11405. SNDRV_PCM_FMTBIT_S24_LE |
  11406. SNDRV_PCM_FMTBIT_S32_LE,
  11407. .channels_min = 1,
  11408. .channels_max = 8,
  11409. .rate_min = 8000,
  11410. .rate_max = 352800,
  11411. },
  11412. .name = "SEN_TDM_TX_7",
  11413. .ops = &msm_dai_q6_tdm_ops,
  11414. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  11415. .probe = msm_dai_q6_dai_tdm_probe,
  11416. .remove = msm_dai_q6_dai_tdm_remove,
  11417. },
  11418. };
  11419. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  11420. .name = "msm-dai-q6-tdm",
  11421. };
  11422. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  11423. {
  11424. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  11425. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  11426. int rc = 0;
  11427. u32 tdm_dev_id = 0;
  11428. int port_idx = 0;
  11429. struct device_node *tdm_parent_node = NULL;
  11430. /* retrieve device/afe id */
  11431. rc = of_property_read_u32(pdev->dev.of_node,
  11432. "qcom,msm-cpudai-tdm-dev-id",
  11433. &tdm_dev_id);
  11434. if (rc) {
  11435. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  11436. __func__);
  11437. goto rtn;
  11438. }
  11439. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  11440. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  11441. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  11442. __func__, tdm_dev_id);
  11443. rc = -ENXIO;
  11444. goto rtn;
  11445. }
  11446. pdev->id = tdm_dev_id;
  11447. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  11448. GFP_KERNEL);
  11449. if (!dai_data) {
  11450. rc = -ENOMEM;
  11451. dev_err(&pdev->dev,
  11452. "%s Failed to allocate memory for tdm dai_data\n",
  11453. __func__);
  11454. goto rtn;
  11455. }
  11456. memset(dai_data, 0, sizeof(*dai_data));
  11457. rc = of_property_read_u32(pdev->dev.of_node,
  11458. "qcom,msm-dai-is-island-supported",
  11459. &dai_data->is_island_dai);
  11460. if (rc)
  11461. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11462. /* TDM CFG */
  11463. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  11464. rc = of_property_read_u32(tdm_parent_node,
  11465. "qcom,msm-cpudai-tdm-sync-mode",
  11466. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  11467. if (rc) {
  11468. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  11469. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  11470. goto free_dai_data;
  11471. }
  11472. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  11473. __func__, dai_data->port_cfg.tdm.sync_mode);
  11474. rc = of_property_read_u32(tdm_parent_node,
  11475. "qcom,msm-cpudai-tdm-sync-src",
  11476. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  11477. if (rc) {
  11478. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  11479. __func__, "qcom,msm-cpudai-tdm-sync-src");
  11480. goto free_dai_data;
  11481. }
  11482. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  11483. __func__, dai_data->port_cfg.tdm.sync_src);
  11484. rc = of_property_read_u32(tdm_parent_node,
  11485. "qcom,msm-cpudai-tdm-data-out",
  11486. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11487. if (rc) {
  11488. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  11489. __func__, "qcom,msm-cpudai-tdm-data-out");
  11490. goto free_dai_data;
  11491. }
  11492. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  11493. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11494. rc = of_property_read_u32(tdm_parent_node,
  11495. "qcom,msm-cpudai-tdm-invert-sync",
  11496. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11497. if (rc) {
  11498. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  11499. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  11500. goto free_dai_data;
  11501. }
  11502. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  11503. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11504. rc = of_property_read_u32(tdm_parent_node,
  11505. "qcom,msm-cpudai-tdm-data-delay",
  11506. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11507. if (rc) {
  11508. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  11509. __func__, "qcom,msm-cpudai-tdm-data-delay");
  11510. goto free_dai_data;
  11511. }
  11512. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  11513. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11514. /* TDM CFG -- set default */
  11515. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  11516. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  11517. AFE_API_VERSION_TDM_CONFIG;
  11518. /* TDM SLOT MAPPING CFG */
  11519. rc = of_property_read_u32(pdev->dev.of_node,
  11520. "qcom,msm-cpudai-tdm-data-align",
  11521. &dai_data->port_cfg.slot_mapping.data_align_type);
  11522. if (rc) {
  11523. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  11524. __func__,
  11525. "qcom,msm-cpudai-tdm-data-align");
  11526. goto free_dai_data;
  11527. }
  11528. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  11529. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  11530. /* TDM SLOT MAPPING CFG -- set default */
  11531. dai_data->port_cfg.slot_mapping.minor_version =
  11532. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  11533. dai_data->port_cfg.slot_mapping_v2.minor_version =
  11534. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  11535. /* CUSTOM TDM HEADER CFG */
  11536. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  11537. if (of_find_property(pdev->dev.of_node,
  11538. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  11539. of_find_property(pdev->dev.of_node,
  11540. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  11541. of_find_property(pdev->dev.of_node,
  11542. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  11543. /* if the property exist */
  11544. rc = of_property_read_u32(pdev->dev.of_node,
  11545. "qcom,msm-cpudai-tdm-header-start-offset",
  11546. (u32 *)&custom_tdm_header->start_offset);
  11547. if (rc) {
  11548. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  11549. __func__,
  11550. "qcom,msm-cpudai-tdm-header-start-offset");
  11551. goto free_dai_data;
  11552. }
  11553. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  11554. __func__, custom_tdm_header->start_offset);
  11555. rc = of_property_read_u32(pdev->dev.of_node,
  11556. "qcom,msm-cpudai-tdm-header-width",
  11557. (u32 *)&custom_tdm_header->header_width);
  11558. if (rc) {
  11559. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  11560. __func__, "qcom,msm-cpudai-tdm-header-width");
  11561. goto free_dai_data;
  11562. }
  11563. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  11564. __func__, custom_tdm_header->header_width);
  11565. rc = of_property_read_u32(pdev->dev.of_node,
  11566. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  11567. (u32 *)&custom_tdm_header->num_frame_repeat);
  11568. if (rc) {
  11569. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  11570. __func__,
  11571. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  11572. goto free_dai_data;
  11573. }
  11574. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  11575. __func__, custom_tdm_header->num_frame_repeat);
  11576. /* CUSTOM TDM HEADER CFG -- set default */
  11577. custom_tdm_header->minor_version =
  11578. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  11579. custom_tdm_header->header_type =
  11580. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11581. } else {
  11582. /* CUSTOM TDM HEADER CFG -- set default */
  11583. custom_tdm_header->header_type =
  11584. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11585. /* proceed with probe */
  11586. }
  11587. /* copy static clk per parent node */
  11588. dai_data->clk_set = tdm_clk_set;
  11589. /* copy static group cfg per parent node */
  11590. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  11591. /* copy static num group ports per parent node */
  11592. dai_data->num_group_ports = num_tdm_group_ports;
  11593. dai_data->lane_cfg = tdm_lane_cfg;
  11594. dev_set_drvdata(&pdev->dev, dai_data);
  11595. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  11596. if (port_idx < 0) {
  11597. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  11598. __func__, tdm_dev_id);
  11599. rc = -EINVAL;
  11600. goto free_dai_data;
  11601. }
  11602. rc = snd_soc_register_component(&pdev->dev,
  11603. &msm_q6_tdm_dai_component,
  11604. &msm_dai_q6_tdm_dai[port_idx], 1);
  11605. if (rc) {
  11606. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  11607. __func__, tdm_dev_id, rc);
  11608. goto err_register;
  11609. }
  11610. return 0;
  11611. err_register:
  11612. free_dai_data:
  11613. kfree(dai_data);
  11614. rtn:
  11615. return rc;
  11616. }
  11617. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  11618. {
  11619. struct msm_dai_q6_tdm_dai_data *dai_data =
  11620. dev_get_drvdata(&pdev->dev);
  11621. snd_soc_unregister_component(&pdev->dev);
  11622. kfree(dai_data);
  11623. return 0;
  11624. }
  11625. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  11626. { .compatible = "qcom,msm-dai-q6-tdm", },
  11627. {}
  11628. };
  11629. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  11630. static struct platform_driver msm_dai_q6_tdm_driver = {
  11631. .probe = msm_dai_q6_tdm_dev_probe,
  11632. .remove = msm_dai_q6_tdm_dev_remove,
  11633. .driver = {
  11634. .name = "msm-dai-q6-tdm",
  11635. .owner = THIS_MODULE,
  11636. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  11637. .suppress_bind_attrs = true,
  11638. },
  11639. };
  11640. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  11641. struct snd_ctl_elem_value *ucontrol)
  11642. {
  11643. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11644. int value = ucontrol->value.integer.value[0];
  11645. dai_data->port_config.cdc_dma.data_format = value;
  11646. pr_debug("%s: format = %d\n", __func__, value);
  11647. return 0;
  11648. }
  11649. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  11650. struct snd_ctl_elem_value *ucontrol)
  11651. {
  11652. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11653. ucontrol->value.integer.value[0] =
  11654. dai_data->port_config.cdc_dma.data_format;
  11655. return 0;
  11656. }
  11657. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  11658. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  11659. msm_dai_q6_cdc_dma_format_get,
  11660. msm_dai_q6_cdc_dma_format_put),
  11661. SOC_ENUM_EXT("WSA_CDC_DMA_0 RX XTLoggingDisable",
  11662. xt_logging_disable_enum[0],
  11663. msm_dai_q6_cdc_dma_xt_logging_disable_get,
  11664. msm_dai_q6_cdc_dma_xt_logging_disable_put),
  11665. };
  11666. /* SOC probe for codec DMA interface */
  11667. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  11668. {
  11669. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11670. int rc = 0;
  11671. if (!dai) {
  11672. pr_err("%s: Invalid params dai\n", __func__);
  11673. return -EINVAL;
  11674. }
  11675. if (!dai->dev) {
  11676. pr_err("%s: Invalid params dai dev\n", __func__);
  11677. return -EINVAL;
  11678. }
  11679. msm_dai_q6_set_dai_id(dai);
  11680. dai_data = dev_get_drvdata(dai->dev);
  11681. switch (dai->id) {
  11682. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11683. rc = snd_ctl_add(dai->component->card->snd_card,
  11684. snd_ctl_new1(&cdc_dma_config_controls[0],
  11685. dai_data));
  11686. break;
  11687. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11688. rc = snd_ctl_add(dai->component->card->snd_card,
  11689. snd_ctl_new1(&cdc_dma_config_controls[1],
  11690. dai_data));
  11691. break;
  11692. default:
  11693. break;
  11694. }
  11695. if (rc < 0)
  11696. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  11697. __func__, dai->name);
  11698. if (dai_data->is_island_dai)
  11699. rc = msm_dai_q6_add_island_mx_ctls(
  11700. dai->component->card->snd_card,
  11701. dai->name, dai->id,
  11702. (void *)dai_data);
  11703. rc = msm_dai_q6_add_power_mode_mx_ctls(
  11704. dai->component->card->snd_card,
  11705. dai->name, dai->id,
  11706. (void *)dai_data);
  11707. rc= msm_dai_q6_add_isconfig_config_mx_ctls(
  11708. dai->component->card->snd_card,
  11709. dai->name, dai->id,
  11710. (void *)dai_data);
  11711. rc = msm_dai_q6_dai_add_route(dai);
  11712. return rc;
  11713. }
  11714. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  11715. {
  11716. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11717. dev_get_drvdata(dai->dev);
  11718. int rc = 0;
  11719. /* If AFE port is still up, close it */
  11720. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11721. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  11722. dai->id);
  11723. rc = afe_close(dai->id); /* can block */
  11724. if (rc < 0)
  11725. dev_err(dai->dev, "fail to close AFE port\n");
  11726. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11727. }
  11728. return rc;
  11729. }
  11730. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  11731. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  11732. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  11733. {
  11734. int rc = 0;
  11735. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11736. dev_get_drvdata(dai->dev);
  11737. unsigned int ch_mask = 0, ch_num = 0;
  11738. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  11739. switch (dai->id) {
  11740. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11741. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  11742. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  11743. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  11744. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  11745. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  11746. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  11747. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  11748. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  11749. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  11750. if (!rx_ch_mask) {
  11751. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  11752. return -EINVAL;
  11753. }
  11754. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11755. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  11756. __func__, rx_num_ch);
  11757. return -EINVAL;
  11758. }
  11759. ch_mask = *rx_ch_mask;
  11760. ch_num = rx_num_ch;
  11761. break;
  11762. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11763. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  11764. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  11765. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  11766. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  11767. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  11768. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  11769. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  11770. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  11771. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  11772. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  11773. if (!tx_ch_mask) {
  11774. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  11775. return -EINVAL;
  11776. }
  11777. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11778. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  11779. __func__, tx_num_ch);
  11780. return -EINVAL;
  11781. }
  11782. ch_mask = *tx_ch_mask;
  11783. ch_num = tx_num_ch;
  11784. break;
  11785. default:
  11786. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  11787. return -EINVAL;
  11788. }
  11789. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  11790. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  11791. dai->id, ch_num, ch_mask);
  11792. return rc;
  11793. }
  11794. static int msm_dai_q6_cdc_dma_hw_params(
  11795. struct snd_pcm_substream *substream,
  11796. struct snd_pcm_hw_params *params,
  11797. struct snd_soc_dai *dai)
  11798. {
  11799. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11800. dev_get_drvdata(dai->dev);
  11801. switch (params_format(params)) {
  11802. case SNDRV_PCM_FORMAT_S16_LE:
  11803. case SNDRV_PCM_FORMAT_SPECIAL:
  11804. dai_data->port_config.cdc_dma.bit_width = 16;
  11805. break;
  11806. case SNDRV_PCM_FORMAT_S24_LE:
  11807. case SNDRV_PCM_FORMAT_S24_3LE:
  11808. dai_data->port_config.cdc_dma.bit_width = 24;
  11809. break;
  11810. case SNDRV_PCM_FORMAT_S32_LE:
  11811. dai_data->port_config.cdc_dma.bit_width = 32;
  11812. break;
  11813. default:
  11814. dev_err(dai->dev, "%s: format %d\n",
  11815. __func__, params_format(params));
  11816. return -EINVAL;
  11817. }
  11818. dai_data->rate = params_rate(params);
  11819. dai_data->channels = params_channels(params);
  11820. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  11821. AFE_API_VERSION_CODEC_DMA_CONFIG;
  11822. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  11823. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  11824. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  11825. "num_channel %hu sample_rate %d\n", __func__,
  11826. dai_data->port_config.cdc_dma.bit_width,
  11827. dai_data->port_config.cdc_dma.data_format,
  11828. dai_data->port_config.cdc_dma.num_channels,
  11829. dai_data->rate);
  11830. return 0;
  11831. }
  11832. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  11833. struct snd_soc_dai *dai)
  11834. {
  11835. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11836. dev_get_drvdata(dai->dev);
  11837. int rc = 0;
  11838. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11839. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  11840. (dai_data->port_config.cdc_dma.data_format == 1))
  11841. dai_data->port_config.cdc_dma.data_format =
  11842. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  11843. if (dai_data->cdc_dma_data_align) {
  11844. rc = afe_send_cdc_dma_data_align(dai->id,
  11845. dai_data->cdc_dma_data_align);
  11846. if (rc)
  11847. pr_debug("%s: afe send data alignment failed %d\n",
  11848. __func__, rc);
  11849. }
  11850. rc = afe_port_start(dai->id, &dai_data->port_config,
  11851. dai_data->rate);
  11852. if (rc < 0)
  11853. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  11854. dai->id);
  11855. else
  11856. set_bit(STATUS_PORT_STARTED,
  11857. dai_data->status_mask);
  11858. }
  11859. return rc;
  11860. }
  11861. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  11862. struct snd_soc_dai *dai)
  11863. {
  11864. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11865. dev_get_drvdata(dai->dev);
  11866. int rc = 0;
  11867. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11868. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  11869. dai->id);
  11870. rc = afe_close(dai->id); /* can block */
  11871. if (rc < 0)
  11872. dev_err(dai->dev, "fail to close AFE port\n");
  11873. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  11874. *dai_data->status_mask);
  11875. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11876. }
  11877. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  11878. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  11879. }
  11880. static int msm_dai_q6_cdc_dma_digital_mute(struct snd_soc_dai *dai,
  11881. int mute)
  11882. {
  11883. int port_id = dai->id;
  11884. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11885. dev_get_drvdata(dai->dev);
  11886. if (mute && !dai_data->xt_logging_disable)
  11887. afe_get_sp_xt_logging_data(port_id);
  11888. return 0;
  11889. }
  11890. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  11891. .prepare = msm_dai_q6_cdc_dma_prepare,
  11892. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11893. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11894. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11895. };
  11896. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  11897. .prepare = msm_dai_q6_cdc_dma_prepare,
  11898. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11899. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11900. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11901. .digital_mute = msm_dai_q6_cdc_dma_digital_mute,
  11902. };
  11903. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  11904. {
  11905. .playback = {
  11906. .stream_name = "WSA CDC DMA0 Playback",
  11907. .aif_name = "WSA_CDC_DMA_RX_0",
  11908. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11909. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11910. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11911. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11912. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11913. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11914. SNDRV_PCM_RATE_384000,
  11915. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11916. SNDRV_PCM_FMTBIT_S24_LE |
  11917. SNDRV_PCM_FMTBIT_S24_3LE |
  11918. SNDRV_PCM_FMTBIT_S32_LE,
  11919. .channels_min = 1,
  11920. .channels_max = 4,
  11921. .rate_min = 8000,
  11922. .rate_max = 384000,
  11923. },
  11924. .name = "WSA_CDC_DMA_RX_0",
  11925. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11926. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  11927. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11928. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11929. },
  11930. {
  11931. .capture = {
  11932. .stream_name = "WSA CDC DMA0 Capture",
  11933. .aif_name = "WSA_CDC_DMA_TX_0",
  11934. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11935. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11936. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11937. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11938. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11939. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11940. SNDRV_PCM_RATE_384000,
  11941. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11942. SNDRV_PCM_FMTBIT_S24_LE |
  11943. SNDRV_PCM_FMTBIT_S24_3LE |
  11944. SNDRV_PCM_FMTBIT_S32_LE,
  11945. .channels_min = 1,
  11946. .channels_max = 4,
  11947. .rate_min = 8000,
  11948. .rate_max = 384000,
  11949. },
  11950. .name = "WSA_CDC_DMA_TX_0",
  11951. .ops = &msm_dai_q6_cdc_dma_ops,
  11952. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  11953. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11954. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11955. },
  11956. {
  11957. .playback = {
  11958. .stream_name = "WSA CDC DMA1 Playback",
  11959. .aif_name = "WSA_CDC_DMA_RX_1",
  11960. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11961. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11962. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11963. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11964. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11965. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11966. SNDRV_PCM_RATE_384000,
  11967. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11968. SNDRV_PCM_FMTBIT_S24_LE |
  11969. SNDRV_PCM_FMTBIT_S24_3LE |
  11970. SNDRV_PCM_FMTBIT_S32_LE,
  11971. .channels_min = 1,
  11972. .channels_max = 2,
  11973. .rate_min = 8000,
  11974. .rate_max = 384000,
  11975. },
  11976. .name = "WSA_CDC_DMA_RX_1",
  11977. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11978. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  11979. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11980. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11981. },
  11982. {
  11983. .capture = {
  11984. .stream_name = "WSA CDC DMA1 Capture",
  11985. .aif_name = "WSA_CDC_DMA_TX_1",
  11986. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11987. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11988. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11989. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11990. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11991. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11992. SNDRV_PCM_RATE_384000,
  11993. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11994. SNDRV_PCM_FMTBIT_S24_LE |
  11995. SNDRV_PCM_FMTBIT_S24_3LE |
  11996. SNDRV_PCM_FMTBIT_S32_LE,
  11997. .channels_min = 1,
  11998. .channels_max = 2,
  11999. .rate_min = 8000,
  12000. .rate_max = 384000,
  12001. },
  12002. .name = "WSA_CDC_DMA_TX_1",
  12003. .ops = &msm_dai_q6_cdc_dma_ops,
  12004. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  12005. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12006. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12007. },
  12008. {
  12009. .capture = {
  12010. .stream_name = "WSA CDC DMA2 Capture",
  12011. .aif_name = "WSA_CDC_DMA_TX_2",
  12012. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12013. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12014. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12015. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12016. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12017. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12018. SNDRV_PCM_RATE_384000,
  12019. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12020. SNDRV_PCM_FMTBIT_S24_LE |
  12021. SNDRV_PCM_FMTBIT_S24_3LE |
  12022. SNDRV_PCM_FMTBIT_S32_LE,
  12023. .channels_min = 1,
  12024. .channels_max = 1,
  12025. .rate_min = 8000,
  12026. .rate_max = 384000,
  12027. },
  12028. .name = "WSA_CDC_DMA_TX_2",
  12029. .ops = &msm_dai_q6_cdc_dma_ops,
  12030. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  12031. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12032. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12033. },
  12034. {
  12035. .capture = {
  12036. .stream_name = "VA CDC DMA0 Capture",
  12037. .aif_name = "VA_CDC_DMA_TX_0",
  12038. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12039. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12040. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12041. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12042. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12043. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12044. SNDRV_PCM_RATE_384000,
  12045. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12046. SNDRV_PCM_FMTBIT_S24_LE |
  12047. SNDRV_PCM_FMTBIT_S24_3LE,
  12048. .channels_min = 1,
  12049. .channels_max = 8,
  12050. .rate_min = 8000,
  12051. .rate_max = 384000,
  12052. },
  12053. .name = "VA_CDC_DMA_TX_0",
  12054. .ops = &msm_dai_q6_cdc_dma_ops,
  12055. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  12056. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12057. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12058. },
  12059. {
  12060. .capture = {
  12061. .stream_name = "VA CDC DMA1 Capture",
  12062. .aif_name = "VA_CDC_DMA_TX_1",
  12063. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12064. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12065. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12066. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12067. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12068. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12069. SNDRV_PCM_RATE_384000,
  12070. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12071. SNDRV_PCM_FMTBIT_S24_LE |
  12072. SNDRV_PCM_FMTBIT_S24_3LE,
  12073. .channels_min = 1,
  12074. .channels_max = 8,
  12075. .rate_min = 8000,
  12076. .rate_max = 384000,
  12077. },
  12078. .name = "VA_CDC_DMA_TX_1",
  12079. .ops = &msm_dai_q6_cdc_dma_ops,
  12080. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  12081. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12082. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12083. },
  12084. {
  12085. .capture = {
  12086. .stream_name = "VA CDC DMA2 Capture",
  12087. .aif_name = "VA_CDC_DMA_TX_2",
  12088. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12089. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12090. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12091. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12092. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12093. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12094. SNDRV_PCM_RATE_384000,
  12095. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12096. SNDRV_PCM_FMTBIT_S24_LE |
  12097. SNDRV_PCM_FMTBIT_S24_3LE,
  12098. .channels_min = 1,
  12099. .channels_max = 8,
  12100. .rate_min = 8000,
  12101. .rate_max = 384000,
  12102. },
  12103. .name = "VA_CDC_DMA_TX_2",
  12104. .ops = &msm_dai_q6_cdc_dma_ops,
  12105. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  12106. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12107. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12108. },
  12109. {
  12110. .playback = {
  12111. .stream_name = "RX CDC DMA0 Playback",
  12112. .aif_name = "RX_CDC_DMA_RX_0",
  12113. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12114. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12115. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12116. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12117. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12118. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12119. SNDRV_PCM_RATE_384000,
  12120. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12121. SNDRV_PCM_FMTBIT_S24_LE |
  12122. SNDRV_PCM_FMTBIT_S24_3LE |
  12123. SNDRV_PCM_FMTBIT_S32_LE,
  12124. .channels_min = 1,
  12125. .channels_max = 2,
  12126. .rate_min = 8000,
  12127. .rate_max = 384000,
  12128. },
  12129. .name = "RX_CDC_DMA_RX_0",
  12130. .ops = &msm_dai_q6_cdc_dma_ops,
  12131. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  12132. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12133. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12134. },
  12135. {
  12136. .capture = {
  12137. .stream_name = "TX CDC DMA0 Capture",
  12138. .aif_name = "TX_CDC_DMA_TX_0",
  12139. .rates = SNDRV_PCM_RATE_8000 |
  12140. SNDRV_PCM_RATE_16000 |
  12141. SNDRV_PCM_RATE_32000 |
  12142. SNDRV_PCM_RATE_48000 |
  12143. SNDRV_PCM_RATE_96000 |
  12144. SNDRV_PCM_RATE_192000 |
  12145. SNDRV_PCM_RATE_384000,
  12146. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12147. SNDRV_PCM_FMTBIT_S24_LE |
  12148. SNDRV_PCM_FMTBIT_S24_3LE |
  12149. SNDRV_PCM_FMTBIT_S32_LE,
  12150. .channels_min = 1,
  12151. .channels_max = 3,
  12152. .rate_min = 8000,
  12153. .rate_max = 384000,
  12154. },
  12155. .name = "TX_CDC_DMA_TX_0",
  12156. .ops = &msm_dai_q6_cdc_dma_ops,
  12157. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  12158. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12159. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12160. },
  12161. {
  12162. .playback = {
  12163. .stream_name = "RX CDC DMA1 Playback",
  12164. .aif_name = "RX_CDC_DMA_RX_1",
  12165. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12166. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12167. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12168. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12169. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12170. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12171. SNDRV_PCM_RATE_384000,
  12172. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12173. SNDRV_PCM_FMTBIT_S24_LE |
  12174. SNDRV_PCM_FMTBIT_S24_3LE |
  12175. SNDRV_PCM_FMTBIT_S32_LE,
  12176. .channels_min = 1,
  12177. .channels_max = 2,
  12178. .rate_min = 8000,
  12179. .rate_max = 384000,
  12180. },
  12181. .name = "RX_CDC_DMA_RX_1",
  12182. .ops = &msm_dai_q6_cdc_dma_ops,
  12183. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  12184. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12185. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12186. },
  12187. {
  12188. .capture = {
  12189. .stream_name = "TX CDC DMA1 Capture",
  12190. .aif_name = "TX_CDC_DMA_TX_1",
  12191. .rates = SNDRV_PCM_RATE_8000 |
  12192. SNDRV_PCM_RATE_16000 |
  12193. SNDRV_PCM_RATE_32000 |
  12194. SNDRV_PCM_RATE_48000 |
  12195. SNDRV_PCM_RATE_96000 |
  12196. SNDRV_PCM_RATE_192000 |
  12197. SNDRV_PCM_RATE_384000,
  12198. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12199. SNDRV_PCM_FMTBIT_S24_LE |
  12200. SNDRV_PCM_FMTBIT_S24_3LE |
  12201. SNDRV_PCM_FMTBIT_S32_LE,
  12202. .channels_min = 1,
  12203. .channels_max = 3,
  12204. .rate_min = 8000,
  12205. .rate_max = 384000,
  12206. },
  12207. .name = "TX_CDC_DMA_TX_1",
  12208. .ops = &msm_dai_q6_cdc_dma_ops,
  12209. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  12210. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12211. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12212. },
  12213. {
  12214. .playback = {
  12215. .stream_name = "RX CDC DMA2 Playback",
  12216. .aif_name = "RX_CDC_DMA_RX_2",
  12217. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12218. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12219. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12220. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12221. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12222. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12223. SNDRV_PCM_RATE_384000,
  12224. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12225. SNDRV_PCM_FMTBIT_S24_LE |
  12226. SNDRV_PCM_FMTBIT_S24_3LE |
  12227. SNDRV_PCM_FMTBIT_S32_LE,
  12228. .channels_min = 1,
  12229. .channels_max = 1,
  12230. .rate_min = 8000,
  12231. .rate_max = 384000,
  12232. },
  12233. .name = "RX_CDC_DMA_RX_2",
  12234. .ops = &msm_dai_q6_cdc_dma_ops,
  12235. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  12236. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12237. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12238. },
  12239. {
  12240. .capture = {
  12241. .stream_name = "TX CDC DMA2 Capture",
  12242. .aif_name = "TX_CDC_DMA_TX_2",
  12243. .rates = SNDRV_PCM_RATE_8000 |
  12244. SNDRV_PCM_RATE_16000 |
  12245. SNDRV_PCM_RATE_32000 |
  12246. SNDRV_PCM_RATE_48000 |
  12247. SNDRV_PCM_RATE_96000 |
  12248. SNDRV_PCM_RATE_192000 |
  12249. SNDRV_PCM_RATE_384000,
  12250. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12251. SNDRV_PCM_FMTBIT_S24_LE |
  12252. SNDRV_PCM_FMTBIT_S24_3LE |
  12253. SNDRV_PCM_FMTBIT_S32_LE,
  12254. .channels_min = 1,
  12255. .channels_max = 4,
  12256. .rate_min = 8000,
  12257. .rate_max = 384000,
  12258. },
  12259. .name = "TX_CDC_DMA_TX_2",
  12260. .ops = &msm_dai_q6_cdc_dma_ops,
  12261. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  12262. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12263. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12264. }, {
  12265. .playback = {
  12266. .stream_name = "RX CDC DMA3 Playback",
  12267. .aif_name = "RX_CDC_DMA_RX_3",
  12268. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12269. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12270. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12271. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12272. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12273. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12274. SNDRV_PCM_RATE_384000,
  12275. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12276. SNDRV_PCM_FMTBIT_S24_LE |
  12277. SNDRV_PCM_FMTBIT_S24_3LE |
  12278. SNDRV_PCM_FMTBIT_S32_LE,
  12279. .channels_min = 1,
  12280. .channels_max = 1,
  12281. .rate_min = 8000,
  12282. .rate_max = 384000,
  12283. },
  12284. .name = "RX_CDC_DMA_RX_3",
  12285. .ops = &msm_dai_q6_cdc_dma_ops,
  12286. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  12287. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12288. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12289. },
  12290. {
  12291. .capture = {
  12292. .stream_name = "TX CDC DMA3 Capture",
  12293. .aif_name = "TX_CDC_DMA_TX_3",
  12294. .rates = SNDRV_PCM_RATE_8000 |
  12295. SNDRV_PCM_RATE_16000 |
  12296. SNDRV_PCM_RATE_32000 |
  12297. SNDRV_PCM_RATE_48000 |
  12298. SNDRV_PCM_RATE_96000 |
  12299. SNDRV_PCM_RATE_192000 |
  12300. SNDRV_PCM_RATE_384000,
  12301. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12302. SNDRV_PCM_FMTBIT_S24_LE |
  12303. SNDRV_PCM_FMTBIT_S24_3LE |
  12304. SNDRV_PCM_FMTBIT_S32_LE,
  12305. .channels_min = 1,
  12306. .channels_max = 8,
  12307. .rate_min = 8000,
  12308. .rate_max = 384000,
  12309. },
  12310. .name = "TX_CDC_DMA_TX_3",
  12311. .ops = &msm_dai_q6_cdc_dma_ops,
  12312. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  12313. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12314. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12315. },
  12316. {
  12317. .playback = {
  12318. .stream_name = "RX CDC DMA4 Playback",
  12319. .aif_name = "RX_CDC_DMA_RX_4",
  12320. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12321. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12322. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12323. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12324. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12325. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12326. SNDRV_PCM_RATE_384000,
  12327. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12328. SNDRV_PCM_FMTBIT_S24_LE |
  12329. SNDRV_PCM_FMTBIT_S24_3LE |
  12330. SNDRV_PCM_FMTBIT_S32_LE,
  12331. .channels_min = 1,
  12332. .channels_max = 6,
  12333. .rate_min = 8000,
  12334. .rate_max = 384000,
  12335. },
  12336. .name = "RX_CDC_DMA_RX_4",
  12337. .ops = &msm_dai_q6_cdc_dma_ops,
  12338. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  12339. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12340. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12341. },
  12342. {
  12343. .capture = {
  12344. .stream_name = "TX CDC DMA4 Capture",
  12345. .aif_name = "TX_CDC_DMA_TX_4",
  12346. .rates = SNDRV_PCM_RATE_8000 |
  12347. SNDRV_PCM_RATE_16000 |
  12348. SNDRV_PCM_RATE_32000 |
  12349. SNDRV_PCM_RATE_48000 |
  12350. SNDRV_PCM_RATE_96000 |
  12351. SNDRV_PCM_RATE_192000 |
  12352. SNDRV_PCM_RATE_384000,
  12353. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12354. SNDRV_PCM_FMTBIT_S24_LE |
  12355. SNDRV_PCM_FMTBIT_S24_3LE |
  12356. SNDRV_PCM_FMTBIT_S32_LE,
  12357. .channels_min = 1,
  12358. .channels_max = 8,
  12359. .rate_min = 8000,
  12360. .rate_max = 384000,
  12361. },
  12362. .name = "TX_CDC_DMA_TX_4",
  12363. .ops = &msm_dai_q6_cdc_dma_ops,
  12364. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  12365. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12366. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12367. },
  12368. {
  12369. .playback = {
  12370. .stream_name = "RX CDC DMA5 Playback",
  12371. .aif_name = "RX_CDC_DMA_RX_5",
  12372. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12373. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12374. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12375. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12376. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12377. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12378. SNDRV_PCM_RATE_384000,
  12379. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12380. SNDRV_PCM_FMTBIT_S24_LE |
  12381. SNDRV_PCM_FMTBIT_S24_3LE |
  12382. SNDRV_PCM_FMTBIT_S32_LE,
  12383. .channels_min = 1,
  12384. .channels_max = 1,
  12385. .rate_min = 8000,
  12386. .rate_max = 384000,
  12387. },
  12388. .name = "RX_CDC_DMA_RX_5",
  12389. .ops = &msm_dai_q6_cdc_dma_ops,
  12390. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  12391. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12392. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12393. },
  12394. {
  12395. .capture = {
  12396. .stream_name = "TX CDC DMA5 Capture",
  12397. .aif_name = "TX_CDC_DMA_TX_5",
  12398. .rates = SNDRV_PCM_RATE_8000 |
  12399. SNDRV_PCM_RATE_16000 |
  12400. SNDRV_PCM_RATE_32000 |
  12401. SNDRV_PCM_RATE_48000 |
  12402. SNDRV_PCM_RATE_96000 |
  12403. SNDRV_PCM_RATE_192000 |
  12404. SNDRV_PCM_RATE_384000,
  12405. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12406. SNDRV_PCM_FMTBIT_S24_LE |
  12407. SNDRV_PCM_FMTBIT_S24_3LE |
  12408. SNDRV_PCM_FMTBIT_S32_LE,
  12409. .channels_min = 1,
  12410. .channels_max = 4,
  12411. .rate_min = 8000,
  12412. .rate_max = 384000,
  12413. },
  12414. .name = "TX_CDC_DMA_TX_5",
  12415. .ops = &msm_dai_q6_cdc_dma_ops,
  12416. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  12417. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12418. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12419. },
  12420. {
  12421. .playback = {
  12422. .stream_name = "RX CDC DMA6 Playback",
  12423. .aif_name = "RX_CDC_DMA_RX_6",
  12424. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12425. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12426. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12427. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12428. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12429. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12430. SNDRV_PCM_RATE_384000,
  12431. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12432. SNDRV_PCM_FMTBIT_S24_LE |
  12433. SNDRV_PCM_FMTBIT_S24_3LE |
  12434. SNDRV_PCM_FMTBIT_S32_LE,
  12435. .channels_min = 1,
  12436. .channels_max = 4,
  12437. .rate_min = 8000,
  12438. .rate_max = 384000,
  12439. },
  12440. .name = "RX_CDC_DMA_RX_6",
  12441. .ops = &msm_dai_q6_cdc_dma_ops,
  12442. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  12443. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12444. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12445. },
  12446. {
  12447. .playback = {
  12448. .stream_name = "RX CDC DMA7 Playback",
  12449. .aif_name = "RX_CDC_DMA_RX_7",
  12450. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12451. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12452. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12453. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12454. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12455. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12456. SNDRV_PCM_RATE_384000,
  12457. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12458. SNDRV_PCM_FMTBIT_S24_LE |
  12459. SNDRV_PCM_FMTBIT_S24_3LE |
  12460. SNDRV_PCM_FMTBIT_S32_LE,
  12461. .channels_min = 1,
  12462. .channels_max = 2,
  12463. .rate_min = 8000,
  12464. .rate_max = 384000,
  12465. },
  12466. .name = "RX_CDC_DMA_RX_7",
  12467. .ops = &msm_dai_q6_cdc_dma_ops,
  12468. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  12469. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12470. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12471. },
  12472. };
  12473. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  12474. .name = "msm-dai-cdc-dma-dev",
  12475. };
  12476. /* DT related probe for each codec DMA interface device */
  12477. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  12478. {
  12479. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  12480. u32 cdc_dma_id = 0;
  12481. int i;
  12482. int rc = 0;
  12483. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  12484. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  12485. &cdc_dma_id);
  12486. if (rc) {
  12487. dev_err(&pdev->dev,
  12488. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  12489. return rc;
  12490. }
  12491. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  12492. dev_name(&pdev->dev), cdc_dma_id);
  12493. pdev->id = cdc_dma_id;
  12494. dai_data = devm_kzalloc(&pdev->dev,
  12495. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  12496. GFP_KERNEL);
  12497. if (!dai_data)
  12498. return -ENOMEM;
  12499. rc = of_property_read_u32(pdev->dev.of_node,
  12500. "qcom,msm-dai-is-island-supported",
  12501. &dai_data->is_island_dai);
  12502. if (rc)
  12503. dev_dbg(&pdev->dev, "island supported entry not found\n");
  12504. rc = of_property_read_u32(pdev->dev.of_node,
  12505. "qcom,msm-cdc-dma-data-align",
  12506. &dai_data->cdc_dma_data_align);
  12507. if (rc)
  12508. dev_dbg(&pdev->dev, "cdc dma data align supported entry not found\n");
  12509. dev_set_drvdata(&pdev->dev, dai_data);
  12510. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  12511. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  12512. return snd_soc_register_component(&pdev->dev,
  12513. &msm_q6_cdc_dma_dai_component,
  12514. &msm_dai_q6_cdc_dma_dai[i], 1);
  12515. }
  12516. }
  12517. return -ENODEV;
  12518. }
  12519. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  12520. {
  12521. snd_soc_unregister_component(&pdev->dev);
  12522. return 0;
  12523. }
  12524. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  12525. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  12526. { }
  12527. };
  12528. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  12529. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  12530. .probe = msm_dai_q6_cdc_dma_dev_probe,
  12531. .remove = msm_dai_q6_cdc_dma_dev_remove,
  12532. .driver = {
  12533. .name = "msm-dai-cdc-dma-dev",
  12534. .owner = THIS_MODULE,
  12535. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  12536. .suppress_bind_attrs = true,
  12537. },
  12538. };
  12539. /* DT related probe for codec DMA interface device group */
  12540. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  12541. {
  12542. int rc;
  12543. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  12544. if (rc) {
  12545. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  12546. __func__, rc);
  12547. } else
  12548. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  12549. return rc;
  12550. }
  12551. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  12552. {
  12553. of_platform_depopulate(&pdev->dev);
  12554. return 0;
  12555. }
  12556. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  12557. { .compatible = "qcom,msm-dai-cdc-dma", },
  12558. { }
  12559. };
  12560. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  12561. static struct platform_driver msm_dai_cdc_dma_q6 = {
  12562. .probe = msm_dai_cdc_dma_q6_probe,
  12563. .remove = msm_dai_cdc_dma_q6_remove,
  12564. .driver = {
  12565. .name = "msm-dai-cdc-dma",
  12566. .owner = THIS_MODULE,
  12567. .of_match_table = msm_dai_cdc_dma_dt_match,
  12568. .suppress_bind_attrs = true,
  12569. },
  12570. };
  12571. int __init msm_dai_q6_init(void)
  12572. {
  12573. int rc;
  12574. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  12575. if (rc) {
  12576. pr_err("%s: fail to register auxpcm dev driver", __func__);
  12577. goto fail;
  12578. }
  12579. rc = platform_driver_register(&msm_dai_q6);
  12580. if (rc) {
  12581. pr_err("%s: fail to register dai q6 driver", __func__);
  12582. goto dai_q6_fail;
  12583. }
  12584. rc = platform_driver_register(&msm_dai_q6_dev);
  12585. if (rc) {
  12586. pr_err("%s: fail to register dai q6 dev driver", __func__);
  12587. goto dai_q6_dev_fail;
  12588. }
  12589. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  12590. if (rc) {
  12591. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  12592. goto dai_q6_mi2s_drv_fail;
  12593. }
  12594. rc = platform_driver_register(&msm_dai_q6_meta_mi2s_driver);
  12595. if (rc) {
  12596. pr_err("%s: fail to register dai META MI2S dev drv\n",
  12597. __func__);
  12598. goto dai_q6_meta_mi2s_drv_fail;
  12599. }
  12600. rc = platform_driver_register(&msm_dai_mi2s_q6);
  12601. if (rc) {
  12602. pr_err("%s: fail to register dai MI2S\n", __func__);
  12603. goto dai_mi2s_q6_fail;
  12604. }
  12605. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  12606. if (rc) {
  12607. pr_err("%s: fail to register dai SPDIF\n", __func__);
  12608. goto dai_spdif_q6_fail;
  12609. }
  12610. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  12611. if (rc) {
  12612. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  12613. goto dai_q6_tdm_drv_fail;
  12614. }
  12615. rc = platform_driver_register(&msm_dai_tdm_q6);
  12616. if (rc) {
  12617. pr_err("%s: fail to register dai TDM\n", __func__);
  12618. goto dai_tdm_q6_fail;
  12619. }
  12620. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  12621. if (rc) {
  12622. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  12623. goto dai_cdc_dma_q6_dev_fail;
  12624. }
  12625. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  12626. if (rc) {
  12627. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  12628. goto dai_cdc_dma_q6_fail;
  12629. }
  12630. return rc;
  12631. dai_cdc_dma_q6_fail:
  12632. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12633. dai_cdc_dma_q6_dev_fail:
  12634. platform_driver_unregister(&msm_dai_tdm_q6);
  12635. dai_tdm_q6_fail:
  12636. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12637. dai_q6_tdm_drv_fail:
  12638. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12639. dai_spdif_q6_fail:
  12640. platform_driver_unregister(&msm_dai_mi2s_q6);
  12641. dai_mi2s_q6_fail:
  12642. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12643. dai_q6_meta_mi2s_drv_fail:
  12644. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12645. dai_q6_mi2s_drv_fail:
  12646. platform_driver_unregister(&msm_dai_q6_dev);
  12647. dai_q6_dev_fail:
  12648. platform_driver_unregister(&msm_dai_q6);
  12649. dai_q6_fail:
  12650. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12651. fail:
  12652. return rc;
  12653. }
  12654. void msm_dai_q6_exit(void)
  12655. {
  12656. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  12657. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12658. platform_driver_unregister(&msm_dai_tdm_q6);
  12659. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12660. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12661. platform_driver_unregister(&msm_dai_mi2s_q6);
  12662. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12663. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12664. platform_driver_unregister(&msm_dai_q6_dev);
  12665. platform_driver_unregister(&msm_dai_q6);
  12666. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12667. }
  12668. /* Module information */
  12669. MODULE_DESCRIPTION("MSM DSP DAI driver");
  12670. MODULE_LICENSE("GPL v2");