msm-dai-q6-v2.c 356 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2019, 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 spdif_clock_value(rate) (2*rate*32*2)
  31. #define CHANNEL_STATUS_SIZE 24
  32. #define CHANNEL_STATUS_MASK_INIT 0x0
  33. #define CHANNEL_STATUS_MASK 0x4
  34. #define AFE_API_VERSION_CLOCK_SET 1
  35. #define MSM_DAI_SYSFS_ENTRY_MAX_LEN 64
  36. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  37. SNDRV_PCM_FMTBIT_S24_LE | \
  38. SNDRV_PCM_FMTBIT_S32_LE)
  39. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id);
  40. enum {
  41. ENC_FMT_NONE,
  42. DEC_FMT_NONE = ENC_FMT_NONE,
  43. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  44. DEC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  45. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  46. DEC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  47. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  48. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  49. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  50. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  51. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  52. DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  53. DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
  54. ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  55. DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  56. };
  57. enum {
  58. SPKR_1,
  59. SPKR_2,
  60. };
  61. static const struct afe_clk_set lpass_clk_set_default = {
  62. AFE_API_VERSION_CLOCK_SET,
  63. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  64. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  65. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  66. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  67. 0,
  68. };
  69. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  70. AFE_API_VERSION_I2S_CONFIG,
  71. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  72. 0,
  73. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  74. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  75. Q6AFE_LPASS_MODE_CLK1_VALID,
  76. 0,
  77. };
  78. enum {
  79. STATUS_PORT_STARTED, /* track if AFE port has started */
  80. /* track AFE Tx port status for bi-directional transfers */
  81. STATUS_TX_PORT,
  82. /* track AFE Rx port status for bi-directional transfers */
  83. STATUS_RX_PORT,
  84. STATUS_MAX
  85. };
  86. enum {
  87. RATE_8KHZ,
  88. RATE_16KHZ,
  89. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  90. };
  91. enum {
  92. IDX_PRIMARY_TDM_RX_0,
  93. IDX_PRIMARY_TDM_RX_1,
  94. IDX_PRIMARY_TDM_RX_2,
  95. IDX_PRIMARY_TDM_RX_3,
  96. IDX_PRIMARY_TDM_RX_4,
  97. IDX_PRIMARY_TDM_RX_5,
  98. IDX_PRIMARY_TDM_RX_6,
  99. IDX_PRIMARY_TDM_RX_7,
  100. IDX_PRIMARY_TDM_TX_0,
  101. IDX_PRIMARY_TDM_TX_1,
  102. IDX_PRIMARY_TDM_TX_2,
  103. IDX_PRIMARY_TDM_TX_3,
  104. IDX_PRIMARY_TDM_TX_4,
  105. IDX_PRIMARY_TDM_TX_5,
  106. IDX_PRIMARY_TDM_TX_6,
  107. IDX_PRIMARY_TDM_TX_7,
  108. IDX_SECONDARY_TDM_RX_0,
  109. IDX_SECONDARY_TDM_RX_1,
  110. IDX_SECONDARY_TDM_RX_2,
  111. IDX_SECONDARY_TDM_RX_3,
  112. IDX_SECONDARY_TDM_RX_4,
  113. IDX_SECONDARY_TDM_RX_5,
  114. IDX_SECONDARY_TDM_RX_6,
  115. IDX_SECONDARY_TDM_RX_7,
  116. IDX_SECONDARY_TDM_TX_0,
  117. IDX_SECONDARY_TDM_TX_1,
  118. IDX_SECONDARY_TDM_TX_2,
  119. IDX_SECONDARY_TDM_TX_3,
  120. IDX_SECONDARY_TDM_TX_4,
  121. IDX_SECONDARY_TDM_TX_5,
  122. IDX_SECONDARY_TDM_TX_6,
  123. IDX_SECONDARY_TDM_TX_7,
  124. IDX_TERTIARY_TDM_RX_0,
  125. IDX_TERTIARY_TDM_RX_1,
  126. IDX_TERTIARY_TDM_RX_2,
  127. IDX_TERTIARY_TDM_RX_3,
  128. IDX_TERTIARY_TDM_RX_4,
  129. IDX_TERTIARY_TDM_RX_5,
  130. IDX_TERTIARY_TDM_RX_6,
  131. IDX_TERTIARY_TDM_RX_7,
  132. IDX_TERTIARY_TDM_TX_0,
  133. IDX_TERTIARY_TDM_TX_1,
  134. IDX_TERTIARY_TDM_TX_2,
  135. IDX_TERTIARY_TDM_TX_3,
  136. IDX_TERTIARY_TDM_TX_4,
  137. IDX_TERTIARY_TDM_TX_5,
  138. IDX_TERTIARY_TDM_TX_6,
  139. IDX_TERTIARY_TDM_TX_7,
  140. IDX_QUATERNARY_TDM_RX_0,
  141. IDX_QUATERNARY_TDM_RX_1,
  142. IDX_QUATERNARY_TDM_RX_2,
  143. IDX_QUATERNARY_TDM_RX_3,
  144. IDX_QUATERNARY_TDM_RX_4,
  145. IDX_QUATERNARY_TDM_RX_5,
  146. IDX_QUATERNARY_TDM_RX_6,
  147. IDX_QUATERNARY_TDM_RX_7,
  148. IDX_QUATERNARY_TDM_TX_0,
  149. IDX_QUATERNARY_TDM_TX_1,
  150. IDX_QUATERNARY_TDM_TX_2,
  151. IDX_QUATERNARY_TDM_TX_3,
  152. IDX_QUATERNARY_TDM_TX_4,
  153. IDX_QUATERNARY_TDM_TX_5,
  154. IDX_QUATERNARY_TDM_TX_6,
  155. IDX_QUATERNARY_TDM_TX_7,
  156. IDX_QUINARY_TDM_RX_0,
  157. IDX_QUINARY_TDM_RX_1,
  158. IDX_QUINARY_TDM_RX_2,
  159. IDX_QUINARY_TDM_RX_3,
  160. IDX_QUINARY_TDM_RX_4,
  161. IDX_QUINARY_TDM_RX_5,
  162. IDX_QUINARY_TDM_RX_6,
  163. IDX_QUINARY_TDM_RX_7,
  164. IDX_QUINARY_TDM_TX_0,
  165. IDX_QUINARY_TDM_TX_1,
  166. IDX_QUINARY_TDM_TX_2,
  167. IDX_QUINARY_TDM_TX_3,
  168. IDX_QUINARY_TDM_TX_4,
  169. IDX_QUINARY_TDM_TX_5,
  170. IDX_QUINARY_TDM_TX_6,
  171. IDX_QUINARY_TDM_TX_7,
  172. IDX_SENARY_TDM_RX_0,
  173. IDX_SENARY_TDM_RX_1,
  174. IDX_SENARY_TDM_RX_2,
  175. IDX_SENARY_TDM_RX_3,
  176. IDX_SENARY_TDM_RX_4,
  177. IDX_SENARY_TDM_RX_5,
  178. IDX_SENARY_TDM_RX_6,
  179. IDX_SENARY_TDM_RX_7,
  180. IDX_SENARY_TDM_TX_0,
  181. IDX_SENARY_TDM_TX_1,
  182. IDX_SENARY_TDM_TX_2,
  183. IDX_SENARY_TDM_TX_3,
  184. IDX_SENARY_TDM_TX_4,
  185. IDX_SENARY_TDM_TX_5,
  186. IDX_SENARY_TDM_TX_6,
  187. IDX_SENARY_TDM_TX_7,
  188. IDX_TDM_MAX,
  189. };
  190. enum {
  191. IDX_GROUP_PRIMARY_TDM_RX,
  192. IDX_GROUP_PRIMARY_TDM_TX,
  193. IDX_GROUP_SECONDARY_TDM_RX,
  194. IDX_GROUP_SECONDARY_TDM_TX,
  195. IDX_GROUP_TERTIARY_TDM_RX,
  196. IDX_GROUP_TERTIARY_TDM_TX,
  197. IDX_GROUP_QUATERNARY_TDM_RX,
  198. IDX_GROUP_QUATERNARY_TDM_TX,
  199. IDX_GROUP_QUINARY_TDM_RX,
  200. IDX_GROUP_QUINARY_TDM_TX,
  201. IDX_GROUP_SENARY_TDM_RX,
  202. IDX_GROUP_SENARY_TDM_TX,
  203. IDX_GROUP_TDM_MAX,
  204. };
  205. struct msm_dai_q6_dai_data {
  206. DECLARE_BITMAP(status_mask, STATUS_MAX);
  207. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  208. u32 rate;
  209. u32 channels;
  210. u32 bitwidth;
  211. u32 cal_mode;
  212. u32 afe_rx_in_channels;
  213. u16 afe_rx_in_bitformat;
  214. u32 afe_tx_out_channels;
  215. u16 afe_tx_out_bitformat;
  216. struct afe_enc_config enc_config;
  217. struct afe_dec_config dec_config;
  218. union afe_port_config port_config;
  219. u16 vi_feed_mono;
  220. };
  221. struct msm_dai_q6_spdif_dai_data {
  222. DECLARE_BITMAP(status_mask, STATUS_MAX);
  223. u32 rate;
  224. u32 channels;
  225. u32 bitwidth;
  226. u16 port_id;
  227. struct afe_spdif_port_config spdif_port;
  228. struct afe_event_fmt_update fmt_event;
  229. struct kobject *kobj;
  230. };
  231. struct msm_dai_q6_spdif_event_msg {
  232. struct afe_port_mod_evt_rsp_hdr evt_hdr;
  233. struct afe_event_fmt_update fmt_event;
  234. };
  235. struct msm_dai_q6_mi2s_dai_config {
  236. u16 pdata_mi2s_lines;
  237. struct msm_dai_q6_dai_data mi2s_dai_data;
  238. };
  239. struct msm_dai_q6_mi2s_dai_data {
  240. u32 is_island_dai;
  241. struct msm_dai_q6_mi2s_dai_config tx_dai;
  242. struct msm_dai_q6_mi2s_dai_config rx_dai;
  243. };
  244. struct msm_dai_q6_cdc_dma_dai_data {
  245. DECLARE_BITMAP(status_mask, STATUS_MAX);
  246. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  247. u32 rate;
  248. u32 channels;
  249. u32 bitwidth;
  250. u32 is_island_dai;
  251. union afe_port_config port_config;
  252. };
  253. struct msm_dai_q6_auxpcm_dai_data {
  254. /* BITMAP to track Rx and Tx port usage count */
  255. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  256. struct mutex rlock; /* auxpcm dev resource lock */
  257. u16 rx_pid; /* AUXPCM RX AFE port ID */
  258. u16 tx_pid; /* AUXPCM TX AFE port ID */
  259. u16 afe_clk_ver;
  260. u32 is_island_dai;
  261. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  262. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  263. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  264. };
  265. struct msm_dai_q6_tdm_dai_data {
  266. DECLARE_BITMAP(status_mask, STATUS_MAX);
  267. u32 rate;
  268. u32 channels;
  269. u32 bitwidth;
  270. u32 num_group_ports;
  271. u32 is_island_dai;
  272. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  273. union afe_port_group_config group_cfg; /* hold tdm group config */
  274. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  275. struct afe_param_id_tdm_lane_cfg lane_cfg; /* hold tdm lane config */
  276. };
  277. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  278. * 0: linear PCM
  279. * 1: non-linear PCM
  280. * 2: PCM data in IEC 60968 container
  281. * 3: compressed data in IEC 60958 container
  282. * 9: DSD over PCM (DoP) with marker byte
  283. */
  284. static const char *const mi2s_format[] = {
  285. "LPCM",
  286. "Compr",
  287. "LPCM-60958",
  288. "Compr-60958",
  289. "NA4",
  290. "NA5",
  291. "NA6",
  292. "NA7",
  293. "NA8",
  294. "DSD_DOP_W_MARKER"
  295. };
  296. static const char *const mi2s_vi_feed_mono[] = {
  297. "Left",
  298. "Right",
  299. };
  300. static const struct soc_enum mi2s_config_enum[] = {
  301. SOC_ENUM_SINGLE_EXT(10, mi2s_format),
  302. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  303. };
  304. static const char *const cdc_dma_format[] = {
  305. "UNPACKED",
  306. "PACKED_16B",
  307. };
  308. static const struct soc_enum cdc_dma_config_enum[] = {
  309. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  310. };
  311. static const char *const sb_format[] = {
  312. "UNPACKED",
  313. "PACKED_16B",
  314. "DSD_DOP",
  315. };
  316. static const struct soc_enum sb_config_enum[] = {
  317. SOC_ENUM_SINGLE_EXT(3, sb_format),
  318. };
  319. static const char *const tdm_data_format[] = {
  320. "LPCM",
  321. "Compr",
  322. "Gen Compr"
  323. };
  324. static const char *const tdm_header_type[] = {
  325. "Invalid",
  326. "Default",
  327. "Entertainment",
  328. };
  329. static const struct soc_enum tdm_config_enum[] = {
  330. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  331. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  332. };
  333. static DEFINE_MUTEX(tdm_mutex);
  334. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  335. static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = {
  336. AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX,
  337. 0x0,
  338. };
  339. /* cache of group cfg per parent node */
  340. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  341. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  342. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  343. 0,
  344. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  345. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  346. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  347. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  348. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  349. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  350. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  351. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  352. 8,
  353. 48000,
  354. 32,
  355. 8,
  356. 32,
  357. 0xFF,
  358. };
  359. static u32 num_tdm_group_ports;
  360. static struct afe_clk_set tdm_clk_set = {
  361. AFE_API_VERSION_CLOCK_SET,
  362. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  363. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  364. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  365. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  366. 0,
  367. };
  368. static int msm_dai_q6_get_tdm_clk_ref(u16 id)
  369. {
  370. switch (id) {
  371. case IDX_GROUP_PRIMARY_TDM_RX:
  372. case IDX_GROUP_PRIMARY_TDM_TX:
  373. return atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_RX]) +
  374. atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_TX]);
  375. case IDX_GROUP_SECONDARY_TDM_RX:
  376. case IDX_GROUP_SECONDARY_TDM_TX:
  377. return atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_RX]) +
  378. atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_TX]);
  379. case IDX_GROUP_TERTIARY_TDM_RX:
  380. case IDX_GROUP_TERTIARY_TDM_TX:
  381. return atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_RX]) +
  382. atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_TX]);
  383. case IDX_GROUP_QUATERNARY_TDM_RX:
  384. case IDX_GROUP_QUATERNARY_TDM_TX:
  385. return atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_RX]) +
  386. atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_TX]);
  387. case IDX_GROUP_QUINARY_TDM_RX:
  388. case IDX_GROUP_QUINARY_TDM_TX:
  389. return atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_RX]) +
  390. atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_TX]);
  391. case IDX_GROUP_SENARY_TDM_RX:
  392. case IDX_GROUP_SENARY_TDM_TX:
  393. return atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_RX]) +
  394. atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_TX]);
  395. default: return -EINVAL;
  396. }
  397. }
  398. int msm_dai_q6_get_group_idx(u16 id)
  399. {
  400. switch (id) {
  401. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  402. case AFE_PORT_ID_PRIMARY_TDM_RX:
  403. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  404. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  405. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  406. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  407. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  408. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  409. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  410. return IDX_GROUP_PRIMARY_TDM_RX;
  411. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  412. case AFE_PORT_ID_PRIMARY_TDM_TX:
  413. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  414. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  415. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  416. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  417. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  418. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  419. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  420. return IDX_GROUP_PRIMARY_TDM_TX;
  421. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  422. case AFE_PORT_ID_SECONDARY_TDM_RX:
  423. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  424. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  425. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  426. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  427. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  428. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  429. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  430. return IDX_GROUP_SECONDARY_TDM_RX;
  431. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  432. case AFE_PORT_ID_SECONDARY_TDM_TX:
  433. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  434. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  435. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  436. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  437. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  438. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  439. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  440. return IDX_GROUP_SECONDARY_TDM_TX;
  441. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  442. case AFE_PORT_ID_TERTIARY_TDM_RX:
  443. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  444. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  445. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  446. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  447. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  448. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  449. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  450. return IDX_GROUP_TERTIARY_TDM_RX;
  451. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  452. case AFE_PORT_ID_TERTIARY_TDM_TX:
  453. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  454. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  455. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  456. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  457. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  458. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  459. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  460. return IDX_GROUP_TERTIARY_TDM_TX;
  461. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  462. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  463. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  464. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  465. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  466. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  467. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  468. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  469. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  470. return IDX_GROUP_QUATERNARY_TDM_RX;
  471. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  472. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  473. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  474. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  475. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  476. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  477. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  478. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  479. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  480. return IDX_GROUP_QUATERNARY_TDM_TX;
  481. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  482. case AFE_PORT_ID_QUINARY_TDM_RX:
  483. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  484. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  485. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  486. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  487. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  488. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  489. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  490. return IDX_GROUP_QUINARY_TDM_RX;
  491. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  492. case AFE_PORT_ID_QUINARY_TDM_TX:
  493. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  494. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  495. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  496. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  497. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  498. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  499. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  500. return IDX_GROUP_QUINARY_TDM_TX;
  501. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  502. case AFE_PORT_ID_SENARY_TDM_RX:
  503. case AFE_PORT_ID_SENARY_TDM_RX_1:
  504. case AFE_PORT_ID_SENARY_TDM_RX_2:
  505. case AFE_PORT_ID_SENARY_TDM_RX_3:
  506. case AFE_PORT_ID_SENARY_TDM_RX_4:
  507. case AFE_PORT_ID_SENARY_TDM_RX_5:
  508. case AFE_PORT_ID_SENARY_TDM_RX_6:
  509. case AFE_PORT_ID_SENARY_TDM_RX_7:
  510. return IDX_GROUP_SENARY_TDM_RX;
  511. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  512. case AFE_PORT_ID_SENARY_TDM_TX:
  513. case AFE_PORT_ID_SENARY_TDM_TX_1:
  514. case AFE_PORT_ID_SENARY_TDM_TX_2:
  515. case AFE_PORT_ID_SENARY_TDM_TX_3:
  516. case AFE_PORT_ID_SENARY_TDM_TX_4:
  517. case AFE_PORT_ID_SENARY_TDM_TX_5:
  518. case AFE_PORT_ID_SENARY_TDM_TX_6:
  519. case AFE_PORT_ID_SENARY_TDM_TX_7:
  520. return IDX_GROUP_SENARY_TDM_TX;
  521. default: return -EINVAL;
  522. }
  523. }
  524. int msm_dai_q6_get_port_idx(u16 id)
  525. {
  526. switch (id) {
  527. case AFE_PORT_ID_PRIMARY_TDM_RX:
  528. return IDX_PRIMARY_TDM_RX_0;
  529. case AFE_PORT_ID_PRIMARY_TDM_TX:
  530. return IDX_PRIMARY_TDM_TX_0;
  531. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  532. return IDX_PRIMARY_TDM_RX_1;
  533. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  534. return IDX_PRIMARY_TDM_TX_1;
  535. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  536. return IDX_PRIMARY_TDM_RX_2;
  537. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  538. return IDX_PRIMARY_TDM_TX_2;
  539. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  540. return IDX_PRIMARY_TDM_RX_3;
  541. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  542. return IDX_PRIMARY_TDM_TX_3;
  543. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  544. return IDX_PRIMARY_TDM_RX_4;
  545. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  546. return IDX_PRIMARY_TDM_TX_4;
  547. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  548. return IDX_PRIMARY_TDM_RX_5;
  549. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  550. return IDX_PRIMARY_TDM_TX_5;
  551. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  552. return IDX_PRIMARY_TDM_RX_6;
  553. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  554. return IDX_PRIMARY_TDM_TX_6;
  555. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  556. return IDX_PRIMARY_TDM_RX_7;
  557. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  558. return IDX_PRIMARY_TDM_TX_7;
  559. case AFE_PORT_ID_SECONDARY_TDM_RX:
  560. return IDX_SECONDARY_TDM_RX_0;
  561. case AFE_PORT_ID_SECONDARY_TDM_TX:
  562. return IDX_SECONDARY_TDM_TX_0;
  563. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  564. return IDX_SECONDARY_TDM_RX_1;
  565. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  566. return IDX_SECONDARY_TDM_TX_1;
  567. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  568. return IDX_SECONDARY_TDM_RX_2;
  569. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  570. return IDX_SECONDARY_TDM_TX_2;
  571. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  572. return IDX_SECONDARY_TDM_RX_3;
  573. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  574. return IDX_SECONDARY_TDM_TX_3;
  575. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  576. return IDX_SECONDARY_TDM_RX_4;
  577. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  578. return IDX_SECONDARY_TDM_TX_4;
  579. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  580. return IDX_SECONDARY_TDM_RX_5;
  581. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  582. return IDX_SECONDARY_TDM_TX_5;
  583. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  584. return IDX_SECONDARY_TDM_RX_6;
  585. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  586. return IDX_SECONDARY_TDM_TX_6;
  587. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  588. return IDX_SECONDARY_TDM_RX_7;
  589. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  590. return IDX_SECONDARY_TDM_TX_7;
  591. case AFE_PORT_ID_TERTIARY_TDM_RX:
  592. return IDX_TERTIARY_TDM_RX_0;
  593. case AFE_PORT_ID_TERTIARY_TDM_TX:
  594. return IDX_TERTIARY_TDM_TX_0;
  595. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  596. return IDX_TERTIARY_TDM_RX_1;
  597. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  598. return IDX_TERTIARY_TDM_TX_1;
  599. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  600. return IDX_TERTIARY_TDM_RX_2;
  601. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  602. return IDX_TERTIARY_TDM_TX_2;
  603. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  604. return IDX_TERTIARY_TDM_RX_3;
  605. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  606. return IDX_TERTIARY_TDM_TX_3;
  607. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  608. return IDX_TERTIARY_TDM_RX_4;
  609. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  610. return IDX_TERTIARY_TDM_TX_4;
  611. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  612. return IDX_TERTIARY_TDM_RX_5;
  613. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  614. return IDX_TERTIARY_TDM_TX_5;
  615. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  616. return IDX_TERTIARY_TDM_RX_6;
  617. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  618. return IDX_TERTIARY_TDM_TX_6;
  619. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  620. return IDX_TERTIARY_TDM_RX_7;
  621. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  622. return IDX_TERTIARY_TDM_TX_7;
  623. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  624. return IDX_QUATERNARY_TDM_RX_0;
  625. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  626. return IDX_QUATERNARY_TDM_TX_0;
  627. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  628. return IDX_QUATERNARY_TDM_RX_1;
  629. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  630. return IDX_QUATERNARY_TDM_TX_1;
  631. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  632. return IDX_QUATERNARY_TDM_RX_2;
  633. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  634. return IDX_QUATERNARY_TDM_TX_2;
  635. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  636. return IDX_QUATERNARY_TDM_RX_3;
  637. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  638. return IDX_QUATERNARY_TDM_TX_3;
  639. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  640. return IDX_QUATERNARY_TDM_RX_4;
  641. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  642. return IDX_QUATERNARY_TDM_TX_4;
  643. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  644. return IDX_QUATERNARY_TDM_RX_5;
  645. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  646. return IDX_QUATERNARY_TDM_TX_5;
  647. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  648. return IDX_QUATERNARY_TDM_RX_6;
  649. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  650. return IDX_QUATERNARY_TDM_TX_6;
  651. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  652. return IDX_QUATERNARY_TDM_RX_7;
  653. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  654. return IDX_QUATERNARY_TDM_TX_7;
  655. case AFE_PORT_ID_QUINARY_TDM_RX:
  656. return IDX_QUINARY_TDM_RX_0;
  657. case AFE_PORT_ID_QUINARY_TDM_TX:
  658. return IDX_QUINARY_TDM_TX_0;
  659. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  660. return IDX_QUINARY_TDM_RX_1;
  661. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  662. return IDX_QUINARY_TDM_TX_1;
  663. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  664. return IDX_QUINARY_TDM_RX_2;
  665. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  666. return IDX_QUINARY_TDM_TX_2;
  667. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  668. return IDX_QUINARY_TDM_RX_3;
  669. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  670. return IDX_QUINARY_TDM_TX_3;
  671. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  672. return IDX_QUINARY_TDM_RX_4;
  673. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  674. return IDX_QUINARY_TDM_TX_4;
  675. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  676. return IDX_QUINARY_TDM_RX_5;
  677. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  678. return IDX_QUINARY_TDM_TX_5;
  679. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  680. return IDX_QUINARY_TDM_RX_6;
  681. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  682. return IDX_QUINARY_TDM_TX_6;
  683. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  684. return IDX_QUINARY_TDM_RX_7;
  685. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  686. return IDX_QUINARY_TDM_TX_7;
  687. case AFE_PORT_ID_SENARY_TDM_RX:
  688. return IDX_SENARY_TDM_RX_0;
  689. case AFE_PORT_ID_SENARY_TDM_TX:
  690. return IDX_SENARY_TDM_TX_0;
  691. case AFE_PORT_ID_SENARY_TDM_RX_1:
  692. return IDX_SENARY_TDM_RX_1;
  693. case AFE_PORT_ID_SENARY_TDM_TX_1:
  694. return IDX_SENARY_TDM_TX_1;
  695. case AFE_PORT_ID_SENARY_TDM_RX_2:
  696. return IDX_SENARY_TDM_RX_2;
  697. case AFE_PORT_ID_SENARY_TDM_TX_2:
  698. return IDX_SENARY_TDM_TX_2;
  699. case AFE_PORT_ID_SENARY_TDM_RX_3:
  700. return IDX_SENARY_TDM_RX_3;
  701. case AFE_PORT_ID_SENARY_TDM_TX_3:
  702. return IDX_SENARY_TDM_TX_3;
  703. case AFE_PORT_ID_SENARY_TDM_RX_4:
  704. return IDX_SENARY_TDM_RX_4;
  705. case AFE_PORT_ID_SENARY_TDM_TX_4:
  706. return IDX_SENARY_TDM_TX_4;
  707. case AFE_PORT_ID_SENARY_TDM_RX_5:
  708. return IDX_SENARY_TDM_RX_5;
  709. case AFE_PORT_ID_SENARY_TDM_TX_5:
  710. return IDX_SENARY_TDM_TX_5;
  711. case AFE_PORT_ID_SENARY_TDM_RX_6:
  712. return IDX_SENARY_TDM_RX_6;
  713. case AFE_PORT_ID_SENARY_TDM_TX_6:
  714. return IDX_SENARY_TDM_TX_6;
  715. case AFE_PORT_ID_SENARY_TDM_RX_7:
  716. return IDX_SENARY_TDM_RX_7;
  717. case AFE_PORT_ID_SENARY_TDM_TX_7:
  718. return IDX_SENARY_TDM_TX_7;
  719. default: return -EINVAL;
  720. }
  721. }
  722. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  723. {
  724. /* Max num of slots is bits per frame divided
  725. * by bits per sample which is 16
  726. */
  727. switch (frame_rate) {
  728. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  729. return 0;
  730. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  731. return 1;
  732. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  733. return 2;
  734. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  735. return 4;
  736. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  737. return 8;
  738. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  739. return 16;
  740. default:
  741. pr_err("%s Invalid bits per frame %d\n",
  742. __func__, frame_rate);
  743. return 0;
  744. }
  745. }
  746. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  747. {
  748. struct snd_soc_dapm_route intercon;
  749. struct snd_soc_dapm_context *dapm;
  750. if (!dai) {
  751. pr_err("%s: Invalid params dai\n", __func__);
  752. return -EINVAL;
  753. }
  754. if (!dai->driver) {
  755. pr_err("%s: Invalid params dai driver\n", __func__);
  756. return -EINVAL;
  757. }
  758. dapm = snd_soc_component_get_dapm(dai->component);
  759. memset(&intercon, 0, sizeof(intercon));
  760. if (dai->driver->playback.stream_name &&
  761. dai->driver->playback.aif_name) {
  762. dev_dbg(dai->dev, "%s: add route for widget %s",
  763. __func__, dai->driver->playback.stream_name);
  764. intercon.source = dai->driver->playback.aif_name;
  765. intercon.sink = dai->driver->playback.stream_name;
  766. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  767. __func__, intercon.source, intercon.sink);
  768. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  769. snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
  770. }
  771. if (dai->driver->capture.stream_name &&
  772. dai->driver->capture.aif_name) {
  773. dev_dbg(dai->dev, "%s: add route for widget %s",
  774. __func__, dai->driver->capture.stream_name);
  775. intercon.sink = dai->driver->capture.aif_name;
  776. intercon.source = dai->driver->capture.stream_name;
  777. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  778. __func__, intercon.source, intercon.sink);
  779. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  780. snd_soc_dapm_ignore_suspend(dapm, intercon.source);
  781. }
  782. return 0;
  783. }
  784. static int msm_dai_q6_auxpcm_hw_params(
  785. struct snd_pcm_substream *substream,
  786. struct snd_pcm_hw_params *params,
  787. struct snd_soc_dai *dai)
  788. {
  789. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  790. dev_get_drvdata(dai->dev);
  791. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  792. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  793. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  794. int rc = 0, slot_mapping_copy_len = 0;
  795. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  796. params_rate(params) != 16000)) {
  797. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  798. __func__, params_channels(params), params_rate(params));
  799. return -EINVAL;
  800. }
  801. mutex_lock(&aux_dai_data->rlock);
  802. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  803. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  804. /* AUXPCM DAI in use */
  805. if (dai_data->rate != params_rate(params)) {
  806. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  807. __func__);
  808. rc = -EINVAL;
  809. }
  810. mutex_unlock(&aux_dai_data->rlock);
  811. return rc;
  812. }
  813. dai_data->channels = params_channels(params);
  814. dai_data->rate = params_rate(params);
  815. if (dai_data->rate == 8000) {
  816. dai_data->port_config.pcm.pcm_cfg_minor_version =
  817. AFE_API_VERSION_PCM_CONFIG;
  818. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  819. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  820. dai_data->port_config.pcm.frame_setting =
  821. auxpcm_pdata->mode_8k.frame;
  822. dai_data->port_config.pcm.quantype =
  823. auxpcm_pdata->mode_8k.quant;
  824. dai_data->port_config.pcm.ctrl_data_out_enable =
  825. auxpcm_pdata->mode_8k.data;
  826. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  827. dai_data->port_config.pcm.num_channels = dai_data->channels;
  828. dai_data->port_config.pcm.bit_width = 16;
  829. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  830. auxpcm_pdata->mode_8k.num_slots)
  831. slot_mapping_copy_len =
  832. ARRAY_SIZE(
  833. dai_data->port_config.pcm.slot_number_mapping)
  834. * sizeof(uint16_t);
  835. else
  836. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  837. * sizeof(uint16_t);
  838. if (auxpcm_pdata->mode_8k.slot_mapping) {
  839. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  840. auxpcm_pdata->mode_8k.slot_mapping,
  841. slot_mapping_copy_len);
  842. } else {
  843. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  844. __func__);
  845. mutex_unlock(&aux_dai_data->rlock);
  846. return -EINVAL;
  847. }
  848. } else {
  849. dai_data->port_config.pcm.pcm_cfg_minor_version =
  850. AFE_API_VERSION_PCM_CONFIG;
  851. dai_data->port_config.pcm.aux_mode =
  852. auxpcm_pdata->mode_16k.mode;
  853. dai_data->port_config.pcm.sync_src =
  854. auxpcm_pdata->mode_16k.sync;
  855. dai_data->port_config.pcm.frame_setting =
  856. auxpcm_pdata->mode_16k.frame;
  857. dai_data->port_config.pcm.quantype =
  858. auxpcm_pdata->mode_16k.quant;
  859. dai_data->port_config.pcm.ctrl_data_out_enable =
  860. auxpcm_pdata->mode_16k.data;
  861. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  862. dai_data->port_config.pcm.num_channels = dai_data->channels;
  863. dai_data->port_config.pcm.bit_width = 16;
  864. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  865. auxpcm_pdata->mode_16k.num_slots)
  866. slot_mapping_copy_len =
  867. ARRAY_SIZE(
  868. dai_data->port_config.pcm.slot_number_mapping)
  869. * sizeof(uint16_t);
  870. else
  871. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  872. * sizeof(uint16_t);
  873. if (auxpcm_pdata->mode_16k.slot_mapping) {
  874. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  875. auxpcm_pdata->mode_16k.slot_mapping,
  876. slot_mapping_copy_len);
  877. } else {
  878. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  879. __func__);
  880. mutex_unlock(&aux_dai_data->rlock);
  881. return -EINVAL;
  882. }
  883. }
  884. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  885. __func__, dai_data->port_config.pcm.aux_mode,
  886. dai_data->port_config.pcm.sync_src,
  887. dai_data->port_config.pcm.frame_setting);
  888. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  889. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  890. __func__, dai_data->port_config.pcm.quantype,
  891. dai_data->port_config.pcm.ctrl_data_out_enable,
  892. dai_data->port_config.pcm.slot_number_mapping[0],
  893. dai_data->port_config.pcm.slot_number_mapping[1],
  894. dai_data->port_config.pcm.slot_number_mapping[2],
  895. dai_data->port_config.pcm.slot_number_mapping[3]);
  896. mutex_unlock(&aux_dai_data->rlock);
  897. return rc;
  898. }
  899. static int msm_dai_q6_auxpcm_set_clk(
  900. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  901. u16 port_id, bool enable)
  902. {
  903. int rc;
  904. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  905. aux_dai_data->afe_clk_ver, port_id, enable);
  906. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  907. aux_dai_data->clk_set.enable = enable;
  908. rc = afe_set_lpass_clock_v2(port_id,
  909. &aux_dai_data->clk_set);
  910. } else {
  911. if (!enable)
  912. aux_dai_data->clk_cfg.clk_val1 = 0;
  913. rc = afe_set_lpass_clock(port_id,
  914. &aux_dai_data->clk_cfg);
  915. }
  916. return rc;
  917. }
  918. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  919. struct snd_soc_dai *dai)
  920. {
  921. int rc = 0;
  922. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  923. dev_get_drvdata(dai->dev);
  924. mutex_lock(&aux_dai_data->rlock);
  925. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  926. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  927. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  928. __func__, dai->id);
  929. goto exit;
  930. }
  931. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  932. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  933. clear_bit(STATUS_TX_PORT,
  934. aux_dai_data->auxpcm_port_status);
  935. else {
  936. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  937. __func__);
  938. goto exit;
  939. }
  940. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  941. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  942. clear_bit(STATUS_RX_PORT,
  943. aux_dai_data->auxpcm_port_status);
  944. else {
  945. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  946. __func__);
  947. goto exit;
  948. }
  949. }
  950. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  951. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  952. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  953. __func__);
  954. goto exit;
  955. }
  956. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  957. __func__, dai->id);
  958. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  959. if (rc < 0)
  960. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  961. rc = afe_close(aux_dai_data->tx_pid);
  962. if (rc < 0)
  963. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  964. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  965. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  966. exit:
  967. mutex_unlock(&aux_dai_data->rlock);
  968. }
  969. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  970. struct snd_soc_dai *dai)
  971. {
  972. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  973. dev_get_drvdata(dai->dev);
  974. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  975. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  976. int rc = 0;
  977. u32 pcm_clk_rate;
  978. auxpcm_pdata = dai->dev->platform_data;
  979. mutex_lock(&aux_dai_data->rlock);
  980. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  981. if (test_bit(STATUS_TX_PORT,
  982. aux_dai_data->auxpcm_port_status)) {
  983. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  984. __func__);
  985. goto exit;
  986. } else
  987. set_bit(STATUS_TX_PORT,
  988. aux_dai_data->auxpcm_port_status);
  989. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  990. if (test_bit(STATUS_RX_PORT,
  991. aux_dai_data->auxpcm_port_status)) {
  992. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  993. __func__);
  994. goto exit;
  995. } else
  996. set_bit(STATUS_RX_PORT,
  997. aux_dai_data->auxpcm_port_status);
  998. }
  999. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  1000. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1001. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  1002. goto exit;
  1003. }
  1004. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  1005. __func__, dai->id);
  1006. rc = afe_q6_interface_prepare();
  1007. if (rc < 0) {
  1008. dev_err(dai->dev, "fail to open AFE APR\n");
  1009. goto fail;
  1010. }
  1011. /*
  1012. * For AUX PCM Interface the below sequence of clk
  1013. * settings and afe_open is a strict requirement.
  1014. *
  1015. * Also using afe_open instead of afe_port_start_nowait
  1016. * to make sure the port is open before deasserting the
  1017. * clock line. This is required because pcm register is
  1018. * not written before clock deassert. Hence the hw does
  1019. * not get updated with new setting if the below clock
  1020. * assert/deasset and afe_open sequence is not followed.
  1021. */
  1022. if (dai_data->rate == 8000) {
  1023. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  1024. } else if (dai_data->rate == 16000) {
  1025. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  1026. } else {
  1027. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  1028. dai_data->rate);
  1029. rc = -EINVAL;
  1030. goto fail;
  1031. }
  1032. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  1033. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  1034. sizeof(struct afe_clk_set));
  1035. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  1036. switch (dai->id) {
  1037. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  1038. if (pcm_clk_rate)
  1039. aux_dai_data->clk_set.clk_id =
  1040. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  1041. else
  1042. aux_dai_data->clk_set.clk_id =
  1043. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  1044. break;
  1045. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  1046. if (pcm_clk_rate)
  1047. aux_dai_data->clk_set.clk_id =
  1048. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  1049. else
  1050. aux_dai_data->clk_set.clk_id =
  1051. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  1052. break;
  1053. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  1054. if (pcm_clk_rate)
  1055. aux_dai_data->clk_set.clk_id =
  1056. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  1057. else
  1058. aux_dai_data->clk_set.clk_id =
  1059. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  1060. break;
  1061. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  1062. if (pcm_clk_rate)
  1063. aux_dai_data->clk_set.clk_id =
  1064. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  1065. else
  1066. aux_dai_data->clk_set.clk_id =
  1067. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  1068. break;
  1069. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  1070. if (pcm_clk_rate)
  1071. aux_dai_data->clk_set.clk_id =
  1072. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  1073. else
  1074. aux_dai_data->clk_set.clk_id =
  1075. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  1076. break;
  1077. case MSM_DAI_SEN_AUXPCM_DT_DEV_ID:
  1078. if (pcm_clk_rate)
  1079. aux_dai_data->clk_set.clk_id =
  1080. Q6AFE_LPASS_CLK_ID_SEN_PCM_IBIT;
  1081. else
  1082. aux_dai_data->clk_set.clk_id =
  1083. Q6AFE_LPASS_CLK_ID_SEN_PCM_EBIT;
  1084. break;
  1085. default:
  1086. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  1087. __func__, dai->id);
  1088. break;
  1089. }
  1090. } else {
  1091. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  1092. sizeof(struct afe_clk_cfg));
  1093. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  1094. }
  1095. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1096. aux_dai_data->rx_pid, true);
  1097. if (rc < 0) {
  1098. dev_err(dai->dev,
  1099. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  1100. __func__);
  1101. goto fail;
  1102. }
  1103. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1104. aux_dai_data->tx_pid, true);
  1105. if (rc < 0) {
  1106. dev_err(dai->dev,
  1107. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  1108. __func__);
  1109. goto fail;
  1110. }
  1111. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  1112. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  1113. goto exit;
  1114. fail:
  1115. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  1116. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1117. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1118. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1119. exit:
  1120. mutex_unlock(&aux_dai_data->rlock);
  1121. return rc;
  1122. }
  1123. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1124. int cmd, struct snd_soc_dai *dai)
  1125. {
  1126. int rc = 0;
  1127. pr_debug("%s:port:%d cmd:%d\n",
  1128. __func__, dai->id, cmd);
  1129. switch (cmd) {
  1130. case SNDRV_PCM_TRIGGER_START:
  1131. case SNDRV_PCM_TRIGGER_RESUME:
  1132. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1133. /* afe_open will be called from prepare */
  1134. return 0;
  1135. case SNDRV_PCM_TRIGGER_STOP:
  1136. case SNDRV_PCM_TRIGGER_SUSPEND:
  1137. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1138. return 0;
  1139. default:
  1140. pr_err("%s: cmd %d\n", __func__, cmd);
  1141. rc = -EINVAL;
  1142. }
  1143. return rc;
  1144. }
  1145. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1146. {
  1147. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1148. int rc;
  1149. aux_dai_data = dev_get_drvdata(dai->dev);
  1150. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1151. __func__, dai->id);
  1152. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1153. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1154. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1155. if (rc < 0)
  1156. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1157. rc = afe_close(aux_dai_data->tx_pid);
  1158. if (rc < 0)
  1159. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1160. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1161. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1162. }
  1163. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1164. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1165. return 0;
  1166. }
  1167. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1168. struct snd_ctl_elem_value *ucontrol)
  1169. {
  1170. int value = ucontrol->value.integer.value[0];
  1171. u16 port_id = (u16)kcontrol->private_value;
  1172. pr_debug("%s: island mode = %d\n", __func__, value);
  1173. afe_set_island_mode_cfg(port_id, value);
  1174. return 0;
  1175. }
  1176. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1177. struct snd_ctl_elem_value *ucontrol)
  1178. {
  1179. int value;
  1180. u16 port_id = (u16)kcontrol->private_value;
  1181. afe_get_island_mode_cfg(port_id, &value);
  1182. ucontrol->value.integer.value[0] = value;
  1183. return 0;
  1184. }
  1185. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1186. {
  1187. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1188. kfree(knew);
  1189. }
  1190. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1191. const char *dai_name,
  1192. int dai_id, void *dai_data)
  1193. {
  1194. const char *mx_ctl_name = "TX island";
  1195. char *mixer_str = NULL;
  1196. int dai_str_len = 0, ctl_len = 0;
  1197. int rc = 0;
  1198. struct snd_kcontrol_new *knew = NULL;
  1199. struct snd_kcontrol *kctl = NULL;
  1200. dai_str_len = strlen(dai_name) + 1;
  1201. /* Add island related mixer controls */
  1202. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1203. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1204. if (!mixer_str)
  1205. return -ENOMEM;
  1206. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1207. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1208. if (!knew) {
  1209. kfree(mixer_str);
  1210. return -ENOMEM;
  1211. }
  1212. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1213. knew->info = snd_ctl_boolean_mono_info;
  1214. knew->get = msm_dai_q6_island_mode_get;
  1215. knew->put = msm_dai_q6_island_mode_put;
  1216. knew->name = mixer_str;
  1217. knew->private_value = dai_id;
  1218. kctl = snd_ctl_new1(knew, knew);
  1219. if (!kctl) {
  1220. kfree(knew);
  1221. kfree(mixer_str);
  1222. return -ENOMEM;
  1223. }
  1224. kctl->private_free = island_mx_ctl_private_free;
  1225. rc = snd_ctl_add(card, kctl);
  1226. if (rc < 0)
  1227. pr_err("%s: err add config ctl, DAI = %s\n",
  1228. __func__, dai_name);
  1229. kfree(mixer_str);
  1230. return rc;
  1231. }
  1232. /*
  1233. * For single CPU DAI registration, the dai id needs to be
  1234. * set explicitly in the dai probe as ASoC does not read
  1235. * the cpu->driver->id field rather it assigns the dai id
  1236. * from the device name that is in the form %s.%d. This dai
  1237. * id should be assigned to back-end AFE port id and used
  1238. * during dai prepare. For multiple dai registration, it
  1239. * is not required to call this function, however the dai->
  1240. * driver->id field must be defined and set to corresponding
  1241. * AFE Port id.
  1242. */
  1243. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1244. {
  1245. if (!dai->driver) {
  1246. dev_err(dai->dev, "DAI driver is not set\n");
  1247. return;
  1248. }
  1249. if (!dai->driver->id) {
  1250. dev_dbg(dai->dev, "DAI driver id is not set\n");
  1251. return;
  1252. }
  1253. dai->id = dai->driver->id;
  1254. }
  1255. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1256. {
  1257. int rc = 0;
  1258. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1259. if (!dai) {
  1260. pr_err("%s: Invalid params dai\n", __func__);
  1261. return -EINVAL;
  1262. }
  1263. if (!dai->dev) {
  1264. pr_err("%s: Invalid params dai dev\n", __func__);
  1265. return -EINVAL;
  1266. }
  1267. msm_dai_q6_set_dai_id(dai);
  1268. dai_data = dev_get_drvdata(dai->dev);
  1269. if (dai_data->is_island_dai)
  1270. rc = msm_dai_q6_add_island_mx_ctls(
  1271. dai->component->card->snd_card,
  1272. dai->name, dai_data->tx_pid,
  1273. (void *)dai_data);
  1274. rc = msm_dai_q6_dai_add_route(dai);
  1275. return rc;
  1276. }
  1277. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1278. .prepare = msm_dai_q6_auxpcm_prepare,
  1279. .trigger = msm_dai_q6_auxpcm_trigger,
  1280. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1281. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1282. };
  1283. static const struct snd_soc_component_driver
  1284. msm_dai_q6_aux_pcm_dai_component = {
  1285. .name = "msm-auxpcm-dev",
  1286. };
  1287. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1288. {
  1289. .playback = {
  1290. .stream_name = "AUX PCM Playback",
  1291. .aif_name = "AUX_PCM_RX",
  1292. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1293. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1294. .channels_min = 1,
  1295. .channels_max = 1,
  1296. .rate_max = 16000,
  1297. .rate_min = 8000,
  1298. },
  1299. .capture = {
  1300. .stream_name = "AUX PCM Capture",
  1301. .aif_name = "AUX_PCM_TX",
  1302. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1303. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1304. .channels_min = 1,
  1305. .channels_max = 1,
  1306. .rate_max = 16000,
  1307. .rate_min = 8000,
  1308. },
  1309. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1310. .name = "Pri AUX PCM",
  1311. .ops = &msm_dai_q6_auxpcm_ops,
  1312. .probe = msm_dai_q6_aux_pcm_probe,
  1313. .remove = msm_dai_q6_dai_auxpcm_remove,
  1314. },
  1315. {
  1316. .playback = {
  1317. .stream_name = "Sec AUX PCM Playback",
  1318. .aif_name = "SEC_AUX_PCM_RX",
  1319. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1320. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1321. .channels_min = 1,
  1322. .channels_max = 1,
  1323. .rate_max = 16000,
  1324. .rate_min = 8000,
  1325. },
  1326. .capture = {
  1327. .stream_name = "Sec AUX PCM Capture",
  1328. .aif_name = "SEC_AUX_PCM_TX",
  1329. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1330. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1331. .channels_min = 1,
  1332. .channels_max = 1,
  1333. .rate_max = 16000,
  1334. .rate_min = 8000,
  1335. },
  1336. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1337. .name = "Sec AUX PCM",
  1338. .ops = &msm_dai_q6_auxpcm_ops,
  1339. .probe = msm_dai_q6_aux_pcm_probe,
  1340. .remove = msm_dai_q6_dai_auxpcm_remove,
  1341. },
  1342. {
  1343. .playback = {
  1344. .stream_name = "Tert AUX PCM Playback",
  1345. .aif_name = "TERT_AUX_PCM_RX",
  1346. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1347. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1348. .channels_min = 1,
  1349. .channels_max = 1,
  1350. .rate_max = 16000,
  1351. .rate_min = 8000,
  1352. },
  1353. .capture = {
  1354. .stream_name = "Tert AUX PCM Capture",
  1355. .aif_name = "TERT_AUX_PCM_TX",
  1356. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1357. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1358. .channels_min = 1,
  1359. .channels_max = 1,
  1360. .rate_max = 16000,
  1361. .rate_min = 8000,
  1362. },
  1363. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1364. .name = "Tert AUX PCM",
  1365. .ops = &msm_dai_q6_auxpcm_ops,
  1366. .probe = msm_dai_q6_aux_pcm_probe,
  1367. .remove = msm_dai_q6_dai_auxpcm_remove,
  1368. },
  1369. {
  1370. .playback = {
  1371. .stream_name = "Quat AUX PCM Playback",
  1372. .aif_name = "QUAT_AUX_PCM_RX",
  1373. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1374. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1375. .channels_min = 1,
  1376. .channels_max = 1,
  1377. .rate_max = 16000,
  1378. .rate_min = 8000,
  1379. },
  1380. .capture = {
  1381. .stream_name = "Quat AUX PCM Capture",
  1382. .aif_name = "QUAT_AUX_PCM_TX",
  1383. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1384. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1385. .channels_min = 1,
  1386. .channels_max = 1,
  1387. .rate_max = 16000,
  1388. .rate_min = 8000,
  1389. },
  1390. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1391. .name = "Quat AUX PCM",
  1392. .ops = &msm_dai_q6_auxpcm_ops,
  1393. .probe = msm_dai_q6_aux_pcm_probe,
  1394. .remove = msm_dai_q6_dai_auxpcm_remove,
  1395. },
  1396. {
  1397. .playback = {
  1398. .stream_name = "Quin AUX PCM Playback",
  1399. .aif_name = "QUIN_AUX_PCM_RX",
  1400. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1401. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1402. .channels_min = 1,
  1403. .channels_max = 1,
  1404. .rate_max = 16000,
  1405. .rate_min = 8000,
  1406. },
  1407. .capture = {
  1408. .stream_name = "Quin AUX PCM Capture",
  1409. .aif_name = "QUIN_AUX_PCM_TX",
  1410. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1411. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1412. .channels_min = 1,
  1413. .channels_max = 1,
  1414. .rate_max = 16000,
  1415. .rate_min = 8000,
  1416. },
  1417. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1418. .name = "Quin AUX PCM",
  1419. .ops = &msm_dai_q6_auxpcm_ops,
  1420. .probe = msm_dai_q6_aux_pcm_probe,
  1421. .remove = msm_dai_q6_dai_auxpcm_remove,
  1422. },
  1423. {
  1424. .playback = {
  1425. .stream_name = "Sen AUX PCM Playback",
  1426. .aif_name = "SEN_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 = "Sen AUX PCM Capture",
  1436. .aif_name = "SEN_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_SEN_AUXPCM_DT_DEV_ID,
  1445. .name = "Sen 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. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1452. struct snd_ctl_elem_value *ucontrol)
  1453. {
  1454. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1455. int value = ucontrol->value.integer.value[0];
  1456. dai_data->spdif_port.cfg.data_format = value;
  1457. pr_debug("%s: value = %d\n", __func__, value);
  1458. return 0;
  1459. }
  1460. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1461. struct snd_ctl_elem_value *ucontrol)
  1462. {
  1463. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1464. ucontrol->value.integer.value[0] =
  1465. dai_data->spdif_port.cfg.data_format;
  1466. return 0;
  1467. }
  1468. static int msm_dai_q6_spdif_source_put(struct snd_kcontrol *kcontrol,
  1469. struct snd_ctl_elem_value *ucontrol)
  1470. {
  1471. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1472. int value = ucontrol->value.integer.value[0];
  1473. dai_data->spdif_port.cfg.src_sel = value;
  1474. pr_debug("%s: value = %d\n", __func__, value);
  1475. return 0;
  1476. }
  1477. static int msm_dai_q6_spdif_source_get(struct snd_kcontrol *kcontrol,
  1478. struct snd_ctl_elem_value *ucontrol)
  1479. {
  1480. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1481. ucontrol->value.integer.value[0] =
  1482. dai_data->spdif_port.cfg.src_sel;
  1483. return 0;
  1484. }
  1485. static const char * const spdif_format[] = {
  1486. "LPCM",
  1487. "Compr"
  1488. };
  1489. static const char * const spdif_source[] = {
  1490. "Optical", "EXT-ARC", "Coaxial", "VT-ARC"
  1491. };
  1492. static const struct soc_enum spdif_rx_config_enum[] = {
  1493. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1494. };
  1495. static const struct soc_enum spdif_tx_config_enum[] = {
  1496. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_source), spdif_source),
  1497. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1498. };
  1499. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1500. struct snd_ctl_elem_value *ucontrol)
  1501. {
  1502. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1503. int ret = 0;
  1504. dai_data->spdif_port.ch_status.status_type =
  1505. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1506. memset(dai_data->spdif_port.ch_status.status_mask,
  1507. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1508. dai_data->spdif_port.ch_status.status_mask[0] =
  1509. CHANNEL_STATUS_MASK;
  1510. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1511. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1512. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1513. pr_debug("%s: Port already started. Dynamic update\n",
  1514. __func__);
  1515. ret = afe_send_spdif_ch_status_cfg(
  1516. &dai_data->spdif_port.ch_status,
  1517. dai_data->port_id);
  1518. }
  1519. return ret;
  1520. }
  1521. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1522. struct snd_ctl_elem_value *ucontrol)
  1523. {
  1524. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1525. memcpy(ucontrol->value.iec958.status,
  1526. dai_data->spdif_port.ch_status.status_bits,
  1527. CHANNEL_STATUS_SIZE);
  1528. return 0;
  1529. }
  1530. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1531. struct snd_ctl_elem_info *uinfo)
  1532. {
  1533. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1534. uinfo->count = 1;
  1535. return 0;
  1536. }
  1537. static const struct snd_kcontrol_new spdif_rx_config_controls[] = {
  1538. /* Primary SPDIF output */
  1539. {
  1540. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1541. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1542. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1543. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1544. .info = msm_dai_q6_spdif_chstatus_info,
  1545. .get = msm_dai_q6_spdif_chstatus_get,
  1546. .put = msm_dai_q6_spdif_chstatus_put,
  1547. },
  1548. SOC_ENUM_EXT("PRI SPDIF RX Format", spdif_rx_config_enum[0],
  1549. msm_dai_q6_spdif_format_get,
  1550. msm_dai_q6_spdif_format_put),
  1551. /* Secondary SPDIF output */
  1552. {
  1553. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1554. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1555. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1556. .name = SNDRV_CTL_NAME_IEC958("SEC", PLAYBACK, PCM_STREAM),
  1557. .info = msm_dai_q6_spdif_chstatus_info,
  1558. .get = msm_dai_q6_spdif_chstatus_get,
  1559. .put = msm_dai_q6_spdif_chstatus_put,
  1560. },
  1561. SOC_ENUM_EXT("SEC SPDIF RX Format", spdif_rx_config_enum[0],
  1562. msm_dai_q6_spdif_format_get,
  1563. msm_dai_q6_spdif_format_put)
  1564. };
  1565. static const struct snd_kcontrol_new spdif_tx_config_controls[] = {
  1566. SOC_ENUM_EXT("PRI SPDIF TX Source", spdif_tx_config_enum[0],
  1567. msm_dai_q6_spdif_source_get,
  1568. msm_dai_q6_spdif_source_put),
  1569. SOC_ENUM_EXT("PRI SPDIF TX Format", spdif_tx_config_enum[1],
  1570. msm_dai_q6_spdif_format_get,
  1571. msm_dai_q6_spdif_format_put),
  1572. SOC_ENUM_EXT("SEC SPDIF TX Source", spdif_tx_config_enum[0],
  1573. msm_dai_q6_spdif_source_get,
  1574. msm_dai_q6_spdif_source_put),
  1575. SOC_ENUM_EXT("SEC SPDIF TX Format", spdif_tx_config_enum[1],
  1576. msm_dai_q6_spdif_format_get,
  1577. msm_dai_q6_spdif_format_put)
  1578. };
  1579. static void msm_dai_q6_spdif_process_event(uint32_t opcode, uint32_t token,
  1580. uint32_t *payload, void *private_data)
  1581. {
  1582. struct msm_dai_q6_spdif_event_msg *evt;
  1583. struct msm_dai_q6_spdif_dai_data *dai_data;
  1584. evt = (struct msm_dai_q6_spdif_event_msg *)payload;
  1585. dai_data = (struct msm_dai_q6_spdif_dai_data *)private_data;
  1586. pr_debug("%s: old state %d, fmt %d, rate %d\n",
  1587. __func__, dai_data->fmt_event.status,
  1588. dai_data->fmt_event.data_format,
  1589. dai_data->fmt_event.sample_rate);
  1590. pr_debug("%s: new state %d, fmt %d, rate %d\n",
  1591. __func__, evt->fmt_event.status,
  1592. evt->fmt_event.data_format,
  1593. evt->fmt_event.sample_rate);
  1594. dai_data->fmt_event.status = evt->fmt_event.status;
  1595. dai_data->fmt_event.data_format = evt->fmt_event.data_format;
  1596. dai_data->fmt_event.sample_rate = evt->fmt_event.sample_rate;
  1597. }
  1598. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1599. struct snd_pcm_hw_params *params,
  1600. struct snd_soc_dai *dai)
  1601. {
  1602. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1603. dai_data->channels = params_channels(params);
  1604. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1605. switch (params_format(params)) {
  1606. case SNDRV_PCM_FORMAT_S16_LE:
  1607. dai_data->spdif_port.cfg.bit_width = 16;
  1608. break;
  1609. case SNDRV_PCM_FORMAT_S24_LE:
  1610. case SNDRV_PCM_FORMAT_S24_3LE:
  1611. dai_data->spdif_port.cfg.bit_width = 24;
  1612. break;
  1613. default:
  1614. pr_err("%s: format %d\n",
  1615. __func__, params_format(params));
  1616. return -EINVAL;
  1617. }
  1618. dai_data->rate = params_rate(params);
  1619. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1620. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1621. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1622. AFE_API_VERSION_SPDIF_CONFIG_V2;
  1623. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1624. dai_data->channels, dai_data->rate,
  1625. dai_data->spdif_port.cfg.bit_width);
  1626. dai_data->spdif_port.cfg.reserved = 0;
  1627. return 0;
  1628. }
  1629. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1630. struct snd_soc_dai *dai)
  1631. {
  1632. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1633. int rc = 0;
  1634. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1635. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1636. __func__, *dai_data->status_mask);
  1637. return;
  1638. }
  1639. rc = afe_close(dai->id);
  1640. if (rc < 0)
  1641. dev_err(dai->dev, "fail to close AFE port\n");
  1642. dai_data->fmt_event.status = 0; /* report invalid line state */
  1643. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1644. *dai_data->status_mask);
  1645. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1646. }
  1647. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1648. struct snd_soc_dai *dai)
  1649. {
  1650. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1651. int rc = 0;
  1652. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1653. rc = afe_spdif_reg_event_cfg(dai->id,
  1654. AFE_MODULE_REGISTER_EVENT_FLAG,
  1655. msm_dai_q6_spdif_process_event,
  1656. dai_data);
  1657. if (rc < 0)
  1658. dev_err(dai->dev,
  1659. "fail to register event for port 0x%x\n",
  1660. dai->id);
  1661. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1662. dai_data->rate);
  1663. if (rc < 0)
  1664. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1665. dai->id);
  1666. else
  1667. set_bit(STATUS_PORT_STARTED,
  1668. dai_data->status_mask);
  1669. }
  1670. return rc;
  1671. }
  1672. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_state(struct device *dev,
  1673. struct device_attribute *attr, char *buf)
  1674. {
  1675. ssize_t ret;
  1676. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1677. if (!dai_data) {
  1678. pr_err("%s: invalid input\n", __func__);
  1679. return -EINVAL;
  1680. }
  1681. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1682. dai_data->fmt_event.status);
  1683. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.status);
  1684. return ret;
  1685. }
  1686. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_format(struct device *dev,
  1687. struct device_attribute *attr, char *buf)
  1688. {
  1689. ssize_t ret;
  1690. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1691. if (!dai_data) {
  1692. pr_err("%s: invalid input\n", __func__);
  1693. return -EINVAL;
  1694. }
  1695. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1696. dai_data->fmt_event.data_format);
  1697. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.data_format);
  1698. return ret;
  1699. }
  1700. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_rate(struct device *dev,
  1701. struct device_attribute *attr, char *buf)
  1702. {
  1703. ssize_t ret;
  1704. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1705. if (!dai_data) {
  1706. pr_err("%s: invalid input\n", __func__);
  1707. return -EINVAL;
  1708. }
  1709. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1710. dai_data->fmt_event.sample_rate);
  1711. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.sample_rate);
  1712. return ret;
  1713. }
  1714. static DEVICE_ATTR(audio_state, 0444, msm_dai_q6_spdif_sysfs_rda_audio_state,
  1715. NULL);
  1716. static DEVICE_ATTR(audio_format, 0444, msm_dai_q6_spdif_sysfs_rda_audio_format,
  1717. NULL);
  1718. static DEVICE_ATTR(audio_rate, 0444, msm_dai_q6_spdif_sysfs_rda_audio_rate,
  1719. NULL);
  1720. static struct attribute *msm_dai_q6_spdif_fs_attrs[] = {
  1721. &dev_attr_audio_state.attr,
  1722. &dev_attr_audio_format.attr,
  1723. &dev_attr_audio_rate.attr,
  1724. NULL,
  1725. };
  1726. static struct attribute_group msm_dai_q6_spdif_fs_attrs_group = {
  1727. .attrs = msm_dai_q6_spdif_fs_attrs,
  1728. };
  1729. static int msm_dai_q6_spdif_sysfs_create(struct snd_soc_dai *dai,
  1730. struct msm_dai_q6_spdif_dai_data *dai_data)
  1731. {
  1732. int rc;
  1733. rc = sysfs_create_group(&dai->dev->kobj,
  1734. &msm_dai_q6_spdif_fs_attrs_group);
  1735. if (rc) {
  1736. pr_err("%s: failed, rc=%d\n", __func__, rc);
  1737. return rc;
  1738. }
  1739. dai_data->kobj = &dai->dev->kobj;
  1740. return 0;
  1741. }
  1742. static void msm_dai_q6_spdif_sysfs_remove(struct snd_soc_dai *dai,
  1743. struct msm_dai_q6_spdif_dai_data *dai_data)
  1744. {
  1745. if (dai_data->kobj)
  1746. sysfs_remove_group(dai_data->kobj,
  1747. &msm_dai_q6_spdif_fs_attrs_group);
  1748. dai_data->kobj = NULL;
  1749. }
  1750. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1751. {
  1752. struct msm_dai_q6_spdif_dai_data *dai_data;
  1753. int rc = 0;
  1754. struct snd_soc_dapm_route intercon;
  1755. struct snd_soc_dapm_context *dapm;
  1756. if (!dai) {
  1757. pr_err("%s: dai not found!!\n", __func__);
  1758. return -EINVAL;
  1759. }
  1760. if (!dai->dev) {
  1761. pr_err("%s: Invalid params dai dev\n", __func__);
  1762. return -EINVAL;
  1763. }
  1764. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1765. GFP_KERNEL);
  1766. if (!dai_data)
  1767. return -ENOMEM;
  1768. else
  1769. dev_set_drvdata(dai->dev, dai_data);
  1770. msm_dai_q6_set_dai_id(dai);
  1771. dai_data->port_id = dai->id;
  1772. switch (dai->id) {
  1773. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  1774. rc = snd_ctl_add(dai->component->card->snd_card,
  1775. snd_ctl_new1(&spdif_rx_config_controls[1],
  1776. dai_data));
  1777. break;
  1778. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  1779. rc = snd_ctl_add(dai->component->card->snd_card,
  1780. snd_ctl_new1(&spdif_rx_config_controls[3],
  1781. dai_data));
  1782. break;
  1783. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  1784. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1785. rc = snd_ctl_add(dai->component->card->snd_card,
  1786. snd_ctl_new1(&spdif_tx_config_controls[0],
  1787. dai_data));
  1788. rc = snd_ctl_add(dai->component->card->snd_card,
  1789. snd_ctl_new1(&spdif_tx_config_controls[1],
  1790. dai_data));
  1791. break;
  1792. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  1793. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1794. rc = snd_ctl_add(dai->component->card->snd_card,
  1795. snd_ctl_new1(&spdif_tx_config_controls[2],
  1796. dai_data));
  1797. rc = snd_ctl_add(dai->component->card->snd_card,
  1798. snd_ctl_new1(&spdif_tx_config_controls[3],
  1799. dai_data));
  1800. break;
  1801. }
  1802. if (rc < 0)
  1803. dev_err(dai->dev,
  1804. "%s: err add config ctl, DAI = %s\n",
  1805. __func__, dai->name);
  1806. dapm = snd_soc_component_get_dapm(dai->component);
  1807. memset(&intercon, 0, sizeof(intercon));
  1808. if (!rc && dai && dai->driver) {
  1809. if (dai->driver->playback.stream_name &&
  1810. dai->driver->playback.aif_name) {
  1811. dev_dbg(dai->dev, "%s: add route for widget %s",
  1812. __func__, dai->driver->playback.stream_name);
  1813. intercon.source = dai->driver->playback.aif_name;
  1814. intercon.sink = dai->driver->playback.stream_name;
  1815. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1816. __func__, intercon.source, intercon.sink);
  1817. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1818. }
  1819. if (dai->driver->capture.stream_name &&
  1820. dai->driver->capture.aif_name) {
  1821. dev_dbg(dai->dev, "%s: add route for widget %s",
  1822. __func__, dai->driver->capture.stream_name);
  1823. intercon.sink = dai->driver->capture.aif_name;
  1824. intercon.source = dai->driver->capture.stream_name;
  1825. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1826. __func__, intercon.source, intercon.sink);
  1827. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1828. }
  1829. }
  1830. return rc;
  1831. }
  1832. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1833. {
  1834. struct msm_dai_q6_spdif_dai_data *dai_data;
  1835. int rc;
  1836. dai_data = dev_get_drvdata(dai->dev);
  1837. /* If AFE port is still up, close it */
  1838. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1839. rc = afe_spdif_reg_event_cfg(dai->id,
  1840. AFE_MODULE_DEREGISTER_EVENT_FLAG,
  1841. NULL,
  1842. dai_data);
  1843. if (rc < 0)
  1844. dev_err(dai->dev,
  1845. "fail to deregister event for port 0x%x\n",
  1846. dai->id);
  1847. rc = afe_close(dai->id); /* can block */
  1848. if (rc < 0)
  1849. dev_err(dai->dev, "fail to close AFE port\n");
  1850. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1851. }
  1852. msm_dai_q6_spdif_sysfs_remove(dai, dai_data);
  1853. kfree(dai_data);
  1854. return 0;
  1855. }
  1856. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1857. .prepare = msm_dai_q6_spdif_prepare,
  1858. .hw_params = msm_dai_q6_spdif_hw_params,
  1859. .shutdown = msm_dai_q6_spdif_shutdown,
  1860. };
  1861. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai[] = {
  1862. {
  1863. .playback = {
  1864. .stream_name = "Primary SPDIF Playback",
  1865. .aif_name = "PRI_SPDIF_RX",
  1866. .rates = SNDRV_PCM_RATE_32000 |
  1867. SNDRV_PCM_RATE_44100 |
  1868. SNDRV_PCM_RATE_48000 |
  1869. SNDRV_PCM_RATE_88200 |
  1870. SNDRV_PCM_RATE_96000 |
  1871. SNDRV_PCM_RATE_176400 |
  1872. SNDRV_PCM_RATE_192000,
  1873. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1874. SNDRV_PCM_FMTBIT_S24_LE,
  1875. .channels_min = 1,
  1876. .channels_max = 2,
  1877. .rate_min = 32000,
  1878. .rate_max = 192000,
  1879. },
  1880. .name = "PRI_SPDIF_RX",
  1881. .ops = &msm_dai_q6_spdif_ops,
  1882. .id = AFE_PORT_ID_PRIMARY_SPDIF_RX,
  1883. .probe = msm_dai_q6_spdif_dai_probe,
  1884. .remove = msm_dai_q6_spdif_dai_remove,
  1885. },
  1886. {
  1887. .playback = {
  1888. .stream_name = "Secondary SPDIF Playback",
  1889. .aif_name = "SEC_SPDIF_RX",
  1890. .rates = SNDRV_PCM_RATE_32000 |
  1891. SNDRV_PCM_RATE_44100 |
  1892. SNDRV_PCM_RATE_48000 |
  1893. SNDRV_PCM_RATE_88200 |
  1894. SNDRV_PCM_RATE_96000 |
  1895. SNDRV_PCM_RATE_176400 |
  1896. SNDRV_PCM_RATE_192000,
  1897. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1898. SNDRV_PCM_FMTBIT_S24_LE,
  1899. .channels_min = 1,
  1900. .channels_max = 2,
  1901. .rate_min = 32000,
  1902. .rate_max = 192000,
  1903. },
  1904. .name = "SEC_SPDIF_RX",
  1905. .ops = &msm_dai_q6_spdif_ops,
  1906. .id = AFE_PORT_ID_SECONDARY_SPDIF_RX,
  1907. .probe = msm_dai_q6_spdif_dai_probe,
  1908. .remove = msm_dai_q6_spdif_dai_remove,
  1909. },
  1910. };
  1911. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_tx_dai[] = {
  1912. {
  1913. .capture = {
  1914. .stream_name = "Primary SPDIF Capture",
  1915. .aif_name = "PRI_SPDIF_TX",
  1916. .rates = SNDRV_PCM_RATE_32000 |
  1917. SNDRV_PCM_RATE_44100 |
  1918. SNDRV_PCM_RATE_48000 |
  1919. SNDRV_PCM_RATE_88200 |
  1920. SNDRV_PCM_RATE_96000 |
  1921. SNDRV_PCM_RATE_176400 |
  1922. SNDRV_PCM_RATE_192000,
  1923. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1924. SNDRV_PCM_FMTBIT_S24_LE,
  1925. .channels_min = 1,
  1926. .channels_max = 2,
  1927. .rate_min = 32000,
  1928. .rate_max = 192000,
  1929. },
  1930. .name = "PRI_SPDIF_TX",
  1931. .ops = &msm_dai_q6_spdif_ops,
  1932. .id = AFE_PORT_ID_PRIMARY_SPDIF_TX,
  1933. .probe = msm_dai_q6_spdif_dai_probe,
  1934. .remove = msm_dai_q6_spdif_dai_remove,
  1935. },
  1936. {
  1937. .capture = {
  1938. .stream_name = "Secondary SPDIF Capture",
  1939. .aif_name = "SEC_SPDIF_TX",
  1940. .rates = SNDRV_PCM_RATE_32000 |
  1941. SNDRV_PCM_RATE_44100 |
  1942. SNDRV_PCM_RATE_48000 |
  1943. SNDRV_PCM_RATE_88200 |
  1944. SNDRV_PCM_RATE_96000 |
  1945. SNDRV_PCM_RATE_176400 |
  1946. SNDRV_PCM_RATE_192000,
  1947. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1948. SNDRV_PCM_FMTBIT_S24_LE,
  1949. .channels_min = 1,
  1950. .channels_max = 2,
  1951. .rate_min = 32000,
  1952. .rate_max = 192000,
  1953. },
  1954. .name = "SEC_SPDIF_TX",
  1955. .ops = &msm_dai_q6_spdif_ops,
  1956. .id = AFE_PORT_ID_SECONDARY_SPDIF_TX,
  1957. .probe = msm_dai_q6_spdif_dai_probe,
  1958. .remove = msm_dai_q6_spdif_dai_remove,
  1959. },
  1960. };
  1961. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  1962. .name = "msm-dai-q6-spdif",
  1963. };
  1964. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  1965. struct snd_soc_dai *dai)
  1966. {
  1967. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1968. int rc = 0;
  1969. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1970. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  1971. int bitwidth = 0;
  1972. switch (dai_data->afe_rx_in_bitformat) {
  1973. case SNDRV_PCM_FORMAT_S32_LE:
  1974. bitwidth = 32;
  1975. break;
  1976. case SNDRV_PCM_FORMAT_S24_LE:
  1977. bitwidth = 24;
  1978. break;
  1979. case SNDRV_PCM_FORMAT_S16_LE:
  1980. default:
  1981. bitwidth = 16;
  1982. break;
  1983. }
  1984. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  1985. __func__, dai_data->enc_config.format);
  1986. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1987. dai_data->rate,
  1988. dai_data->afe_rx_in_channels,
  1989. bitwidth,
  1990. &dai_data->enc_config, NULL);
  1991. if (rc < 0)
  1992. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  1993. __func__, rc);
  1994. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  1995. int bitwidth = 0;
  1996. /*
  1997. * If bitwidth is not configured set default value to
  1998. * zero, so that decoder port config uses slim device
  1999. * bit width value in afe decoder config.
  2000. */
  2001. switch (dai_data->afe_tx_out_bitformat) {
  2002. case SNDRV_PCM_FORMAT_S32_LE:
  2003. bitwidth = 32;
  2004. break;
  2005. case SNDRV_PCM_FORMAT_S24_LE:
  2006. bitwidth = 24;
  2007. break;
  2008. case SNDRV_PCM_FORMAT_S16_LE:
  2009. bitwidth = 16;
  2010. break;
  2011. default:
  2012. bitwidth = 0;
  2013. break;
  2014. }
  2015. pr_debug("%s: calling AFE_PORT_START_V2 with dec format: %d\n",
  2016. __func__, dai_data->dec_config.format);
  2017. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  2018. dai_data->rate,
  2019. dai_data->afe_tx_out_channels,
  2020. bitwidth,
  2021. NULL, &dai_data->dec_config);
  2022. if (rc < 0) {
  2023. pr_err("%s: fail to open AFE port 0x%x\n",
  2024. __func__, dai->id);
  2025. }
  2026. } else {
  2027. rc = afe_port_start(dai->id, &dai_data->port_config,
  2028. dai_data->rate);
  2029. }
  2030. if (rc < 0)
  2031. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  2032. dai->id);
  2033. else
  2034. set_bit(STATUS_PORT_STARTED,
  2035. dai_data->status_mask);
  2036. }
  2037. return rc;
  2038. }
  2039. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  2040. struct snd_soc_dai *dai, int stream)
  2041. {
  2042. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2043. dai_data->channels = params_channels(params);
  2044. switch (dai_data->channels) {
  2045. case 2:
  2046. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2047. break;
  2048. case 1:
  2049. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2050. break;
  2051. default:
  2052. return -EINVAL;
  2053. pr_err("%s: err channels %d\n",
  2054. __func__, dai_data->channels);
  2055. break;
  2056. }
  2057. switch (params_format(params)) {
  2058. case SNDRV_PCM_FORMAT_S16_LE:
  2059. case SNDRV_PCM_FORMAT_SPECIAL:
  2060. dai_data->port_config.i2s.bit_width = 16;
  2061. break;
  2062. case SNDRV_PCM_FORMAT_S24_LE:
  2063. case SNDRV_PCM_FORMAT_S24_3LE:
  2064. dai_data->port_config.i2s.bit_width = 24;
  2065. break;
  2066. default:
  2067. pr_err("%s: format %d\n",
  2068. __func__, params_format(params));
  2069. return -EINVAL;
  2070. }
  2071. dai_data->rate = params_rate(params);
  2072. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2073. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2074. AFE_API_VERSION_I2S_CONFIG;
  2075. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2076. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  2077. dai_data->channels, dai_data->rate);
  2078. dai_data->port_config.i2s.channel_mode = 1;
  2079. return 0;
  2080. }
  2081. static u16 num_of_bits_set(u16 sd_line_mask)
  2082. {
  2083. u8 num_bits_set = 0;
  2084. while (sd_line_mask) {
  2085. num_bits_set++;
  2086. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  2087. }
  2088. return num_bits_set;
  2089. }
  2090. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  2091. struct snd_soc_dai *dai, int stream)
  2092. {
  2093. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2094. struct msm_i2s_data *i2s_pdata =
  2095. (struct msm_i2s_data *) dai->dev->platform_data;
  2096. dai_data->channels = params_channels(params);
  2097. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  2098. switch (dai_data->channels) {
  2099. case 2:
  2100. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2101. break;
  2102. case 1:
  2103. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2104. break;
  2105. default:
  2106. pr_warn("%s: greater than stereo has not been validated %d",
  2107. __func__, dai_data->channels);
  2108. break;
  2109. }
  2110. }
  2111. dai_data->rate = params_rate(params);
  2112. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2113. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2114. AFE_API_VERSION_I2S_CONFIG;
  2115. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2116. /* Q6 only supports 16 as now */
  2117. dai_data->port_config.i2s.bit_width = 16;
  2118. dai_data->port_config.i2s.channel_mode = 1;
  2119. return 0;
  2120. }
  2121. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  2122. struct snd_soc_dai *dai, int stream)
  2123. {
  2124. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2125. dai_data->channels = params_channels(params);
  2126. dai_data->rate = params_rate(params);
  2127. switch (params_format(params)) {
  2128. case SNDRV_PCM_FORMAT_S16_LE:
  2129. case SNDRV_PCM_FORMAT_SPECIAL:
  2130. dai_data->port_config.slim_sch.bit_width = 16;
  2131. break;
  2132. case SNDRV_PCM_FORMAT_S24_LE:
  2133. case SNDRV_PCM_FORMAT_S24_3LE:
  2134. dai_data->port_config.slim_sch.bit_width = 24;
  2135. break;
  2136. case SNDRV_PCM_FORMAT_S32_LE:
  2137. dai_data->port_config.slim_sch.bit_width = 32;
  2138. break;
  2139. default:
  2140. pr_err("%s: format %d\n",
  2141. __func__, params_format(params));
  2142. return -EINVAL;
  2143. }
  2144. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  2145. AFE_API_VERSION_SLIMBUS_CONFIG;
  2146. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  2147. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  2148. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  2149. "num_channel %hu shared_ch_mapping[0] %hu\n"
  2150. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  2151. "sample_rate %d\n", __func__,
  2152. dai_data->port_config.slim_sch.slimbus_dev_id,
  2153. dai_data->port_config.slim_sch.bit_width,
  2154. dai_data->port_config.slim_sch.data_format,
  2155. dai_data->port_config.slim_sch.num_channels,
  2156. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2157. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  2158. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  2159. dai_data->rate);
  2160. return 0;
  2161. }
  2162. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  2163. struct snd_soc_dai *dai, int stream)
  2164. {
  2165. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2166. dai_data->channels = params_channels(params);
  2167. dai_data->rate = params_rate(params);
  2168. switch (params_format(params)) {
  2169. case SNDRV_PCM_FORMAT_S16_LE:
  2170. case SNDRV_PCM_FORMAT_SPECIAL:
  2171. dai_data->port_config.usb_audio.bit_width = 16;
  2172. break;
  2173. case SNDRV_PCM_FORMAT_S24_LE:
  2174. case SNDRV_PCM_FORMAT_S24_3LE:
  2175. dai_data->port_config.usb_audio.bit_width = 24;
  2176. break;
  2177. case SNDRV_PCM_FORMAT_S32_LE:
  2178. dai_data->port_config.usb_audio.bit_width = 32;
  2179. break;
  2180. default:
  2181. dev_err(dai->dev, "%s: invalid format %d\n",
  2182. __func__, params_format(params));
  2183. return -EINVAL;
  2184. }
  2185. dai_data->port_config.usb_audio.cfg_minor_version =
  2186. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  2187. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  2188. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  2189. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  2190. "num_channel %hu sample_rate %d\n", __func__,
  2191. dai_data->port_config.usb_audio.dev_token,
  2192. dai_data->port_config.usb_audio.bit_width,
  2193. dai_data->port_config.usb_audio.data_format,
  2194. dai_data->port_config.usb_audio.num_channels,
  2195. dai_data->port_config.usb_audio.sample_rate);
  2196. return 0;
  2197. }
  2198. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  2199. struct snd_soc_dai *dai, int stream)
  2200. {
  2201. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2202. dai_data->channels = params_channels(params);
  2203. dai_data->rate = params_rate(params);
  2204. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  2205. dai_data->channels, dai_data->rate);
  2206. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  2207. pr_debug("%s: setting bt_fm parameters\n", __func__);
  2208. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  2209. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  2210. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  2211. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  2212. dai_data->port_config.int_bt_fm.bit_width = 16;
  2213. return 0;
  2214. }
  2215. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  2216. struct snd_soc_dai *dai)
  2217. {
  2218. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2219. dai_data->rate = params_rate(params);
  2220. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  2221. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  2222. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  2223. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  2224. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  2225. AFE_API_VERSION_RT_PROXY_CONFIG;
  2226. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  2227. dai_data->port_config.rtproxy.interleaved = 1;
  2228. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  2229. dai_data->port_config.rtproxy.jitter_allowance =
  2230. dai_data->port_config.rtproxy.frame_size/2;
  2231. dai_data->port_config.rtproxy.low_water_mark = 0;
  2232. dai_data->port_config.rtproxy.high_water_mark = 0;
  2233. return 0;
  2234. }
  2235. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  2236. struct snd_soc_dai *dai, int stream)
  2237. {
  2238. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2239. dai_data->channels = params_channels(params);
  2240. dai_data->rate = params_rate(params);
  2241. /* Q6 only supports 16 as now */
  2242. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  2243. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  2244. dai_data->port_config.pseudo_port.num_channels =
  2245. params_channels(params);
  2246. dai_data->port_config.pseudo_port.bit_width = 16;
  2247. dai_data->port_config.pseudo_port.data_format = 0;
  2248. dai_data->port_config.pseudo_port.timing_mode =
  2249. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  2250. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  2251. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  2252. "timing Mode %hu sample_rate %d\n", __func__,
  2253. dai_data->port_config.pseudo_port.bit_width,
  2254. dai_data->port_config.pseudo_port.num_channels,
  2255. dai_data->port_config.pseudo_port.data_format,
  2256. dai_data->port_config.pseudo_port.timing_mode,
  2257. dai_data->port_config.pseudo_port.sample_rate);
  2258. return 0;
  2259. }
  2260. /* Current implementation assumes hw_param is called once
  2261. * This may not be the case but what to do when ADM and AFE
  2262. * port are already opened and parameter changes
  2263. */
  2264. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  2265. struct snd_pcm_hw_params *params,
  2266. struct snd_soc_dai *dai)
  2267. {
  2268. int rc = 0;
  2269. switch (dai->id) {
  2270. case PRIMARY_I2S_TX:
  2271. case PRIMARY_I2S_RX:
  2272. case SECONDARY_I2S_RX:
  2273. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  2274. break;
  2275. case MI2S_RX:
  2276. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  2277. break;
  2278. case SLIMBUS_0_RX:
  2279. case SLIMBUS_1_RX:
  2280. case SLIMBUS_2_RX:
  2281. case SLIMBUS_3_RX:
  2282. case SLIMBUS_4_RX:
  2283. case SLIMBUS_5_RX:
  2284. case SLIMBUS_6_RX:
  2285. case SLIMBUS_7_RX:
  2286. case SLIMBUS_8_RX:
  2287. case SLIMBUS_9_RX:
  2288. case SLIMBUS_0_TX:
  2289. case SLIMBUS_1_TX:
  2290. case SLIMBUS_2_TX:
  2291. case SLIMBUS_3_TX:
  2292. case SLIMBUS_4_TX:
  2293. case SLIMBUS_5_TX:
  2294. case SLIMBUS_6_TX:
  2295. case SLIMBUS_7_TX:
  2296. case SLIMBUS_8_TX:
  2297. case SLIMBUS_9_TX:
  2298. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  2299. substream->stream);
  2300. break;
  2301. case INT_BT_SCO_RX:
  2302. case INT_BT_SCO_TX:
  2303. case INT_BT_A2DP_RX:
  2304. case INT_FM_RX:
  2305. case INT_FM_TX:
  2306. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  2307. break;
  2308. case AFE_PORT_ID_USB_RX:
  2309. case AFE_PORT_ID_USB_TX:
  2310. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  2311. substream->stream);
  2312. break;
  2313. case RT_PROXY_DAI_001_TX:
  2314. case RT_PROXY_DAI_001_RX:
  2315. case RT_PROXY_DAI_002_TX:
  2316. case RT_PROXY_DAI_002_RX:
  2317. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  2318. break;
  2319. case VOICE_PLAYBACK_TX:
  2320. case VOICE2_PLAYBACK_TX:
  2321. case VOICE_RECORD_RX:
  2322. case VOICE_RECORD_TX:
  2323. rc = msm_dai_q6_pseudo_port_hw_params(params,
  2324. dai, substream->stream);
  2325. break;
  2326. default:
  2327. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  2328. rc = -EINVAL;
  2329. break;
  2330. }
  2331. return rc;
  2332. }
  2333. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  2334. struct snd_soc_dai *dai)
  2335. {
  2336. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2337. int rc = 0;
  2338. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2339. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2340. rc = afe_close(dai->id); /* can block */
  2341. if (rc < 0)
  2342. dev_err(dai->dev, "fail to close AFE port\n");
  2343. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  2344. *dai_data->status_mask);
  2345. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2346. }
  2347. }
  2348. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2349. {
  2350. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2351. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2352. case SND_SOC_DAIFMT_CBS_CFS:
  2353. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  2354. break;
  2355. case SND_SOC_DAIFMT_CBM_CFM:
  2356. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  2357. break;
  2358. default:
  2359. pr_err("%s: fmt 0x%x\n",
  2360. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2361. return -EINVAL;
  2362. }
  2363. return 0;
  2364. }
  2365. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2366. {
  2367. int rc = 0;
  2368. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  2369. dai->id, fmt);
  2370. switch (dai->id) {
  2371. case PRIMARY_I2S_TX:
  2372. case PRIMARY_I2S_RX:
  2373. case MI2S_RX:
  2374. case SECONDARY_I2S_RX:
  2375. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  2376. break;
  2377. default:
  2378. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2379. rc = -EINVAL;
  2380. break;
  2381. }
  2382. return rc;
  2383. }
  2384. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  2385. unsigned int tx_num, unsigned int *tx_slot,
  2386. unsigned int rx_num, unsigned int *rx_slot)
  2387. {
  2388. int rc = 0;
  2389. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2390. unsigned int i = 0;
  2391. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  2392. switch (dai->id) {
  2393. case SLIMBUS_0_RX:
  2394. case SLIMBUS_1_RX:
  2395. case SLIMBUS_2_RX:
  2396. case SLIMBUS_3_RX:
  2397. case SLIMBUS_4_RX:
  2398. case SLIMBUS_5_RX:
  2399. case SLIMBUS_6_RX:
  2400. case SLIMBUS_7_RX:
  2401. case SLIMBUS_8_RX:
  2402. case SLIMBUS_9_RX:
  2403. /*
  2404. * channel number to be between 128 and 255.
  2405. * For RX port use channel numbers
  2406. * from 138 to 144 for pre-Taiko
  2407. * from 144 to 159 for Taiko
  2408. */
  2409. if (!rx_slot) {
  2410. pr_err("%s: rx slot not found\n", __func__);
  2411. return -EINVAL;
  2412. }
  2413. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2414. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  2415. return -EINVAL;
  2416. }
  2417. for (i = 0; i < rx_num; i++) {
  2418. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2419. rx_slot[i];
  2420. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2421. __func__, i, rx_slot[i]);
  2422. }
  2423. dai_data->port_config.slim_sch.num_channels = rx_num;
  2424. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  2425. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  2426. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2427. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2428. break;
  2429. case SLIMBUS_0_TX:
  2430. case SLIMBUS_1_TX:
  2431. case SLIMBUS_2_TX:
  2432. case SLIMBUS_3_TX:
  2433. case SLIMBUS_4_TX:
  2434. case SLIMBUS_5_TX:
  2435. case SLIMBUS_6_TX:
  2436. case SLIMBUS_7_TX:
  2437. case SLIMBUS_8_TX:
  2438. case SLIMBUS_9_TX:
  2439. /*
  2440. * channel number to be between 128 and 255.
  2441. * For TX port use channel numbers
  2442. * from 128 to 137 for pre-Taiko
  2443. * from 128 to 143 for Taiko
  2444. */
  2445. if (!tx_slot) {
  2446. pr_err("%s: tx slot not found\n", __func__);
  2447. return -EINVAL;
  2448. }
  2449. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2450. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  2451. return -EINVAL;
  2452. }
  2453. for (i = 0; i < tx_num; i++) {
  2454. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2455. tx_slot[i];
  2456. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2457. __func__, i, tx_slot[i]);
  2458. }
  2459. dai_data->port_config.slim_sch.num_channels = tx_num;
  2460. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2461. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2462. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2463. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2464. break;
  2465. default:
  2466. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2467. rc = -EINVAL;
  2468. break;
  2469. }
  2470. return rc;
  2471. }
  2472. /* all ports with excursion logging requirement can use this digital_mute api */
  2473. static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai,
  2474. int mute)
  2475. {
  2476. int port_id = dai->id;
  2477. if (mute)
  2478. afe_get_sp_xt_logging_data(port_id);
  2479. return 0;
  2480. }
  2481. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2482. .prepare = msm_dai_q6_prepare,
  2483. .hw_params = msm_dai_q6_hw_params,
  2484. .shutdown = msm_dai_q6_shutdown,
  2485. .set_fmt = msm_dai_q6_set_fmt,
  2486. .set_channel_map = msm_dai_q6_set_channel_map,
  2487. };
  2488. static struct snd_soc_dai_ops msm_dai_slimbus_0_rx_ops = {
  2489. .prepare = msm_dai_q6_prepare,
  2490. .hw_params = msm_dai_q6_hw_params,
  2491. .shutdown = msm_dai_q6_shutdown,
  2492. .set_fmt = msm_dai_q6_set_fmt,
  2493. .set_channel_map = msm_dai_q6_set_channel_map,
  2494. .digital_mute = msm_dai_q6_spk_digital_mute,
  2495. };
  2496. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2497. struct snd_ctl_elem_value *ucontrol)
  2498. {
  2499. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2500. u16 port_id = ((struct soc_enum *)
  2501. kcontrol->private_value)->reg;
  2502. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2503. pr_debug("%s: setting cal_mode to %d\n",
  2504. __func__, dai_data->cal_mode);
  2505. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2506. return 0;
  2507. }
  2508. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2509. struct snd_ctl_elem_value *ucontrol)
  2510. {
  2511. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2512. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2513. return 0;
  2514. }
  2515. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2516. struct snd_ctl_elem_value *ucontrol)
  2517. {
  2518. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2519. int value = ucontrol->value.integer.value[0];
  2520. if (dai_data) {
  2521. dai_data->port_config.slim_sch.data_format = value;
  2522. pr_debug("%s: format = %d\n", __func__, value);
  2523. }
  2524. return 0;
  2525. }
  2526. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2527. struct snd_ctl_elem_value *ucontrol)
  2528. {
  2529. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2530. if (dai_data)
  2531. ucontrol->value.integer.value[0] =
  2532. dai_data->port_config.slim_sch.data_format;
  2533. return 0;
  2534. }
  2535. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2536. struct snd_ctl_elem_value *ucontrol)
  2537. {
  2538. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2539. u32 val = ucontrol->value.integer.value[0];
  2540. if (dai_data) {
  2541. dai_data->port_config.usb_audio.dev_token = val;
  2542. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2543. dai_data->port_config.usb_audio.dev_token);
  2544. } else {
  2545. pr_err("%s: dai_data is NULL\n", __func__);
  2546. }
  2547. return 0;
  2548. }
  2549. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2550. struct snd_ctl_elem_value *ucontrol)
  2551. {
  2552. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2553. if (dai_data) {
  2554. ucontrol->value.integer.value[0] =
  2555. dai_data->port_config.usb_audio.dev_token;
  2556. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2557. dai_data->port_config.usb_audio.dev_token);
  2558. } else {
  2559. pr_err("%s: dai_data is NULL\n", __func__);
  2560. }
  2561. return 0;
  2562. }
  2563. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2564. struct snd_ctl_elem_value *ucontrol)
  2565. {
  2566. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2567. u32 val = ucontrol->value.integer.value[0];
  2568. if (dai_data) {
  2569. dai_data->port_config.usb_audio.endian = val;
  2570. pr_debug("%s: endian = 0x%x\n", __func__,
  2571. dai_data->port_config.usb_audio.endian);
  2572. } else {
  2573. pr_err("%s: dai_data is NULL\n", __func__);
  2574. return -EINVAL;
  2575. }
  2576. return 0;
  2577. }
  2578. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2579. struct snd_ctl_elem_value *ucontrol)
  2580. {
  2581. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2582. if (dai_data) {
  2583. ucontrol->value.integer.value[0] =
  2584. dai_data->port_config.usb_audio.endian;
  2585. pr_debug("%s: endian = 0x%x\n", __func__,
  2586. dai_data->port_config.usb_audio.endian);
  2587. } else {
  2588. pr_err("%s: dai_data is NULL\n", __func__);
  2589. return -EINVAL;
  2590. }
  2591. return 0;
  2592. }
  2593. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2594. struct snd_ctl_elem_value *ucontrol)
  2595. {
  2596. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2597. u32 val = ucontrol->value.integer.value[0];
  2598. if (!dai_data) {
  2599. pr_err("%s: dai_data is NULL\n", __func__);
  2600. return -EINVAL;
  2601. }
  2602. dai_data->port_config.usb_audio.service_interval = val;
  2603. pr_debug("%s: new service interval = %u\n", __func__,
  2604. dai_data->port_config.usb_audio.service_interval);
  2605. return 0;
  2606. }
  2607. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2608. struct snd_ctl_elem_value *ucontrol)
  2609. {
  2610. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2611. if (!dai_data) {
  2612. pr_err("%s: dai_data is NULL\n", __func__);
  2613. return -EINVAL;
  2614. }
  2615. ucontrol->value.integer.value[0] =
  2616. dai_data->port_config.usb_audio.service_interval;
  2617. pr_debug("%s: service interval = %d\n", __func__,
  2618. dai_data->port_config.usb_audio.service_interval);
  2619. return 0;
  2620. }
  2621. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2622. struct snd_ctl_elem_info *uinfo)
  2623. {
  2624. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2625. uinfo->count = sizeof(struct afe_enc_config);
  2626. return 0;
  2627. }
  2628. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2629. struct snd_ctl_elem_value *ucontrol)
  2630. {
  2631. int ret = 0;
  2632. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2633. if (dai_data) {
  2634. int format_size = sizeof(dai_data->enc_config.format);
  2635. pr_debug("%s: encoder config for %d format\n",
  2636. __func__, dai_data->enc_config.format);
  2637. memcpy(ucontrol->value.bytes.data,
  2638. &dai_data->enc_config.format,
  2639. format_size);
  2640. switch (dai_data->enc_config.format) {
  2641. case ENC_FMT_SBC:
  2642. memcpy(ucontrol->value.bytes.data + format_size,
  2643. &dai_data->enc_config.data,
  2644. sizeof(struct asm_sbc_enc_cfg_t));
  2645. break;
  2646. case ENC_FMT_AAC_V2:
  2647. memcpy(ucontrol->value.bytes.data + format_size,
  2648. &dai_data->enc_config.data,
  2649. sizeof(struct asm_aac_enc_cfg_t));
  2650. break;
  2651. case ENC_FMT_APTX:
  2652. memcpy(ucontrol->value.bytes.data + format_size,
  2653. &dai_data->enc_config.data,
  2654. sizeof(struct asm_aptx_enc_cfg_t));
  2655. break;
  2656. case ENC_FMT_APTX_HD:
  2657. memcpy(ucontrol->value.bytes.data + format_size,
  2658. &dai_data->enc_config.data,
  2659. sizeof(struct asm_custom_enc_cfg_t));
  2660. break;
  2661. case ENC_FMT_CELT:
  2662. memcpy(ucontrol->value.bytes.data + format_size,
  2663. &dai_data->enc_config.data,
  2664. sizeof(struct asm_celt_enc_cfg_t));
  2665. break;
  2666. case ENC_FMT_LDAC:
  2667. memcpy(ucontrol->value.bytes.data + format_size,
  2668. &dai_data->enc_config.data,
  2669. sizeof(struct asm_ldac_enc_cfg_t));
  2670. break;
  2671. case ENC_FMT_APTX_ADAPTIVE:
  2672. memcpy(ucontrol->value.bytes.data + format_size,
  2673. &dai_data->enc_config.data,
  2674. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2675. break;
  2676. case ENC_FMT_APTX_AD_SPEECH:
  2677. memcpy(ucontrol->value.bytes.data + format_size,
  2678. &dai_data->enc_config.data,
  2679. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2680. break;
  2681. default:
  2682. pr_debug("%s: unknown format = %d\n",
  2683. __func__, dai_data->enc_config.format);
  2684. ret = -EINVAL;
  2685. break;
  2686. }
  2687. }
  2688. return ret;
  2689. }
  2690. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2691. struct snd_ctl_elem_value *ucontrol)
  2692. {
  2693. int ret = 0;
  2694. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2695. if (dai_data) {
  2696. int format_size = sizeof(dai_data->enc_config.format);
  2697. memset(&dai_data->enc_config, 0x0,
  2698. sizeof(struct afe_enc_config));
  2699. memcpy(&dai_data->enc_config.format,
  2700. ucontrol->value.bytes.data,
  2701. format_size);
  2702. pr_debug("%s: Received encoder config for %d format\n",
  2703. __func__, dai_data->enc_config.format);
  2704. switch (dai_data->enc_config.format) {
  2705. case ENC_FMT_SBC:
  2706. memcpy(&dai_data->enc_config.data,
  2707. ucontrol->value.bytes.data + format_size,
  2708. sizeof(struct asm_sbc_enc_cfg_t));
  2709. break;
  2710. case ENC_FMT_AAC_V2:
  2711. memcpy(&dai_data->enc_config.data,
  2712. ucontrol->value.bytes.data + format_size,
  2713. sizeof(struct asm_aac_enc_cfg_t));
  2714. break;
  2715. case ENC_FMT_APTX:
  2716. memcpy(&dai_data->enc_config.data,
  2717. ucontrol->value.bytes.data + format_size,
  2718. sizeof(struct asm_aptx_enc_cfg_t));
  2719. break;
  2720. case ENC_FMT_APTX_HD:
  2721. memcpy(&dai_data->enc_config.data,
  2722. ucontrol->value.bytes.data + format_size,
  2723. sizeof(struct asm_custom_enc_cfg_t));
  2724. break;
  2725. case ENC_FMT_CELT:
  2726. memcpy(&dai_data->enc_config.data,
  2727. ucontrol->value.bytes.data + format_size,
  2728. sizeof(struct asm_celt_enc_cfg_t));
  2729. break;
  2730. case ENC_FMT_LDAC:
  2731. memcpy(&dai_data->enc_config.data,
  2732. ucontrol->value.bytes.data + format_size,
  2733. sizeof(struct asm_ldac_enc_cfg_t));
  2734. break;
  2735. case ENC_FMT_APTX_ADAPTIVE:
  2736. memcpy(&dai_data->enc_config.data,
  2737. ucontrol->value.bytes.data + format_size,
  2738. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2739. break;
  2740. case ENC_FMT_APTX_AD_SPEECH:
  2741. memcpy(&dai_data->enc_config.data,
  2742. ucontrol->value.bytes.data + format_size,
  2743. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2744. break;
  2745. default:
  2746. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2747. __func__, dai_data->enc_config.format);
  2748. ret = -EINVAL;
  2749. break;
  2750. }
  2751. } else
  2752. ret = -EINVAL;
  2753. return ret;
  2754. }
  2755. static const char *const afe_chs_text[] = {"Zero", "One", "Two"};
  2756. static const struct soc_enum afe_chs_enum[] = {
  2757. SOC_ENUM_SINGLE_EXT(3, afe_chs_text),
  2758. };
  2759. static const char *const afe_bit_format_text[] = {"S16_LE", "S24_LE",
  2760. "S32_LE"};
  2761. static const struct soc_enum afe_bit_format_enum[] = {
  2762. SOC_ENUM_SINGLE_EXT(3, afe_bit_format_text),
  2763. };
  2764. static const char *const tws_chs_mode_text[] = {"Zero", "One", "Two"};
  2765. static const struct soc_enum tws_chs_mode_enum[] = {
  2766. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tws_chs_mode_text), tws_chs_mode_text),
  2767. };
  2768. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2769. struct snd_ctl_elem_value *ucontrol)
  2770. {
  2771. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2772. if (dai_data) {
  2773. ucontrol->value.integer.value[0] = dai_data->afe_rx_in_channels;
  2774. pr_debug("%s:afe input channel = %d\n",
  2775. __func__, dai_data->afe_rx_in_channels);
  2776. }
  2777. return 0;
  2778. }
  2779. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2780. struct snd_ctl_elem_value *ucontrol)
  2781. {
  2782. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2783. if (dai_data) {
  2784. dai_data->afe_rx_in_channels = ucontrol->value.integer.value[0];
  2785. pr_debug("%s: updating afe input channel : %d\n",
  2786. __func__, dai_data->afe_rx_in_channels);
  2787. }
  2788. return 0;
  2789. }
  2790. static int msm_dai_q6_tws_channel_mode_get(struct snd_kcontrol *kcontrol,
  2791. struct snd_ctl_elem_value *ucontrol)
  2792. {
  2793. struct snd_soc_dai *dai = kcontrol->private_data;
  2794. struct msm_dai_q6_dai_data *dai_data = NULL;
  2795. if (dai)
  2796. dai_data = dev_get_drvdata(dai->dev);
  2797. if (dai_data) {
  2798. ucontrol->value.integer.value[0] =
  2799. dai_data->enc_config.mono_mode;
  2800. pr_debug("%s:tws channel mode = %d\n",
  2801. __func__, dai_data->enc_config.mono_mode);
  2802. }
  2803. return 0;
  2804. }
  2805. static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol,
  2806. struct snd_ctl_elem_value *ucontrol)
  2807. {
  2808. struct snd_soc_dai *dai = kcontrol->private_data;
  2809. struct msm_dai_q6_dai_data *dai_data = NULL;
  2810. int ret = 0;
  2811. if (dai)
  2812. dai_data = dev_get_drvdata(dai->dev);
  2813. if (dai_data && (dai_data->enc_config.format == ENC_FMT_APTX)) {
  2814. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2815. ret = afe_set_tws_channel_mode(dai->id,
  2816. ucontrol->value.integer.value[0]);
  2817. if (ret < 0) {
  2818. pr_err("%s: channel mode setting failed for TWS\n",
  2819. __func__);
  2820. goto exit;
  2821. } else {
  2822. pr_debug("%s: updating tws channel mode : %d\n",
  2823. __func__, dai_data->enc_config.mono_mode);
  2824. }
  2825. }
  2826. if (ucontrol->value.integer.value[0] ==
  2827. MSM_DAI_TWS_CHANNEL_MODE_ONE ||
  2828. ucontrol->value.integer.value[0] ==
  2829. MSM_DAI_TWS_CHANNEL_MODE_TWO)
  2830. dai_data->enc_config.mono_mode =
  2831. ucontrol->value.integer.value[0];
  2832. else
  2833. return -EINVAL;
  2834. }
  2835. exit:
  2836. return ret;
  2837. }
  2838. static int msm_dai_q6_afe_input_bit_format_get(
  2839. struct snd_kcontrol *kcontrol,
  2840. struct snd_ctl_elem_value *ucontrol)
  2841. {
  2842. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2843. if (!dai_data) {
  2844. pr_err("%s: Invalid dai data\n", __func__);
  2845. return -EINVAL;
  2846. }
  2847. switch (dai_data->afe_rx_in_bitformat) {
  2848. case SNDRV_PCM_FORMAT_S32_LE:
  2849. ucontrol->value.integer.value[0] = 2;
  2850. break;
  2851. case SNDRV_PCM_FORMAT_S24_LE:
  2852. ucontrol->value.integer.value[0] = 1;
  2853. break;
  2854. case SNDRV_PCM_FORMAT_S16_LE:
  2855. default:
  2856. ucontrol->value.integer.value[0] = 0;
  2857. break;
  2858. }
  2859. pr_debug("%s: afe input bit format : %ld\n",
  2860. __func__, ucontrol->value.integer.value[0]);
  2861. return 0;
  2862. }
  2863. static int msm_dai_q6_afe_input_bit_format_put(
  2864. struct snd_kcontrol *kcontrol,
  2865. struct snd_ctl_elem_value *ucontrol)
  2866. {
  2867. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2868. if (!dai_data) {
  2869. pr_err("%s: Invalid dai data\n", __func__);
  2870. return -EINVAL;
  2871. }
  2872. switch (ucontrol->value.integer.value[0]) {
  2873. case 2:
  2874. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2875. break;
  2876. case 1:
  2877. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2878. break;
  2879. case 0:
  2880. default:
  2881. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2882. break;
  2883. }
  2884. pr_debug("%s: updating afe input bit format : %d\n",
  2885. __func__, dai_data->afe_rx_in_bitformat);
  2886. return 0;
  2887. }
  2888. static int msm_dai_q6_afe_output_bit_format_get(
  2889. struct snd_kcontrol *kcontrol,
  2890. struct snd_ctl_elem_value *ucontrol)
  2891. {
  2892. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2893. if (!dai_data) {
  2894. pr_err("%s: Invalid dai data\n", __func__);
  2895. return -EINVAL;
  2896. }
  2897. switch (dai_data->afe_tx_out_bitformat) {
  2898. case SNDRV_PCM_FORMAT_S32_LE:
  2899. ucontrol->value.integer.value[0] = 2;
  2900. break;
  2901. case SNDRV_PCM_FORMAT_S24_LE:
  2902. ucontrol->value.integer.value[0] = 1;
  2903. break;
  2904. case SNDRV_PCM_FORMAT_S16_LE:
  2905. default:
  2906. ucontrol->value.integer.value[0] = 0;
  2907. break;
  2908. }
  2909. pr_debug("%s: afe output bit format : %ld\n",
  2910. __func__, ucontrol->value.integer.value[0]);
  2911. return 0;
  2912. }
  2913. static int msm_dai_q6_afe_output_bit_format_put(
  2914. struct snd_kcontrol *kcontrol,
  2915. struct snd_ctl_elem_value *ucontrol)
  2916. {
  2917. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2918. if (!dai_data) {
  2919. pr_err("%s: Invalid dai data\n", __func__);
  2920. return -EINVAL;
  2921. }
  2922. switch (ucontrol->value.integer.value[0]) {
  2923. case 2:
  2924. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2925. break;
  2926. case 1:
  2927. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2928. break;
  2929. case 0:
  2930. default:
  2931. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2932. break;
  2933. }
  2934. pr_debug("%s: updating afe output bit format : %d\n",
  2935. __func__, dai_data->afe_tx_out_bitformat);
  2936. return 0;
  2937. }
  2938. static int msm_dai_q6_afe_output_channel_get(struct snd_kcontrol *kcontrol,
  2939. struct snd_ctl_elem_value *ucontrol)
  2940. {
  2941. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2942. if (dai_data) {
  2943. ucontrol->value.integer.value[0] =
  2944. dai_data->afe_tx_out_channels;
  2945. pr_debug("%s:afe output channel = %d\n",
  2946. __func__, dai_data->afe_tx_out_channels);
  2947. }
  2948. return 0;
  2949. }
  2950. static int msm_dai_q6_afe_output_channel_put(struct snd_kcontrol *kcontrol,
  2951. struct snd_ctl_elem_value *ucontrol)
  2952. {
  2953. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2954. if (dai_data) {
  2955. dai_data->afe_tx_out_channels =
  2956. ucontrol->value.integer.value[0];
  2957. pr_debug("%s: updating afe output channel : %d\n",
  2958. __func__, dai_data->afe_tx_out_channels);
  2959. }
  2960. return 0;
  2961. }
  2962. static int msm_dai_q6_afe_scrambler_mode_get(
  2963. struct snd_kcontrol *kcontrol,
  2964. struct snd_ctl_elem_value *ucontrol)
  2965. {
  2966. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2967. if (!dai_data) {
  2968. pr_err("%s: Invalid dai data\n", __func__);
  2969. return -EINVAL;
  2970. }
  2971. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  2972. return 0;
  2973. }
  2974. static int msm_dai_q6_afe_scrambler_mode_put(
  2975. struct snd_kcontrol *kcontrol,
  2976. struct snd_ctl_elem_value *ucontrol)
  2977. {
  2978. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2979. if (!dai_data) {
  2980. pr_err("%s: Invalid dai data\n", __func__);
  2981. return -EINVAL;
  2982. }
  2983. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  2984. pr_debug("%s: afe scrambler mode : %d\n",
  2985. __func__, dai_data->enc_config.scrambler_mode);
  2986. return 0;
  2987. }
  2988. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2989. {
  2990. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2991. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2992. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2993. .name = "SLIM_7_RX Encoder Config",
  2994. .info = msm_dai_q6_afe_enc_cfg_info,
  2995. .get = msm_dai_q6_afe_enc_cfg_get,
  2996. .put = msm_dai_q6_afe_enc_cfg_put,
  2997. },
  2998. {
  2999. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3000. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3001. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3002. .name = "SLIM_7_RX APTX_AD Enc Cfg",
  3003. .info = msm_dai_q6_afe_enc_cfg_info,
  3004. .get = msm_dai_q6_afe_enc_cfg_get,
  3005. .put = msm_dai_q6_afe_enc_cfg_put,
  3006. },
  3007. SOC_ENUM_EXT("AFE Input Channels", afe_chs_enum[0],
  3008. msm_dai_q6_afe_input_channel_get,
  3009. msm_dai_q6_afe_input_channel_put),
  3010. SOC_ENUM_EXT("AFE Input Bit Format", afe_bit_format_enum[0],
  3011. msm_dai_q6_afe_input_bit_format_get,
  3012. msm_dai_q6_afe_input_bit_format_put),
  3013. SOC_SINGLE_EXT("AFE Scrambler Mode",
  3014. 0, 0, 1, 0,
  3015. msm_dai_q6_afe_scrambler_mode_get,
  3016. msm_dai_q6_afe_scrambler_mode_put),
  3017. SOC_ENUM_EXT("TWS Channel Mode", tws_chs_mode_enum[0],
  3018. msm_dai_q6_tws_channel_mode_get,
  3019. msm_dai_q6_tws_channel_mode_put)
  3020. };
  3021. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  3022. struct snd_ctl_elem_info *uinfo)
  3023. {
  3024. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3025. uinfo->count = sizeof(struct afe_dec_config);
  3026. return 0;
  3027. }
  3028. static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3029. struct snd_ctl_elem_value *ucontrol)
  3030. {
  3031. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3032. u32 format_size = 0;
  3033. u32 abr_size = 0;
  3034. if (!dai_data) {
  3035. pr_err("%s: Invalid dai data\n", __func__);
  3036. return -EINVAL;
  3037. }
  3038. format_size = sizeof(dai_data->dec_config.format);
  3039. memcpy(ucontrol->value.bytes.data,
  3040. &dai_data->dec_config.format,
  3041. format_size);
  3042. pr_debug("%s: abr_dec_cfg for %d format\n",
  3043. __func__, dai_data->dec_config.format);
  3044. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3045. memcpy(ucontrol->value.bytes.data + format_size,
  3046. &dai_data->dec_config.abr_dec_cfg,
  3047. sizeof(struct afe_imc_dec_enc_info));
  3048. switch (dai_data->dec_config.format) {
  3049. case DEC_FMT_APTX_AD_SPEECH:
  3050. pr_debug("%s: afe_dec_cfg for %d format\n",
  3051. __func__, dai_data->dec_config.format);
  3052. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3053. &dai_data->dec_config.data,
  3054. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3055. break;
  3056. default:
  3057. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3058. __func__, dai_data->dec_config.format);
  3059. break;
  3060. }
  3061. return 0;
  3062. }
  3063. static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3064. struct snd_ctl_elem_value *ucontrol)
  3065. {
  3066. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3067. u32 format_size = 0;
  3068. u32 abr_size = 0;
  3069. if (!dai_data) {
  3070. pr_err("%s: Invalid dai data\n", __func__);
  3071. return -EINVAL;
  3072. }
  3073. memset(&dai_data->dec_config, 0x0,
  3074. sizeof(struct afe_dec_config));
  3075. format_size = sizeof(dai_data->dec_config.format);
  3076. memcpy(&dai_data->dec_config.format,
  3077. ucontrol->value.bytes.data,
  3078. format_size);
  3079. pr_debug("%s: abr_dec_cfg for %d format\n",
  3080. __func__, dai_data->dec_config.format);
  3081. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3082. memcpy(&dai_data->dec_config.abr_dec_cfg,
  3083. ucontrol->value.bytes.data + format_size,
  3084. sizeof(struct afe_imc_dec_enc_info));
  3085. dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
  3086. switch (dai_data->dec_config.format) {
  3087. case DEC_FMT_APTX_AD_SPEECH:
  3088. pr_debug("%s: afe_dec_cfg for %d format\n",
  3089. __func__, dai_data->dec_config.format);
  3090. memcpy(&dai_data->dec_config.data,
  3091. ucontrol->value.bytes.data + format_size + abr_size,
  3092. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3093. break;
  3094. default:
  3095. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3096. __func__, dai_data->dec_config.format);
  3097. break;
  3098. }
  3099. return 0;
  3100. }
  3101. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3102. struct snd_ctl_elem_value *ucontrol)
  3103. {
  3104. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3105. u32 format_size = 0;
  3106. int ret = 0;
  3107. if (!dai_data) {
  3108. pr_err("%s: Invalid dai data\n", __func__);
  3109. return -EINVAL;
  3110. }
  3111. format_size = sizeof(dai_data->dec_config.format);
  3112. memcpy(ucontrol->value.bytes.data,
  3113. &dai_data->dec_config.format,
  3114. format_size);
  3115. switch (dai_data->dec_config.format) {
  3116. case DEC_FMT_AAC_V2:
  3117. memcpy(ucontrol->value.bytes.data + format_size,
  3118. &dai_data->dec_config.data,
  3119. sizeof(struct asm_aac_dec_cfg_v2_t));
  3120. break;
  3121. case DEC_FMT_APTX_ADAPTIVE:
  3122. memcpy(ucontrol->value.bytes.data + format_size,
  3123. &dai_data->dec_config.data,
  3124. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3125. break;
  3126. case DEC_FMT_SBC:
  3127. case DEC_FMT_MP3:
  3128. /* No decoder specific data available */
  3129. break;
  3130. default:
  3131. pr_err("%s: Invalid format %d\n",
  3132. __func__, dai_data->dec_config.format);
  3133. ret = -EINVAL;
  3134. break;
  3135. }
  3136. return ret;
  3137. }
  3138. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3139. struct snd_ctl_elem_value *ucontrol)
  3140. {
  3141. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3142. u32 format_size = 0;
  3143. int ret = 0;
  3144. if (!dai_data) {
  3145. pr_err("%s: Invalid dai data\n", __func__);
  3146. return -EINVAL;
  3147. }
  3148. memset(&dai_data->dec_config, 0x0,
  3149. sizeof(struct afe_dec_config));
  3150. format_size = sizeof(dai_data->dec_config.format);
  3151. memcpy(&dai_data->dec_config.format,
  3152. ucontrol->value.bytes.data,
  3153. format_size);
  3154. pr_debug("%s: Received decoder config for %d format\n",
  3155. __func__, dai_data->dec_config.format);
  3156. switch (dai_data->dec_config.format) {
  3157. case DEC_FMT_AAC_V2:
  3158. memcpy(&dai_data->dec_config.data,
  3159. ucontrol->value.bytes.data + format_size,
  3160. sizeof(struct asm_aac_dec_cfg_v2_t));
  3161. break;
  3162. case DEC_FMT_SBC:
  3163. memcpy(&dai_data->dec_config.data,
  3164. ucontrol->value.bytes.data + format_size,
  3165. sizeof(struct asm_sbc_dec_cfg_t));
  3166. break;
  3167. case DEC_FMT_APTX_ADAPTIVE:
  3168. memcpy(&dai_data->dec_config.data,
  3169. ucontrol->value.bytes.data + format_size,
  3170. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3171. break;
  3172. default:
  3173. pr_err("%s: Invalid format %d\n",
  3174. __func__, dai_data->dec_config.format);
  3175. ret = -EINVAL;
  3176. break;
  3177. }
  3178. return ret;
  3179. }
  3180. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  3181. {
  3182. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3183. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3184. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3185. .name = "SLIM_7_TX Decoder Config",
  3186. .info = msm_dai_q6_afe_dec_cfg_info,
  3187. .get = msm_dai_q6_afe_feedback_dec_cfg_get,
  3188. .put = msm_dai_q6_afe_feedback_dec_cfg_put,
  3189. },
  3190. {
  3191. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3192. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3193. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3194. .name = "SLIM_9_TX Decoder Config",
  3195. .info = msm_dai_q6_afe_dec_cfg_info,
  3196. .get = msm_dai_q6_afe_dec_cfg_get,
  3197. .put = msm_dai_q6_afe_dec_cfg_put,
  3198. },
  3199. SOC_ENUM_EXT("AFE Output Channels", afe_chs_enum[0],
  3200. msm_dai_q6_afe_output_channel_get,
  3201. msm_dai_q6_afe_output_channel_put),
  3202. SOC_ENUM_EXT("AFE Output Bit Format", afe_bit_format_enum[0],
  3203. msm_dai_q6_afe_output_bit_format_get,
  3204. msm_dai_q6_afe_output_bit_format_put),
  3205. };
  3206. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  3207. struct snd_ctl_elem_info *uinfo)
  3208. {
  3209. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3210. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  3211. return 0;
  3212. }
  3213. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  3214. struct snd_ctl_elem_value *ucontrol)
  3215. {
  3216. int ret = -EINVAL;
  3217. struct afe_param_id_dev_timing_stats timing_stats;
  3218. struct snd_soc_dai *dai = kcontrol->private_data;
  3219. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3220. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3221. pr_debug("%s: afe port not started. dai_data->status_mask = %ld\n",
  3222. __func__, *dai_data->status_mask);
  3223. goto done;
  3224. }
  3225. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  3226. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  3227. if (ret) {
  3228. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  3229. __func__, dai->id, ret);
  3230. goto done;
  3231. }
  3232. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  3233. sizeof(struct afe_param_id_dev_timing_stats));
  3234. done:
  3235. return ret;
  3236. }
  3237. static const char * const afe_cal_mode_text[] = {
  3238. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  3239. };
  3240. static const struct soc_enum slim_2_rx_enum =
  3241. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3242. afe_cal_mode_text);
  3243. static const struct soc_enum rt_proxy_1_rx_enum =
  3244. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3245. afe_cal_mode_text);
  3246. static const struct soc_enum rt_proxy_1_tx_enum =
  3247. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3248. afe_cal_mode_text);
  3249. static const struct snd_kcontrol_new sb_config_controls[] = {
  3250. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  3251. msm_dai_q6_sb_format_get,
  3252. msm_dai_q6_sb_format_put),
  3253. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  3254. msm_dai_q6_cal_info_get,
  3255. msm_dai_q6_cal_info_put),
  3256. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  3257. msm_dai_q6_sb_format_get,
  3258. msm_dai_q6_sb_format_put)
  3259. };
  3260. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  3261. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  3262. msm_dai_q6_cal_info_get,
  3263. msm_dai_q6_cal_info_put),
  3264. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  3265. msm_dai_q6_cal_info_get,
  3266. msm_dai_q6_cal_info_put),
  3267. };
  3268. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  3269. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  3270. msm_dai_q6_usb_audio_cfg_get,
  3271. msm_dai_q6_usb_audio_cfg_put),
  3272. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  3273. msm_dai_q6_usb_audio_endian_cfg_get,
  3274. msm_dai_q6_usb_audio_endian_cfg_put),
  3275. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  3276. msm_dai_q6_usb_audio_cfg_get,
  3277. msm_dai_q6_usb_audio_cfg_put),
  3278. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  3279. msm_dai_q6_usb_audio_endian_cfg_get,
  3280. msm_dai_q6_usb_audio_endian_cfg_put),
  3281. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  3282. UINT_MAX, 0,
  3283. msm_dai_q6_usb_audio_svc_interval_get,
  3284. msm_dai_q6_usb_audio_svc_interval_put),
  3285. };
  3286. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  3287. {
  3288. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3289. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3290. .name = "SLIMBUS_0_RX DRIFT",
  3291. .info = msm_dai_q6_slim_rx_drift_info,
  3292. .get = msm_dai_q6_slim_rx_drift_get,
  3293. },
  3294. {
  3295. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3296. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3297. .name = "SLIMBUS_6_RX DRIFT",
  3298. .info = msm_dai_q6_slim_rx_drift_info,
  3299. .get = msm_dai_q6_slim_rx_drift_get,
  3300. },
  3301. {
  3302. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3303. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3304. .name = "SLIMBUS_7_RX DRIFT",
  3305. .info = msm_dai_q6_slim_rx_drift_info,
  3306. .get = msm_dai_q6_slim_rx_drift_get,
  3307. },
  3308. };
  3309. static inline void msm_dai_q6_set_slim_dev_id(struct snd_soc_dai *dai)
  3310. {
  3311. int rc = 0;
  3312. int slim_dev_id = 0;
  3313. const char *q6_slim_dev_id = "qcom,msm-dai-q6-slim-dev-id";
  3314. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3315. dai_data->port_config.slim_sch.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1;
  3316. rc = of_property_read_u32(dai->dev->of_node, q6_slim_dev_id,
  3317. &slim_dev_id);
  3318. if (rc) {
  3319. dev_dbg(dai->dev,
  3320. "%s: missing %s in dt node\n", __func__, q6_slim_dev_id);
  3321. return;
  3322. }
  3323. dev_dbg(dai->dev, "%s: slim_dev_id = %d\n", __func__, slim_dev_id);
  3324. if (slim_dev_id >= AFE_SLIMBUS_DEVICE_1 &&
  3325. slim_dev_id <= AFE_SLIMBUS_DEVICE_2)
  3326. dai_data->port_config.slim_sch.slimbus_dev_id = slim_dev_id;
  3327. }
  3328. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  3329. {
  3330. struct msm_dai_q6_dai_data *dai_data;
  3331. int rc = 0;
  3332. if (!dai) {
  3333. pr_err("%s: Invalid params dai\n", __func__);
  3334. return -EINVAL;
  3335. }
  3336. if (!dai->dev) {
  3337. pr_err("%s: Invalid params dai dev\n", __func__);
  3338. return -EINVAL;
  3339. }
  3340. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  3341. if (!dai_data)
  3342. return -ENOMEM;
  3343. else
  3344. dev_set_drvdata(dai->dev, dai_data);
  3345. msm_dai_q6_set_dai_id(dai);
  3346. if ((dai->id >= SLIMBUS_0_RX) && (dai->id <= SLIMBUS_9_TX))
  3347. msm_dai_q6_set_slim_dev_id(dai);
  3348. switch (dai->id) {
  3349. case SLIMBUS_4_TX:
  3350. rc = snd_ctl_add(dai->component->card->snd_card,
  3351. snd_ctl_new1(&sb_config_controls[0],
  3352. dai_data));
  3353. break;
  3354. case SLIMBUS_2_RX:
  3355. rc = snd_ctl_add(dai->component->card->snd_card,
  3356. snd_ctl_new1(&sb_config_controls[1],
  3357. dai_data));
  3358. rc = snd_ctl_add(dai->component->card->snd_card,
  3359. snd_ctl_new1(&sb_config_controls[2],
  3360. dai_data));
  3361. break;
  3362. case SLIMBUS_7_RX:
  3363. rc = snd_ctl_add(dai->component->card->snd_card,
  3364. snd_ctl_new1(&afe_enc_config_controls[0],
  3365. dai_data));
  3366. rc = snd_ctl_add(dai->component->card->snd_card,
  3367. snd_ctl_new1(&afe_enc_config_controls[1],
  3368. dai_data));
  3369. rc = snd_ctl_add(dai->component->card->snd_card,
  3370. snd_ctl_new1(&afe_enc_config_controls[2],
  3371. dai_data));
  3372. rc = snd_ctl_add(dai->component->card->snd_card,
  3373. snd_ctl_new1(&afe_enc_config_controls[3],
  3374. dai_data));
  3375. rc = snd_ctl_add(dai->component->card->snd_card,
  3376. snd_ctl_new1(&afe_enc_config_controls[4],
  3377. dai));
  3378. rc = snd_ctl_add(dai->component->card->snd_card,
  3379. snd_ctl_new1(&afe_enc_config_controls[5],
  3380. dai));
  3381. rc = snd_ctl_add(dai->component->card->snd_card,
  3382. snd_ctl_new1(&avd_drift_config_controls[2],
  3383. dai));
  3384. break;
  3385. case SLIMBUS_7_TX:
  3386. rc = snd_ctl_add(dai->component->card->snd_card,
  3387. snd_ctl_new1(&afe_dec_config_controls[0],
  3388. dai_data));
  3389. break;
  3390. case SLIMBUS_9_TX:
  3391. rc = snd_ctl_add(dai->component->card->snd_card,
  3392. snd_ctl_new1(&afe_dec_config_controls[1],
  3393. dai_data));
  3394. rc = snd_ctl_add(dai->component->card->snd_card,
  3395. snd_ctl_new1(&afe_dec_config_controls[2],
  3396. dai_data));
  3397. rc = snd_ctl_add(dai->component->card->snd_card,
  3398. snd_ctl_new1(&afe_dec_config_controls[3],
  3399. dai_data));
  3400. break;
  3401. case RT_PROXY_DAI_001_RX:
  3402. rc = snd_ctl_add(dai->component->card->snd_card,
  3403. snd_ctl_new1(&rt_proxy_config_controls[0],
  3404. dai_data));
  3405. break;
  3406. case RT_PROXY_DAI_001_TX:
  3407. rc = snd_ctl_add(dai->component->card->snd_card,
  3408. snd_ctl_new1(&rt_proxy_config_controls[1],
  3409. dai_data));
  3410. break;
  3411. case AFE_PORT_ID_USB_RX:
  3412. rc = snd_ctl_add(dai->component->card->snd_card,
  3413. snd_ctl_new1(&usb_audio_cfg_controls[0],
  3414. dai_data));
  3415. rc = snd_ctl_add(dai->component->card->snd_card,
  3416. snd_ctl_new1(&usb_audio_cfg_controls[1],
  3417. dai_data));
  3418. rc = snd_ctl_add(dai->component->card->snd_card,
  3419. snd_ctl_new1(&usb_audio_cfg_controls[4],
  3420. dai_data));
  3421. break;
  3422. case AFE_PORT_ID_USB_TX:
  3423. rc = snd_ctl_add(dai->component->card->snd_card,
  3424. snd_ctl_new1(&usb_audio_cfg_controls[2],
  3425. dai_data));
  3426. rc = snd_ctl_add(dai->component->card->snd_card,
  3427. snd_ctl_new1(&usb_audio_cfg_controls[3],
  3428. dai_data));
  3429. break;
  3430. case SLIMBUS_0_RX:
  3431. rc = snd_ctl_add(dai->component->card->snd_card,
  3432. snd_ctl_new1(&avd_drift_config_controls[0],
  3433. dai));
  3434. break;
  3435. case SLIMBUS_6_RX:
  3436. rc = snd_ctl_add(dai->component->card->snd_card,
  3437. snd_ctl_new1(&avd_drift_config_controls[1],
  3438. dai));
  3439. break;
  3440. }
  3441. if (rc < 0)
  3442. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  3443. __func__, dai->name);
  3444. rc = msm_dai_q6_dai_add_route(dai);
  3445. return rc;
  3446. }
  3447. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  3448. {
  3449. struct msm_dai_q6_dai_data *dai_data;
  3450. int rc;
  3451. dai_data = dev_get_drvdata(dai->dev);
  3452. /* If AFE port is still up, close it */
  3453. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3454. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  3455. rc = afe_close(dai->id); /* can block */
  3456. if (rc < 0)
  3457. dev_err(dai->dev, "fail to close AFE port\n");
  3458. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3459. }
  3460. kfree(dai_data);
  3461. return 0;
  3462. }
  3463. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  3464. {
  3465. .playback = {
  3466. .stream_name = "AFE Playback",
  3467. .aif_name = "PCM_RX",
  3468. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3469. SNDRV_PCM_RATE_16000,
  3470. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3471. SNDRV_PCM_FMTBIT_S24_LE,
  3472. .channels_min = 1,
  3473. .channels_max = 2,
  3474. .rate_min = 8000,
  3475. .rate_max = 48000,
  3476. },
  3477. .ops = &msm_dai_q6_ops,
  3478. .id = RT_PROXY_DAI_001_RX,
  3479. .probe = msm_dai_q6_dai_probe,
  3480. .remove = msm_dai_q6_dai_remove,
  3481. },
  3482. {
  3483. .playback = {
  3484. .stream_name = "AFE-PROXY RX",
  3485. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3486. SNDRV_PCM_RATE_16000,
  3487. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3488. SNDRV_PCM_FMTBIT_S24_LE,
  3489. .channels_min = 1,
  3490. .channels_max = 2,
  3491. .rate_min = 8000,
  3492. .rate_max = 48000,
  3493. },
  3494. .ops = &msm_dai_q6_ops,
  3495. .id = RT_PROXY_DAI_002_RX,
  3496. .probe = msm_dai_q6_dai_probe,
  3497. .remove = msm_dai_q6_dai_remove,
  3498. },
  3499. };
  3500. static struct snd_soc_dai_driver msm_dai_q6_afe_lb_tx_dai[] = {
  3501. {
  3502. .capture = {
  3503. .stream_name = "AFE Loopback Capture",
  3504. .aif_name = "AFE_LOOPBACK_TX",
  3505. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3506. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3507. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3508. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3509. SNDRV_PCM_RATE_192000,
  3510. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  3511. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE |
  3512. SNDRV_PCM_FMTBIT_S32_LE ),
  3513. .channels_min = 1,
  3514. .channels_max = 8,
  3515. .rate_min = 8000,
  3516. .rate_max = 192000,
  3517. },
  3518. .id = AFE_LOOPBACK_TX,
  3519. .probe = msm_dai_q6_dai_probe,
  3520. .remove = msm_dai_q6_dai_remove,
  3521. },
  3522. };
  3523. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  3524. {
  3525. .capture = {
  3526. .stream_name = "AFE Capture",
  3527. .aif_name = "PCM_TX",
  3528. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3529. SNDRV_PCM_RATE_16000,
  3530. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3531. .channels_min = 1,
  3532. .channels_max = 8,
  3533. .rate_min = 8000,
  3534. .rate_max = 48000,
  3535. },
  3536. .ops = &msm_dai_q6_ops,
  3537. .id = RT_PROXY_DAI_002_TX,
  3538. .probe = msm_dai_q6_dai_probe,
  3539. .remove = msm_dai_q6_dai_remove,
  3540. },
  3541. {
  3542. .capture = {
  3543. .stream_name = "AFE-PROXY TX",
  3544. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3545. SNDRV_PCM_RATE_16000,
  3546. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3547. .channels_min = 1,
  3548. .channels_max = 8,
  3549. .rate_min = 8000,
  3550. .rate_max = 48000,
  3551. },
  3552. .ops = &msm_dai_q6_ops,
  3553. .id = RT_PROXY_DAI_001_TX,
  3554. .probe = msm_dai_q6_dai_probe,
  3555. .remove = msm_dai_q6_dai_remove,
  3556. },
  3557. };
  3558. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3559. .playback = {
  3560. .stream_name = "Internal BT-SCO Playback",
  3561. .aif_name = "INT_BT_SCO_RX",
  3562. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3563. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3564. .channels_min = 1,
  3565. .channels_max = 1,
  3566. .rate_max = 16000,
  3567. .rate_min = 8000,
  3568. },
  3569. .ops = &msm_dai_q6_ops,
  3570. .id = INT_BT_SCO_RX,
  3571. .probe = msm_dai_q6_dai_probe,
  3572. .remove = msm_dai_q6_dai_remove,
  3573. };
  3574. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  3575. .playback = {
  3576. .stream_name = "Internal BT-A2DP Playback",
  3577. .aif_name = "INT_BT_A2DP_RX",
  3578. .rates = SNDRV_PCM_RATE_48000,
  3579. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3580. .channels_min = 1,
  3581. .channels_max = 2,
  3582. .rate_max = 48000,
  3583. .rate_min = 48000,
  3584. },
  3585. .ops = &msm_dai_q6_ops,
  3586. .id = INT_BT_A2DP_RX,
  3587. .probe = msm_dai_q6_dai_probe,
  3588. .remove = msm_dai_q6_dai_remove,
  3589. };
  3590. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  3591. .capture = {
  3592. .stream_name = "Internal BT-SCO Capture",
  3593. .aif_name = "INT_BT_SCO_TX",
  3594. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3595. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3596. .channels_min = 1,
  3597. .channels_max = 1,
  3598. .rate_max = 16000,
  3599. .rate_min = 8000,
  3600. },
  3601. .ops = &msm_dai_q6_ops,
  3602. .id = INT_BT_SCO_TX,
  3603. .probe = msm_dai_q6_dai_probe,
  3604. .remove = msm_dai_q6_dai_remove,
  3605. };
  3606. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  3607. .playback = {
  3608. .stream_name = "Internal FM Playback",
  3609. .aif_name = "INT_FM_RX",
  3610. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3611. SNDRV_PCM_RATE_16000,
  3612. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3613. .channels_min = 2,
  3614. .channels_max = 2,
  3615. .rate_max = 48000,
  3616. .rate_min = 8000,
  3617. },
  3618. .ops = &msm_dai_q6_ops,
  3619. .id = INT_FM_RX,
  3620. .probe = msm_dai_q6_dai_probe,
  3621. .remove = msm_dai_q6_dai_remove,
  3622. };
  3623. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  3624. .capture = {
  3625. .stream_name = "Internal FM Capture",
  3626. .aif_name = "INT_FM_TX",
  3627. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3628. SNDRV_PCM_RATE_16000,
  3629. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3630. .channels_min = 2,
  3631. .channels_max = 2,
  3632. .rate_max = 48000,
  3633. .rate_min = 8000,
  3634. },
  3635. .ops = &msm_dai_q6_ops,
  3636. .id = INT_FM_TX,
  3637. .probe = msm_dai_q6_dai_probe,
  3638. .remove = msm_dai_q6_dai_remove,
  3639. };
  3640. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  3641. {
  3642. .playback = {
  3643. .stream_name = "Voice Farend Playback",
  3644. .aif_name = "VOICE_PLAYBACK_TX",
  3645. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3646. SNDRV_PCM_RATE_16000,
  3647. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3648. .channels_min = 1,
  3649. .channels_max = 2,
  3650. .rate_min = 8000,
  3651. .rate_max = 48000,
  3652. },
  3653. .ops = &msm_dai_q6_ops,
  3654. .id = VOICE_PLAYBACK_TX,
  3655. .probe = msm_dai_q6_dai_probe,
  3656. .remove = msm_dai_q6_dai_remove,
  3657. },
  3658. {
  3659. .playback = {
  3660. .stream_name = "Voice2 Farend Playback",
  3661. .aif_name = "VOICE2_PLAYBACK_TX",
  3662. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3663. SNDRV_PCM_RATE_16000,
  3664. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3665. .channels_min = 1,
  3666. .channels_max = 2,
  3667. .rate_min = 8000,
  3668. .rate_max = 48000,
  3669. },
  3670. .ops = &msm_dai_q6_ops,
  3671. .id = VOICE2_PLAYBACK_TX,
  3672. .probe = msm_dai_q6_dai_probe,
  3673. .remove = msm_dai_q6_dai_remove,
  3674. },
  3675. };
  3676. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  3677. {
  3678. .capture = {
  3679. .stream_name = "Voice Uplink Capture",
  3680. .aif_name = "INCALL_RECORD_TX",
  3681. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3682. SNDRV_PCM_RATE_16000,
  3683. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3684. .channels_min = 1,
  3685. .channels_max = 2,
  3686. .rate_min = 8000,
  3687. .rate_max = 48000,
  3688. },
  3689. .ops = &msm_dai_q6_ops,
  3690. .id = VOICE_RECORD_TX,
  3691. .probe = msm_dai_q6_dai_probe,
  3692. .remove = msm_dai_q6_dai_remove,
  3693. },
  3694. {
  3695. .capture = {
  3696. .stream_name = "Voice Downlink Capture",
  3697. .aif_name = "INCALL_RECORD_RX",
  3698. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3699. SNDRV_PCM_RATE_16000,
  3700. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3701. .channels_min = 1,
  3702. .channels_max = 2,
  3703. .rate_min = 8000,
  3704. .rate_max = 48000,
  3705. },
  3706. .ops = &msm_dai_q6_ops,
  3707. .id = VOICE_RECORD_RX,
  3708. .probe = msm_dai_q6_dai_probe,
  3709. .remove = msm_dai_q6_dai_remove,
  3710. },
  3711. };
  3712. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  3713. .playback = {
  3714. .stream_name = "USB Audio Playback",
  3715. .aif_name = "USB_AUDIO_RX",
  3716. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3717. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3718. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3719. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3720. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3721. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3722. SNDRV_PCM_RATE_384000,
  3723. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3724. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3725. .channels_min = 1,
  3726. .channels_max = 8,
  3727. .rate_max = 384000,
  3728. .rate_min = 8000,
  3729. },
  3730. .ops = &msm_dai_q6_ops,
  3731. .id = AFE_PORT_ID_USB_RX,
  3732. .probe = msm_dai_q6_dai_probe,
  3733. .remove = msm_dai_q6_dai_remove,
  3734. };
  3735. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  3736. .capture = {
  3737. .stream_name = "USB Audio Capture",
  3738. .aif_name = "USB_AUDIO_TX",
  3739. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3740. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3741. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3742. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3743. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3744. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3745. SNDRV_PCM_RATE_384000,
  3746. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3747. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3748. .channels_min = 1,
  3749. .channels_max = 8,
  3750. .rate_max = 384000,
  3751. .rate_min = 8000,
  3752. },
  3753. .ops = &msm_dai_q6_ops,
  3754. .id = AFE_PORT_ID_USB_TX,
  3755. .probe = msm_dai_q6_dai_probe,
  3756. .remove = msm_dai_q6_dai_remove,
  3757. };
  3758. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  3759. {
  3760. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3761. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  3762. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  3763. uint32_t val = 0;
  3764. const char *intf_name;
  3765. int rc = 0, i = 0, len = 0;
  3766. const uint32_t *slot_mapping_array = NULL;
  3767. u32 array_length = 0;
  3768. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  3769. GFP_KERNEL);
  3770. if (!dai_data)
  3771. return -ENOMEM;
  3772. rc = of_property_read_u32(pdev->dev.of_node,
  3773. "qcom,msm-dai-is-island-supported",
  3774. &dai_data->is_island_dai);
  3775. if (rc)
  3776. dev_dbg(&pdev->dev, "island supported entry not found\n");
  3777. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  3778. GFP_KERNEL);
  3779. if (!auxpcm_pdata) {
  3780. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  3781. goto fail_pdata_nomem;
  3782. }
  3783. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  3784. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  3785. rc = of_property_read_u32_array(pdev->dev.of_node,
  3786. "qcom,msm-cpudai-auxpcm-mode",
  3787. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3788. if (rc) {
  3789. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  3790. __func__);
  3791. goto fail_invalid_dt;
  3792. }
  3793. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  3794. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  3795. rc = of_property_read_u32_array(pdev->dev.of_node,
  3796. "qcom,msm-cpudai-auxpcm-sync",
  3797. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3798. if (rc) {
  3799. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  3800. __func__);
  3801. goto fail_invalid_dt;
  3802. }
  3803. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  3804. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  3805. rc = of_property_read_u32_array(pdev->dev.of_node,
  3806. "qcom,msm-cpudai-auxpcm-frame",
  3807. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3808. if (rc) {
  3809. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  3810. __func__);
  3811. goto fail_invalid_dt;
  3812. }
  3813. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  3814. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  3815. rc = of_property_read_u32_array(pdev->dev.of_node,
  3816. "qcom,msm-cpudai-auxpcm-quant",
  3817. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3818. if (rc) {
  3819. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  3820. __func__);
  3821. goto fail_invalid_dt;
  3822. }
  3823. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  3824. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  3825. rc = of_property_read_u32_array(pdev->dev.of_node,
  3826. "qcom,msm-cpudai-auxpcm-num-slots",
  3827. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3828. if (rc) {
  3829. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  3830. __func__);
  3831. goto fail_invalid_dt;
  3832. }
  3833. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  3834. if (auxpcm_pdata->mode_8k.num_slots >
  3835. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  3836. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3837. __func__,
  3838. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  3839. auxpcm_pdata->mode_8k.num_slots);
  3840. rc = -EINVAL;
  3841. goto fail_invalid_dt;
  3842. }
  3843. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  3844. if (auxpcm_pdata->mode_16k.num_slots >
  3845. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  3846. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3847. __func__,
  3848. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  3849. auxpcm_pdata->mode_16k.num_slots);
  3850. rc = -EINVAL;
  3851. goto fail_invalid_dt;
  3852. }
  3853. slot_mapping_array = of_get_property(pdev->dev.of_node,
  3854. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  3855. if (slot_mapping_array == NULL) {
  3856. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  3857. __func__);
  3858. rc = -EINVAL;
  3859. goto fail_invalid_dt;
  3860. }
  3861. array_length = auxpcm_pdata->mode_8k.num_slots +
  3862. auxpcm_pdata->mode_16k.num_slots;
  3863. if (len != sizeof(uint32_t) * array_length) {
  3864. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  3865. __func__, len, sizeof(uint32_t) * array_length);
  3866. rc = -EINVAL;
  3867. goto fail_invalid_dt;
  3868. }
  3869. auxpcm_pdata->mode_8k.slot_mapping =
  3870. kzalloc(sizeof(uint16_t) *
  3871. auxpcm_pdata->mode_8k.num_slots,
  3872. GFP_KERNEL);
  3873. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  3874. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  3875. __func__);
  3876. rc = -ENOMEM;
  3877. goto fail_invalid_dt;
  3878. }
  3879. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  3880. auxpcm_pdata->mode_8k.slot_mapping[i] =
  3881. (u16)be32_to_cpu(slot_mapping_array[i]);
  3882. auxpcm_pdata->mode_16k.slot_mapping =
  3883. kzalloc(sizeof(uint16_t) *
  3884. auxpcm_pdata->mode_16k.num_slots,
  3885. GFP_KERNEL);
  3886. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  3887. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  3888. __func__);
  3889. rc = -ENOMEM;
  3890. goto fail_invalid_16k_slot_mapping;
  3891. }
  3892. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  3893. auxpcm_pdata->mode_16k.slot_mapping[i] =
  3894. (u16)be32_to_cpu(slot_mapping_array[i +
  3895. auxpcm_pdata->mode_8k.num_slots]);
  3896. rc = of_property_read_u32_array(pdev->dev.of_node,
  3897. "qcom,msm-cpudai-auxpcm-data",
  3898. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3899. if (rc) {
  3900. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  3901. __func__);
  3902. goto fail_invalid_dt1;
  3903. }
  3904. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  3905. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  3906. rc = of_property_read_u32_array(pdev->dev.of_node,
  3907. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  3908. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3909. if (rc) {
  3910. dev_err(&pdev->dev,
  3911. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  3912. __func__);
  3913. goto fail_invalid_dt1;
  3914. }
  3915. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  3916. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  3917. rc = of_property_read_string(pdev->dev.of_node,
  3918. "qcom,msm-auxpcm-interface", &intf_name);
  3919. if (rc) {
  3920. dev_err(&pdev->dev,
  3921. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  3922. __func__);
  3923. goto fail_nodev_intf;
  3924. }
  3925. if (!strcmp(intf_name, "primary")) {
  3926. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  3927. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  3928. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  3929. i = 0;
  3930. } else if (!strcmp(intf_name, "secondary")) {
  3931. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  3932. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  3933. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  3934. i = 1;
  3935. } else if (!strcmp(intf_name, "tertiary")) {
  3936. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  3937. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  3938. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  3939. i = 2;
  3940. } else if (!strcmp(intf_name, "quaternary")) {
  3941. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  3942. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  3943. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  3944. i = 3;
  3945. } else if (!strcmp(intf_name, "quinary")) {
  3946. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  3947. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  3948. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  3949. i = 4;
  3950. } else if (!strcmp(intf_name, "senary")) {
  3951. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  3952. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  3953. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  3954. i = 5;
  3955. } else {
  3956. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  3957. __func__, intf_name);
  3958. goto fail_invalid_intf;
  3959. }
  3960. rc = of_property_read_u32(pdev->dev.of_node,
  3961. "qcom,msm-cpudai-afe-clk-ver", &val);
  3962. if (rc)
  3963. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  3964. else
  3965. dai_data->afe_clk_ver = val;
  3966. mutex_init(&dai_data->rlock);
  3967. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  3968. dev_set_drvdata(&pdev->dev, dai_data);
  3969. pdev->dev.platform_data = (void *) auxpcm_pdata;
  3970. rc = snd_soc_register_component(&pdev->dev,
  3971. &msm_dai_q6_aux_pcm_dai_component,
  3972. &msm_dai_q6_aux_pcm_dai[i], 1);
  3973. if (rc) {
  3974. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  3975. __func__, rc);
  3976. goto fail_reg_dai;
  3977. }
  3978. return rc;
  3979. fail_reg_dai:
  3980. fail_invalid_intf:
  3981. fail_nodev_intf:
  3982. fail_invalid_dt1:
  3983. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  3984. fail_invalid_16k_slot_mapping:
  3985. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  3986. fail_invalid_dt:
  3987. kfree(auxpcm_pdata);
  3988. fail_pdata_nomem:
  3989. kfree(dai_data);
  3990. return rc;
  3991. }
  3992. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  3993. {
  3994. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3995. dai_data = dev_get_drvdata(&pdev->dev);
  3996. snd_soc_unregister_component(&pdev->dev);
  3997. mutex_destroy(&dai_data->rlock);
  3998. kfree(dai_data);
  3999. kfree(pdev->dev.platform_data);
  4000. return 0;
  4001. }
  4002. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  4003. { .compatible = "qcom,msm-auxpcm-dev", },
  4004. {}
  4005. };
  4006. static struct platform_driver msm_auxpcm_dev_driver = {
  4007. .probe = msm_auxpcm_dev_probe,
  4008. .remove = msm_auxpcm_dev_remove,
  4009. .driver = {
  4010. .name = "msm-auxpcm-dev",
  4011. .owner = THIS_MODULE,
  4012. .of_match_table = msm_auxpcm_dev_dt_match,
  4013. .suppress_bind_attrs = true,
  4014. },
  4015. };
  4016. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  4017. {
  4018. .playback = {
  4019. .stream_name = "Slimbus Playback",
  4020. .aif_name = "SLIMBUS_0_RX",
  4021. .rates = SNDRV_PCM_RATE_8000_384000,
  4022. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4023. .channels_min = 1,
  4024. .channels_max = 8,
  4025. .rate_min = 8000,
  4026. .rate_max = 384000,
  4027. },
  4028. .ops = &msm_dai_slimbus_0_rx_ops,
  4029. .id = SLIMBUS_0_RX,
  4030. .probe = msm_dai_q6_dai_probe,
  4031. .remove = msm_dai_q6_dai_remove,
  4032. },
  4033. {
  4034. .playback = {
  4035. .stream_name = "Slimbus1 Playback",
  4036. .aif_name = "SLIMBUS_1_RX",
  4037. .rates = SNDRV_PCM_RATE_8000_384000,
  4038. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4039. .channels_min = 1,
  4040. .channels_max = 2,
  4041. .rate_min = 8000,
  4042. .rate_max = 384000,
  4043. },
  4044. .ops = &msm_dai_q6_ops,
  4045. .id = SLIMBUS_1_RX,
  4046. .probe = msm_dai_q6_dai_probe,
  4047. .remove = msm_dai_q6_dai_remove,
  4048. },
  4049. {
  4050. .playback = {
  4051. .stream_name = "Slimbus2 Playback",
  4052. .aif_name = "SLIMBUS_2_RX",
  4053. .rates = SNDRV_PCM_RATE_8000_384000,
  4054. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4055. .channels_min = 1,
  4056. .channels_max = 8,
  4057. .rate_min = 8000,
  4058. .rate_max = 384000,
  4059. },
  4060. .ops = &msm_dai_q6_ops,
  4061. .id = SLIMBUS_2_RX,
  4062. .probe = msm_dai_q6_dai_probe,
  4063. .remove = msm_dai_q6_dai_remove,
  4064. },
  4065. {
  4066. .playback = {
  4067. .stream_name = "Slimbus3 Playback",
  4068. .aif_name = "SLIMBUS_3_RX",
  4069. .rates = SNDRV_PCM_RATE_8000_384000,
  4070. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4071. .channels_min = 1,
  4072. .channels_max = 2,
  4073. .rate_min = 8000,
  4074. .rate_max = 384000,
  4075. },
  4076. .ops = &msm_dai_q6_ops,
  4077. .id = SLIMBUS_3_RX,
  4078. .probe = msm_dai_q6_dai_probe,
  4079. .remove = msm_dai_q6_dai_remove,
  4080. },
  4081. {
  4082. .playback = {
  4083. .stream_name = "Slimbus4 Playback",
  4084. .aif_name = "SLIMBUS_4_RX",
  4085. .rates = SNDRV_PCM_RATE_8000_384000,
  4086. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4087. .channels_min = 1,
  4088. .channels_max = 2,
  4089. .rate_min = 8000,
  4090. .rate_max = 384000,
  4091. },
  4092. .ops = &msm_dai_q6_ops,
  4093. .id = SLIMBUS_4_RX,
  4094. .probe = msm_dai_q6_dai_probe,
  4095. .remove = msm_dai_q6_dai_remove,
  4096. },
  4097. {
  4098. .playback = {
  4099. .stream_name = "Slimbus6 Playback",
  4100. .aif_name = "SLIMBUS_6_RX",
  4101. .rates = SNDRV_PCM_RATE_8000_384000,
  4102. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4103. .channels_min = 1,
  4104. .channels_max = 2,
  4105. .rate_min = 8000,
  4106. .rate_max = 384000,
  4107. },
  4108. .ops = &msm_dai_q6_ops,
  4109. .id = SLIMBUS_6_RX,
  4110. .probe = msm_dai_q6_dai_probe,
  4111. .remove = msm_dai_q6_dai_remove,
  4112. },
  4113. {
  4114. .playback = {
  4115. .stream_name = "Slimbus5 Playback",
  4116. .aif_name = "SLIMBUS_5_RX",
  4117. .rates = SNDRV_PCM_RATE_8000_384000,
  4118. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4119. .channels_min = 1,
  4120. .channels_max = 2,
  4121. .rate_min = 8000,
  4122. .rate_max = 384000,
  4123. },
  4124. .ops = &msm_dai_q6_ops,
  4125. .id = SLIMBUS_5_RX,
  4126. .probe = msm_dai_q6_dai_probe,
  4127. .remove = msm_dai_q6_dai_remove,
  4128. },
  4129. {
  4130. .playback = {
  4131. .stream_name = "Slimbus7 Playback",
  4132. .aif_name = "SLIMBUS_7_RX",
  4133. .rates = SNDRV_PCM_RATE_8000_384000,
  4134. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4135. .channels_min = 1,
  4136. .channels_max = 8,
  4137. .rate_min = 8000,
  4138. .rate_max = 384000,
  4139. },
  4140. .ops = &msm_dai_q6_ops,
  4141. .id = SLIMBUS_7_RX,
  4142. .probe = msm_dai_q6_dai_probe,
  4143. .remove = msm_dai_q6_dai_remove,
  4144. },
  4145. {
  4146. .playback = {
  4147. .stream_name = "Slimbus8 Playback",
  4148. .aif_name = "SLIMBUS_8_RX",
  4149. .rates = SNDRV_PCM_RATE_8000_384000,
  4150. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4151. .channels_min = 1,
  4152. .channels_max = 8,
  4153. .rate_min = 8000,
  4154. .rate_max = 384000,
  4155. },
  4156. .ops = &msm_dai_q6_ops,
  4157. .id = SLIMBUS_8_RX,
  4158. .probe = msm_dai_q6_dai_probe,
  4159. .remove = msm_dai_q6_dai_remove,
  4160. },
  4161. {
  4162. .playback = {
  4163. .stream_name = "Slimbus9 Playback",
  4164. .aif_name = "SLIMBUS_9_RX",
  4165. .rates = SNDRV_PCM_RATE_8000_384000,
  4166. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4167. .channels_min = 1,
  4168. .channels_max = 8,
  4169. .rate_min = 8000,
  4170. .rate_max = 384000,
  4171. },
  4172. .ops = &msm_dai_q6_ops,
  4173. .id = SLIMBUS_9_RX,
  4174. .probe = msm_dai_q6_dai_probe,
  4175. .remove = msm_dai_q6_dai_remove,
  4176. },
  4177. };
  4178. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  4179. {
  4180. .capture = {
  4181. .stream_name = "Slimbus Capture",
  4182. .aif_name = "SLIMBUS_0_TX",
  4183. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4184. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4185. SNDRV_PCM_RATE_192000,
  4186. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4187. SNDRV_PCM_FMTBIT_S24_LE |
  4188. SNDRV_PCM_FMTBIT_S24_3LE,
  4189. .channels_min = 1,
  4190. .channels_max = 8,
  4191. .rate_min = 8000,
  4192. .rate_max = 192000,
  4193. },
  4194. .ops = &msm_dai_q6_ops,
  4195. .id = SLIMBUS_0_TX,
  4196. .probe = msm_dai_q6_dai_probe,
  4197. .remove = msm_dai_q6_dai_remove,
  4198. },
  4199. {
  4200. .capture = {
  4201. .stream_name = "Slimbus1 Capture",
  4202. .aif_name = "SLIMBUS_1_TX",
  4203. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4204. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4205. SNDRV_PCM_RATE_192000,
  4206. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4207. SNDRV_PCM_FMTBIT_S24_LE |
  4208. SNDRV_PCM_FMTBIT_S24_3LE,
  4209. .channels_min = 1,
  4210. .channels_max = 2,
  4211. .rate_min = 8000,
  4212. .rate_max = 192000,
  4213. },
  4214. .ops = &msm_dai_q6_ops,
  4215. .id = SLIMBUS_1_TX,
  4216. .probe = msm_dai_q6_dai_probe,
  4217. .remove = msm_dai_q6_dai_remove,
  4218. },
  4219. {
  4220. .capture = {
  4221. .stream_name = "Slimbus2 Capture",
  4222. .aif_name = "SLIMBUS_2_TX",
  4223. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4224. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4225. SNDRV_PCM_RATE_192000,
  4226. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4227. SNDRV_PCM_FMTBIT_S24_LE,
  4228. .channels_min = 1,
  4229. .channels_max = 8,
  4230. .rate_min = 8000,
  4231. .rate_max = 192000,
  4232. },
  4233. .ops = &msm_dai_q6_ops,
  4234. .id = SLIMBUS_2_TX,
  4235. .probe = msm_dai_q6_dai_probe,
  4236. .remove = msm_dai_q6_dai_remove,
  4237. },
  4238. {
  4239. .capture = {
  4240. .stream_name = "Slimbus3 Capture",
  4241. .aif_name = "SLIMBUS_3_TX",
  4242. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4243. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4244. SNDRV_PCM_RATE_192000,
  4245. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4246. SNDRV_PCM_FMTBIT_S24_LE,
  4247. .channels_min = 2,
  4248. .channels_max = 4,
  4249. .rate_min = 8000,
  4250. .rate_max = 192000,
  4251. },
  4252. .ops = &msm_dai_q6_ops,
  4253. .id = SLIMBUS_3_TX,
  4254. .probe = msm_dai_q6_dai_probe,
  4255. .remove = msm_dai_q6_dai_remove,
  4256. },
  4257. {
  4258. .capture = {
  4259. .stream_name = "Slimbus4 Capture",
  4260. .aif_name = "SLIMBUS_4_TX",
  4261. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4262. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4263. SNDRV_PCM_RATE_192000,
  4264. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4265. SNDRV_PCM_FMTBIT_S24_LE |
  4266. SNDRV_PCM_FMTBIT_S32_LE,
  4267. .channels_min = 2,
  4268. .channels_max = 4,
  4269. .rate_min = 8000,
  4270. .rate_max = 192000,
  4271. },
  4272. .ops = &msm_dai_q6_ops,
  4273. .id = SLIMBUS_4_TX,
  4274. .probe = msm_dai_q6_dai_probe,
  4275. .remove = msm_dai_q6_dai_remove,
  4276. },
  4277. {
  4278. .capture = {
  4279. .stream_name = "Slimbus5 Capture",
  4280. .aif_name = "SLIMBUS_5_TX",
  4281. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4282. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4283. SNDRV_PCM_RATE_192000,
  4284. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4285. SNDRV_PCM_FMTBIT_S24_LE,
  4286. .channels_min = 1,
  4287. .channels_max = 8,
  4288. .rate_min = 8000,
  4289. .rate_max = 192000,
  4290. },
  4291. .ops = &msm_dai_q6_ops,
  4292. .id = SLIMBUS_5_TX,
  4293. .probe = msm_dai_q6_dai_probe,
  4294. .remove = msm_dai_q6_dai_remove,
  4295. },
  4296. {
  4297. .capture = {
  4298. .stream_name = "Slimbus6 Capture",
  4299. .aif_name = "SLIMBUS_6_TX",
  4300. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4301. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4302. SNDRV_PCM_RATE_192000,
  4303. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4304. SNDRV_PCM_FMTBIT_S24_LE,
  4305. .channels_min = 1,
  4306. .channels_max = 2,
  4307. .rate_min = 8000,
  4308. .rate_max = 192000,
  4309. },
  4310. .ops = &msm_dai_q6_ops,
  4311. .id = SLIMBUS_6_TX,
  4312. .probe = msm_dai_q6_dai_probe,
  4313. .remove = msm_dai_q6_dai_remove,
  4314. },
  4315. {
  4316. .capture = {
  4317. .stream_name = "Slimbus7 Capture",
  4318. .aif_name = "SLIMBUS_7_TX",
  4319. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4320. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4321. SNDRV_PCM_RATE_192000,
  4322. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4323. SNDRV_PCM_FMTBIT_S24_LE |
  4324. SNDRV_PCM_FMTBIT_S32_LE,
  4325. .channels_min = 1,
  4326. .channels_max = 8,
  4327. .rate_min = 8000,
  4328. .rate_max = 192000,
  4329. },
  4330. .ops = &msm_dai_q6_ops,
  4331. .id = SLIMBUS_7_TX,
  4332. .probe = msm_dai_q6_dai_probe,
  4333. .remove = msm_dai_q6_dai_remove,
  4334. },
  4335. {
  4336. .capture = {
  4337. .stream_name = "Slimbus8 Capture",
  4338. .aif_name = "SLIMBUS_8_TX",
  4339. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4340. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4341. SNDRV_PCM_RATE_192000,
  4342. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4343. SNDRV_PCM_FMTBIT_S24_LE |
  4344. SNDRV_PCM_FMTBIT_S32_LE,
  4345. .channels_min = 1,
  4346. .channels_max = 8,
  4347. .rate_min = 8000,
  4348. .rate_max = 192000,
  4349. },
  4350. .ops = &msm_dai_q6_ops,
  4351. .id = SLIMBUS_8_TX,
  4352. .probe = msm_dai_q6_dai_probe,
  4353. .remove = msm_dai_q6_dai_remove,
  4354. },
  4355. {
  4356. .capture = {
  4357. .stream_name = "Slimbus9 Capture",
  4358. .aif_name = "SLIMBUS_9_TX",
  4359. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4360. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  4361. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  4362. SNDRV_PCM_RATE_192000,
  4363. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4364. SNDRV_PCM_FMTBIT_S24_LE |
  4365. SNDRV_PCM_FMTBIT_S32_LE,
  4366. .channels_min = 1,
  4367. .channels_max = 8,
  4368. .rate_min = 8000,
  4369. .rate_max = 192000,
  4370. },
  4371. .ops = &msm_dai_q6_ops,
  4372. .id = SLIMBUS_9_TX,
  4373. .probe = msm_dai_q6_dai_probe,
  4374. .remove = msm_dai_q6_dai_remove,
  4375. },
  4376. };
  4377. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  4378. struct snd_ctl_elem_value *ucontrol)
  4379. {
  4380. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4381. int value = ucontrol->value.integer.value[0];
  4382. dai_data->port_config.i2s.data_format = value;
  4383. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  4384. __func__, value, dai_data->port_config.i2s.mono_stereo,
  4385. dai_data->port_config.i2s.channel_mode);
  4386. return 0;
  4387. }
  4388. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  4389. struct snd_ctl_elem_value *ucontrol)
  4390. {
  4391. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4392. ucontrol->value.integer.value[0] =
  4393. dai_data->port_config.i2s.data_format;
  4394. return 0;
  4395. }
  4396. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  4397. struct snd_ctl_elem_value *ucontrol)
  4398. {
  4399. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4400. int value = ucontrol->value.integer.value[0];
  4401. dai_data->vi_feed_mono = value;
  4402. pr_debug("%s: value = %d\n", __func__, value);
  4403. return 0;
  4404. }
  4405. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  4406. struct snd_ctl_elem_value *ucontrol)
  4407. {
  4408. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4409. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  4410. return 0;
  4411. }
  4412. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  4413. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  4414. msm_dai_q6_mi2s_format_get,
  4415. msm_dai_q6_mi2s_format_put),
  4416. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  4417. msm_dai_q6_mi2s_format_get,
  4418. msm_dai_q6_mi2s_format_put),
  4419. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  4420. msm_dai_q6_mi2s_format_get,
  4421. msm_dai_q6_mi2s_format_put),
  4422. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  4423. msm_dai_q6_mi2s_format_get,
  4424. msm_dai_q6_mi2s_format_put),
  4425. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  4426. msm_dai_q6_mi2s_format_get,
  4427. msm_dai_q6_mi2s_format_put),
  4428. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  4429. msm_dai_q6_mi2s_format_get,
  4430. msm_dai_q6_mi2s_format_put),
  4431. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  4432. msm_dai_q6_mi2s_format_get,
  4433. msm_dai_q6_mi2s_format_put),
  4434. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  4435. msm_dai_q6_mi2s_format_get,
  4436. msm_dai_q6_mi2s_format_put),
  4437. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  4438. msm_dai_q6_mi2s_format_get,
  4439. msm_dai_q6_mi2s_format_put),
  4440. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  4441. msm_dai_q6_mi2s_format_get,
  4442. msm_dai_q6_mi2s_format_put),
  4443. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  4444. msm_dai_q6_mi2s_format_get,
  4445. msm_dai_q6_mi2s_format_put),
  4446. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4447. msm_dai_q6_mi2s_format_get,
  4448. msm_dai_q6_mi2s_format_put),
  4449. };
  4450. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4451. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4452. msm_dai_q6_mi2s_vi_feed_mono_get,
  4453. msm_dai_q6_mi2s_vi_feed_mono_put),
  4454. };
  4455. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4456. {
  4457. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4458. dev_get_drvdata(dai->dev);
  4459. struct msm_mi2s_pdata *mi2s_pdata =
  4460. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4461. struct snd_kcontrol *kcontrol = NULL;
  4462. int rc = 0;
  4463. const struct snd_kcontrol_new *ctrl = NULL;
  4464. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4465. u16 dai_id = 0;
  4466. dai->id = mi2s_pdata->intf_id;
  4467. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4468. if (dai->id == MSM_PRIM_MI2S)
  4469. ctrl = &mi2s_config_controls[0];
  4470. if (dai->id == MSM_SEC_MI2S)
  4471. ctrl = &mi2s_config_controls[1];
  4472. if (dai->id == MSM_TERT_MI2S)
  4473. ctrl = &mi2s_config_controls[2];
  4474. if (dai->id == MSM_QUAT_MI2S)
  4475. ctrl = &mi2s_config_controls[3];
  4476. if (dai->id == MSM_QUIN_MI2S)
  4477. ctrl = &mi2s_config_controls[4];
  4478. }
  4479. if (ctrl) {
  4480. kcontrol = snd_ctl_new1(ctrl,
  4481. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4482. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4483. if (rc < 0) {
  4484. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4485. __func__, dai->name);
  4486. goto rtn;
  4487. }
  4488. }
  4489. ctrl = NULL;
  4490. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4491. if (dai->id == MSM_PRIM_MI2S)
  4492. ctrl = &mi2s_config_controls[5];
  4493. if (dai->id == MSM_SEC_MI2S)
  4494. ctrl = &mi2s_config_controls[6];
  4495. if (dai->id == MSM_TERT_MI2S)
  4496. ctrl = &mi2s_config_controls[7];
  4497. if (dai->id == MSM_QUAT_MI2S)
  4498. ctrl = &mi2s_config_controls[8];
  4499. if (dai->id == MSM_QUIN_MI2S)
  4500. ctrl = &mi2s_config_controls[9];
  4501. if (dai->id == MSM_SENARY_MI2S)
  4502. ctrl = &mi2s_config_controls[10];
  4503. if (dai->id == MSM_INT5_MI2S)
  4504. ctrl = &mi2s_config_controls[11];
  4505. }
  4506. if (ctrl) {
  4507. rc = snd_ctl_add(dai->component->card->snd_card,
  4508. snd_ctl_new1(ctrl,
  4509. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4510. if (rc < 0) {
  4511. if (kcontrol)
  4512. snd_ctl_remove(dai->component->card->snd_card,
  4513. kcontrol);
  4514. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4515. __func__, dai->name);
  4516. }
  4517. }
  4518. if (dai->id == MSM_INT5_MI2S)
  4519. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4520. if (vi_feed_ctrl) {
  4521. rc = snd_ctl_add(dai->component->card->snd_card,
  4522. snd_ctl_new1(vi_feed_ctrl,
  4523. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4524. if (rc < 0) {
  4525. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  4526. __func__, dai->name);
  4527. }
  4528. }
  4529. if (mi2s_dai_data->is_island_dai) {
  4530. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  4531. &dai_id);
  4532. rc = msm_dai_q6_add_island_mx_ctls(
  4533. dai->component->card->snd_card,
  4534. dai->name, dai_id,
  4535. (void *)mi2s_dai_data);
  4536. }
  4537. rc = msm_dai_q6_dai_add_route(dai);
  4538. rtn:
  4539. return rc;
  4540. }
  4541. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  4542. {
  4543. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4544. dev_get_drvdata(dai->dev);
  4545. int rc;
  4546. /* If AFE port is still up, close it */
  4547. if (test_bit(STATUS_PORT_STARTED,
  4548. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  4549. rc = afe_close(MI2S_RX); /* can block */
  4550. if (rc < 0)
  4551. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  4552. clear_bit(STATUS_PORT_STARTED,
  4553. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  4554. }
  4555. if (test_bit(STATUS_PORT_STARTED,
  4556. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4557. rc = afe_close(MI2S_TX); /* can block */
  4558. if (rc < 0)
  4559. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  4560. clear_bit(STATUS_PORT_STARTED,
  4561. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  4562. }
  4563. return 0;
  4564. }
  4565. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  4566. struct snd_soc_dai *dai)
  4567. {
  4568. return 0;
  4569. }
  4570. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4571. {
  4572. int ret = 0;
  4573. switch (stream) {
  4574. case SNDRV_PCM_STREAM_PLAYBACK:
  4575. switch (mi2s_id) {
  4576. case MSM_PRIM_MI2S:
  4577. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4578. break;
  4579. case MSM_SEC_MI2S:
  4580. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4581. break;
  4582. case MSM_TERT_MI2S:
  4583. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4584. break;
  4585. case MSM_QUAT_MI2S:
  4586. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4587. break;
  4588. case MSM_SEC_MI2S_SD1:
  4589. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4590. break;
  4591. case MSM_QUIN_MI2S:
  4592. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4593. break;
  4594. case MSM_SENARY_MI2S:
  4595. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  4596. break;
  4597. case MSM_INT0_MI2S:
  4598. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4599. break;
  4600. case MSM_INT1_MI2S:
  4601. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4602. break;
  4603. case MSM_INT2_MI2S:
  4604. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4605. break;
  4606. case MSM_INT3_MI2S:
  4607. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4608. break;
  4609. case MSM_INT4_MI2S:
  4610. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4611. break;
  4612. case MSM_INT5_MI2S:
  4613. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4614. break;
  4615. case MSM_INT6_MI2S:
  4616. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4617. break;
  4618. default:
  4619. pr_err("%s: playback err id 0x%x\n",
  4620. __func__, mi2s_id);
  4621. ret = -1;
  4622. break;
  4623. }
  4624. break;
  4625. case SNDRV_PCM_STREAM_CAPTURE:
  4626. switch (mi2s_id) {
  4627. case MSM_PRIM_MI2S:
  4628. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4629. break;
  4630. case MSM_SEC_MI2S:
  4631. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4632. break;
  4633. case MSM_TERT_MI2S:
  4634. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4635. break;
  4636. case MSM_QUAT_MI2S:
  4637. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4638. break;
  4639. case MSM_QUIN_MI2S:
  4640. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4641. break;
  4642. case MSM_SENARY_MI2S:
  4643. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4644. break;
  4645. case MSM_INT0_MI2S:
  4646. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4647. break;
  4648. case MSM_INT1_MI2S:
  4649. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4650. break;
  4651. case MSM_INT2_MI2S:
  4652. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4653. break;
  4654. case MSM_INT3_MI2S:
  4655. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4656. break;
  4657. case MSM_INT4_MI2S:
  4658. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4659. break;
  4660. case MSM_INT5_MI2S:
  4661. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4662. break;
  4663. case MSM_INT6_MI2S:
  4664. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4665. break;
  4666. default:
  4667. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4668. ret = -1;
  4669. break;
  4670. }
  4671. break;
  4672. default:
  4673. pr_err("%s: default err %d\n", __func__, stream);
  4674. ret = -1;
  4675. break;
  4676. }
  4677. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4678. return ret;
  4679. }
  4680. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4681. struct snd_soc_dai *dai)
  4682. {
  4683. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4684. dev_get_drvdata(dai->dev);
  4685. struct msm_dai_q6_dai_data *dai_data =
  4686. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4687. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4688. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4689. u16 port_id = 0;
  4690. int rc = 0;
  4691. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4692. &port_id) != 0) {
  4693. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4694. __func__, port_id);
  4695. return -EINVAL;
  4696. }
  4697. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4698. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4699. dai->id, port_id, dai_data->channels, dai_data->rate);
  4700. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4701. /* PORT START should be set if prepare called
  4702. * in active state.
  4703. */
  4704. rc = afe_port_start(port_id, &dai_data->port_config,
  4705. dai_data->rate);
  4706. if (rc < 0)
  4707. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4708. dai->id);
  4709. else
  4710. set_bit(STATUS_PORT_STARTED,
  4711. dai_data->status_mask);
  4712. }
  4713. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4714. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4715. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4716. __func__);
  4717. }
  4718. return rc;
  4719. }
  4720. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  4721. struct snd_pcm_hw_params *params,
  4722. struct snd_soc_dai *dai)
  4723. {
  4724. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4725. dev_get_drvdata(dai->dev);
  4726. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  4727. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4728. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  4729. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  4730. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  4731. dai_data->channels = params_channels(params);
  4732. switch (dai_data->channels) {
  4733. case 15:
  4734. case 16:
  4735. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4736. case AFE_PORT_I2S_16CHS:
  4737. dai_data->port_config.i2s.channel_mode
  4738. = AFE_PORT_I2S_16CHS;
  4739. break;
  4740. default:
  4741. goto error_invalid_data;
  4742. };
  4743. break;
  4744. case 13:
  4745. case 14:
  4746. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4747. case AFE_PORT_I2S_14CHS:
  4748. case AFE_PORT_I2S_16CHS:
  4749. dai_data->port_config.i2s.channel_mode
  4750. = AFE_PORT_I2S_14CHS;
  4751. break;
  4752. default:
  4753. goto error_invalid_data;
  4754. };
  4755. break;
  4756. case 11:
  4757. case 12:
  4758. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4759. case AFE_PORT_I2S_12CHS:
  4760. case AFE_PORT_I2S_14CHS:
  4761. case AFE_PORT_I2S_16CHS:
  4762. dai_data->port_config.i2s.channel_mode
  4763. = AFE_PORT_I2S_12CHS;
  4764. break;
  4765. default:
  4766. goto error_invalid_data;
  4767. };
  4768. break;
  4769. case 9:
  4770. case 10:
  4771. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4772. case AFE_PORT_I2S_10CHS:
  4773. case AFE_PORT_I2S_12CHS:
  4774. case AFE_PORT_I2S_14CHS:
  4775. case AFE_PORT_I2S_16CHS:
  4776. dai_data->port_config.i2s.channel_mode
  4777. = AFE_PORT_I2S_10CHS;
  4778. break;
  4779. default:
  4780. goto error_invalid_data;
  4781. };
  4782. break;
  4783. case 8:
  4784. case 7:
  4785. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  4786. goto error_invalid_data;
  4787. else
  4788. if (mi2s_dai_config->pdata_mi2s_lines
  4789. == AFE_PORT_I2S_8CHS_2)
  4790. dai_data->port_config.i2s.channel_mode =
  4791. AFE_PORT_I2S_8CHS_2;
  4792. else
  4793. dai_data->port_config.i2s.channel_mode =
  4794. AFE_PORT_I2S_8CHS;
  4795. break;
  4796. case 6:
  4797. case 5:
  4798. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  4799. goto error_invalid_data;
  4800. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  4801. break;
  4802. case 4:
  4803. case 3:
  4804. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4805. case AFE_PORT_I2S_SD0:
  4806. case AFE_PORT_I2S_SD1:
  4807. case AFE_PORT_I2S_SD2:
  4808. case AFE_PORT_I2S_SD3:
  4809. case AFE_PORT_I2S_SD4:
  4810. case AFE_PORT_I2S_SD5:
  4811. case AFE_PORT_I2S_SD6:
  4812. case AFE_PORT_I2S_SD7:
  4813. goto error_invalid_data;
  4814. break;
  4815. case AFE_PORT_I2S_QUAD01:
  4816. case AFE_PORT_I2S_QUAD23:
  4817. case AFE_PORT_I2S_QUAD45:
  4818. case AFE_PORT_I2S_QUAD67:
  4819. dai_data->port_config.i2s.channel_mode =
  4820. mi2s_dai_config->pdata_mi2s_lines;
  4821. break;
  4822. case AFE_PORT_I2S_8CHS_2:
  4823. dai_data->port_config.i2s.channel_mode =
  4824. AFE_PORT_I2S_QUAD45;
  4825. break;
  4826. default:
  4827. dai_data->port_config.i2s.channel_mode =
  4828. AFE_PORT_I2S_QUAD01;
  4829. break;
  4830. };
  4831. break;
  4832. case 2:
  4833. case 1:
  4834. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  4835. goto error_invalid_data;
  4836. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4837. case AFE_PORT_I2S_SD0:
  4838. case AFE_PORT_I2S_SD1:
  4839. case AFE_PORT_I2S_SD2:
  4840. case AFE_PORT_I2S_SD3:
  4841. case AFE_PORT_I2S_SD4:
  4842. case AFE_PORT_I2S_SD5:
  4843. case AFE_PORT_I2S_SD6:
  4844. case AFE_PORT_I2S_SD7:
  4845. dai_data->port_config.i2s.channel_mode =
  4846. mi2s_dai_config->pdata_mi2s_lines;
  4847. break;
  4848. case AFE_PORT_I2S_QUAD01:
  4849. case AFE_PORT_I2S_6CHS:
  4850. case AFE_PORT_I2S_8CHS:
  4851. case AFE_PORT_I2S_10CHS:
  4852. case AFE_PORT_I2S_12CHS:
  4853. case AFE_PORT_I2S_14CHS:
  4854. case AFE_PORT_I2S_16CHS:
  4855. if (dai_data->vi_feed_mono == SPKR_1)
  4856. dai_data->port_config.i2s.channel_mode =
  4857. AFE_PORT_I2S_SD0;
  4858. else
  4859. dai_data->port_config.i2s.channel_mode =
  4860. AFE_PORT_I2S_SD1;
  4861. break;
  4862. case AFE_PORT_I2S_QUAD23:
  4863. dai_data->port_config.i2s.channel_mode =
  4864. AFE_PORT_I2S_SD2;
  4865. break;
  4866. case AFE_PORT_I2S_QUAD45:
  4867. dai_data->port_config.i2s.channel_mode =
  4868. AFE_PORT_I2S_SD4;
  4869. break;
  4870. case AFE_PORT_I2S_QUAD67:
  4871. dai_data->port_config.i2s.channel_mode =
  4872. AFE_PORT_I2S_SD6;
  4873. break;
  4874. }
  4875. if (dai_data->channels == 2)
  4876. dai_data->port_config.i2s.mono_stereo =
  4877. MSM_AFE_CH_STEREO;
  4878. else
  4879. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  4880. break;
  4881. default:
  4882. pr_err("%s: default err channels %d\n",
  4883. __func__, dai_data->channels);
  4884. goto error_invalid_data;
  4885. }
  4886. dai_data->rate = params_rate(params);
  4887. switch (params_format(params)) {
  4888. case SNDRV_PCM_FORMAT_S16_LE:
  4889. case SNDRV_PCM_FORMAT_SPECIAL:
  4890. dai_data->port_config.i2s.bit_width = 16;
  4891. dai_data->bitwidth = 16;
  4892. break;
  4893. case SNDRV_PCM_FORMAT_S24_LE:
  4894. case SNDRV_PCM_FORMAT_S24_3LE:
  4895. dai_data->port_config.i2s.bit_width = 24;
  4896. dai_data->bitwidth = 24;
  4897. break;
  4898. default:
  4899. pr_err("%s: format %d\n",
  4900. __func__, params_format(params));
  4901. return -EINVAL;
  4902. }
  4903. dai_data->port_config.i2s.i2s_cfg_minor_version =
  4904. AFE_API_VERSION_I2S_CONFIG;
  4905. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  4906. if ((test_bit(STATUS_PORT_STARTED,
  4907. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  4908. test_bit(STATUS_PORT_STARTED,
  4909. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  4910. (test_bit(STATUS_PORT_STARTED,
  4911. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  4912. test_bit(STATUS_PORT_STARTED,
  4913. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  4914. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  4915. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  4916. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  4917. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  4918. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  4919. "Tx sample_rate = %u bit_width = %hu\n"
  4920. "Rx sample_rate = %u bit_width = %hu\n"
  4921. , __func__,
  4922. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  4923. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  4924. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  4925. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  4926. return -EINVAL;
  4927. }
  4928. }
  4929. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  4930. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  4931. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  4932. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  4933. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  4934. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  4935. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  4936. i2s->sample_rate, i2s->data_format, i2s->reserved);
  4937. return 0;
  4938. error_invalid_data:
  4939. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  4940. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  4941. return -EINVAL;
  4942. }
  4943. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  4944. {
  4945. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4946. dev_get_drvdata(dai->dev);
  4947. if (test_bit(STATUS_PORT_STARTED,
  4948. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  4949. test_bit(STATUS_PORT_STARTED,
  4950. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4951. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  4952. __func__);
  4953. return -EPERM;
  4954. }
  4955. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  4956. case SND_SOC_DAIFMT_CBS_CFS:
  4957. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4958. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4959. break;
  4960. case SND_SOC_DAIFMT_CBM_CFM:
  4961. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4962. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4963. break;
  4964. default:
  4965. pr_err("%s: fmt %d\n",
  4966. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  4967. return -EINVAL;
  4968. }
  4969. return 0;
  4970. }
  4971. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  4972. struct snd_soc_dai *dai)
  4973. {
  4974. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4975. dev_get_drvdata(dai->dev);
  4976. struct msm_dai_q6_dai_data *dai_data =
  4977. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4978. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4979. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4980. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4981. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4982. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  4983. }
  4984. return 0;
  4985. }
  4986. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  4987. struct snd_soc_dai *dai)
  4988. {
  4989. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4990. dev_get_drvdata(dai->dev);
  4991. struct msm_dai_q6_dai_data *dai_data =
  4992. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4993. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4994. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4995. u16 port_id = 0;
  4996. int rc = 0;
  4997. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4998. &port_id) != 0) {
  4999. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5000. __func__, port_id);
  5001. }
  5002. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  5003. __func__, port_id);
  5004. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5005. rc = afe_close(port_id);
  5006. if (rc < 0)
  5007. dev_err(dai->dev, "fail to close AFE port\n");
  5008. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  5009. }
  5010. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  5011. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5012. }
  5013. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  5014. .startup = msm_dai_q6_mi2s_startup,
  5015. .prepare = msm_dai_q6_mi2s_prepare,
  5016. .hw_params = msm_dai_q6_mi2s_hw_params,
  5017. .hw_free = msm_dai_q6_mi2s_hw_free,
  5018. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  5019. .shutdown = msm_dai_q6_mi2s_shutdown,
  5020. };
  5021. /* Channel min and max are initialized base on platform data */
  5022. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  5023. {
  5024. .playback = {
  5025. .stream_name = "Primary MI2S Playback",
  5026. .aif_name = "PRI_MI2S_RX",
  5027. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5028. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5029. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5030. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5031. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5032. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5033. SNDRV_PCM_RATE_384000,
  5034. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5035. SNDRV_PCM_FMTBIT_S24_LE |
  5036. SNDRV_PCM_FMTBIT_S24_3LE,
  5037. .rate_min = 8000,
  5038. .rate_max = 384000,
  5039. },
  5040. .capture = {
  5041. .stream_name = "Primary MI2S Capture",
  5042. .aif_name = "PRI_MI2S_TX",
  5043. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5044. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5045. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5046. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5047. SNDRV_PCM_RATE_192000,
  5048. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5049. .rate_min = 8000,
  5050. .rate_max = 192000,
  5051. },
  5052. .ops = &msm_dai_q6_mi2s_ops,
  5053. .name = "Primary MI2S",
  5054. .id = MSM_PRIM_MI2S,
  5055. .probe = msm_dai_q6_dai_mi2s_probe,
  5056. .remove = msm_dai_q6_dai_mi2s_remove,
  5057. },
  5058. {
  5059. .playback = {
  5060. .stream_name = "Secondary MI2S Playback",
  5061. .aif_name = "SEC_MI2S_RX",
  5062. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5063. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5064. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5065. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5066. SNDRV_PCM_RATE_192000,
  5067. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5068. .rate_min = 8000,
  5069. .rate_max = 192000,
  5070. },
  5071. .capture = {
  5072. .stream_name = "Secondary MI2S Capture",
  5073. .aif_name = "SEC_MI2S_TX",
  5074. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5075. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5076. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5077. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5078. SNDRV_PCM_RATE_192000,
  5079. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5080. .rate_min = 8000,
  5081. .rate_max = 192000,
  5082. },
  5083. .ops = &msm_dai_q6_mi2s_ops,
  5084. .name = "Secondary MI2S",
  5085. .id = MSM_SEC_MI2S,
  5086. .probe = msm_dai_q6_dai_mi2s_probe,
  5087. .remove = msm_dai_q6_dai_mi2s_remove,
  5088. },
  5089. {
  5090. .playback = {
  5091. .stream_name = "Tertiary MI2S Playback",
  5092. .aif_name = "TERT_MI2S_RX",
  5093. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5094. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5095. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5096. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5097. SNDRV_PCM_RATE_192000,
  5098. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5099. .rate_min = 8000,
  5100. .rate_max = 192000,
  5101. },
  5102. .capture = {
  5103. .stream_name = "Tertiary MI2S Capture",
  5104. .aif_name = "TERT_MI2S_TX",
  5105. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5106. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5107. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5108. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5109. SNDRV_PCM_RATE_192000,
  5110. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5111. .rate_min = 8000,
  5112. .rate_max = 192000,
  5113. },
  5114. .ops = &msm_dai_q6_mi2s_ops,
  5115. .name = "Tertiary MI2S",
  5116. .id = MSM_TERT_MI2S,
  5117. .probe = msm_dai_q6_dai_mi2s_probe,
  5118. .remove = msm_dai_q6_dai_mi2s_remove,
  5119. },
  5120. {
  5121. .playback = {
  5122. .stream_name = "Quaternary MI2S Playback",
  5123. .aif_name = "QUAT_MI2S_RX",
  5124. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5125. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5126. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5127. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5128. SNDRV_PCM_RATE_192000,
  5129. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5130. .rate_min = 8000,
  5131. .rate_max = 192000,
  5132. },
  5133. .capture = {
  5134. .stream_name = "Quaternary MI2S Capture",
  5135. .aif_name = "QUAT_MI2S_TX",
  5136. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5137. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5138. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5139. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5140. SNDRV_PCM_RATE_192000,
  5141. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5142. .rate_min = 8000,
  5143. .rate_max = 192000,
  5144. },
  5145. .ops = &msm_dai_q6_mi2s_ops,
  5146. .name = "Quaternary MI2S",
  5147. .id = MSM_QUAT_MI2S,
  5148. .probe = msm_dai_q6_dai_mi2s_probe,
  5149. .remove = msm_dai_q6_dai_mi2s_remove,
  5150. },
  5151. {
  5152. .playback = {
  5153. .stream_name = "Quinary MI2S Playback",
  5154. .aif_name = "QUIN_MI2S_RX",
  5155. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5156. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5157. SNDRV_PCM_RATE_192000,
  5158. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5159. .rate_min = 8000,
  5160. .rate_max = 192000,
  5161. },
  5162. .capture = {
  5163. .stream_name = "Quinary MI2S Capture",
  5164. .aif_name = "QUIN_MI2S_TX",
  5165. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5166. SNDRV_PCM_RATE_16000,
  5167. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5168. .rate_min = 8000,
  5169. .rate_max = 48000,
  5170. },
  5171. .ops = &msm_dai_q6_mi2s_ops,
  5172. .name = "Quinary MI2S",
  5173. .id = MSM_QUIN_MI2S,
  5174. .probe = msm_dai_q6_dai_mi2s_probe,
  5175. .remove = msm_dai_q6_dai_mi2s_remove,
  5176. },
  5177. {
  5178. .playback = {
  5179. .stream_name = "Senary MI2S Playback",
  5180. .aif_name = "SEN_MI2S_RX",
  5181. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5182. SNDRV_PCM_RATE_16000,
  5183. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5184. .rate_min = 8000,
  5185. .rate_max = 48000,
  5186. },
  5187. .capture = {
  5188. .stream_name = "Senary MI2S Capture",
  5189. .aif_name = "SENARY_MI2S_TX",
  5190. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5191. SNDRV_PCM_RATE_16000,
  5192. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5193. .rate_min = 8000,
  5194. .rate_max = 48000,
  5195. },
  5196. .ops = &msm_dai_q6_mi2s_ops,
  5197. .name = "Senary MI2S",
  5198. .id = MSM_SENARY_MI2S,
  5199. .probe = msm_dai_q6_dai_mi2s_probe,
  5200. .remove = msm_dai_q6_dai_mi2s_remove,
  5201. },
  5202. {
  5203. .playback = {
  5204. .stream_name = "Secondary MI2S Playback SD1",
  5205. .aif_name = "SEC_MI2S_RX_SD1",
  5206. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5207. SNDRV_PCM_RATE_16000,
  5208. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5209. .rate_min = 8000,
  5210. .rate_max = 48000,
  5211. },
  5212. .id = MSM_SEC_MI2S_SD1,
  5213. },
  5214. {
  5215. .playback = {
  5216. .stream_name = "INT0 MI2S Playback",
  5217. .aif_name = "INT0_MI2S_RX",
  5218. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5219. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5220. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5221. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5222. SNDRV_PCM_FMTBIT_S24_LE |
  5223. SNDRV_PCM_FMTBIT_S24_3LE,
  5224. .rate_min = 8000,
  5225. .rate_max = 192000,
  5226. },
  5227. .capture = {
  5228. .stream_name = "INT0 MI2S Capture",
  5229. .aif_name = "INT0_MI2S_TX",
  5230. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5231. SNDRV_PCM_RATE_16000,
  5232. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5233. .rate_min = 8000,
  5234. .rate_max = 48000,
  5235. },
  5236. .ops = &msm_dai_q6_mi2s_ops,
  5237. .name = "INT0 MI2S",
  5238. .id = MSM_INT0_MI2S,
  5239. .probe = msm_dai_q6_dai_mi2s_probe,
  5240. .remove = msm_dai_q6_dai_mi2s_remove,
  5241. },
  5242. {
  5243. .playback = {
  5244. .stream_name = "INT1 MI2S Playback",
  5245. .aif_name = "INT1_MI2S_RX",
  5246. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5247. SNDRV_PCM_RATE_16000,
  5248. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5249. SNDRV_PCM_FMTBIT_S24_LE |
  5250. SNDRV_PCM_FMTBIT_S24_3LE,
  5251. .rate_min = 8000,
  5252. .rate_max = 48000,
  5253. },
  5254. .capture = {
  5255. .stream_name = "INT1 MI2S Capture",
  5256. .aif_name = "INT1_MI2S_TX",
  5257. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5258. SNDRV_PCM_RATE_16000,
  5259. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5260. .rate_min = 8000,
  5261. .rate_max = 48000,
  5262. },
  5263. .ops = &msm_dai_q6_mi2s_ops,
  5264. .name = "INT1 MI2S",
  5265. .id = MSM_INT1_MI2S,
  5266. .probe = msm_dai_q6_dai_mi2s_probe,
  5267. .remove = msm_dai_q6_dai_mi2s_remove,
  5268. },
  5269. {
  5270. .playback = {
  5271. .stream_name = "INT2 MI2S Playback",
  5272. .aif_name = "INT2_MI2S_RX",
  5273. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5274. SNDRV_PCM_RATE_16000,
  5275. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5276. SNDRV_PCM_FMTBIT_S24_LE |
  5277. SNDRV_PCM_FMTBIT_S24_3LE,
  5278. .rate_min = 8000,
  5279. .rate_max = 48000,
  5280. },
  5281. .capture = {
  5282. .stream_name = "INT2 MI2S Capture",
  5283. .aif_name = "INT2_MI2S_TX",
  5284. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5285. SNDRV_PCM_RATE_16000,
  5286. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5287. .rate_min = 8000,
  5288. .rate_max = 48000,
  5289. },
  5290. .ops = &msm_dai_q6_mi2s_ops,
  5291. .name = "INT2 MI2S",
  5292. .id = MSM_INT2_MI2S,
  5293. .probe = msm_dai_q6_dai_mi2s_probe,
  5294. .remove = msm_dai_q6_dai_mi2s_remove,
  5295. },
  5296. {
  5297. .playback = {
  5298. .stream_name = "INT3 MI2S Playback",
  5299. .aif_name = "INT3_MI2S_RX",
  5300. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5301. SNDRV_PCM_RATE_16000,
  5302. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5303. SNDRV_PCM_FMTBIT_S24_LE |
  5304. SNDRV_PCM_FMTBIT_S24_3LE,
  5305. .rate_min = 8000,
  5306. .rate_max = 48000,
  5307. },
  5308. .capture = {
  5309. .stream_name = "INT3 MI2S Capture",
  5310. .aif_name = "INT3_MI2S_TX",
  5311. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5312. SNDRV_PCM_RATE_16000,
  5313. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5314. .rate_min = 8000,
  5315. .rate_max = 48000,
  5316. },
  5317. .ops = &msm_dai_q6_mi2s_ops,
  5318. .name = "INT3 MI2S",
  5319. .id = MSM_INT3_MI2S,
  5320. .probe = msm_dai_q6_dai_mi2s_probe,
  5321. .remove = msm_dai_q6_dai_mi2s_remove,
  5322. },
  5323. {
  5324. .playback = {
  5325. .stream_name = "INT4 MI2S Playback",
  5326. .aif_name = "INT4_MI2S_RX",
  5327. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5328. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5329. SNDRV_PCM_RATE_192000,
  5330. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5331. SNDRV_PCM_FMTBIT_S24_LE |
  5332. SNDRV_PCM_FMTBIT_S24_3LE,
  5333. .rate_min = 8000,
  5334. .rate_max = 192000,
  5335. },
  5336. .capture = {
  5337. .stream_name = "INT4 MI2S Capture",
  5338. .aif_name = "INT4_MI2S_TX",
  5339. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5340. SNDRV_PCM_RATE_16000,
  5341. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5342. .rate_min = 8000,
  5343. .rate_max = 48000,
  5344. },
  5345. .ops = &msm_dai_q6_mi2s_ops,
  5346. .name = "INT4 MI2S",
  5347. .id = MSM_INT4_MI2S,
  5348. .probe = msm_dai_q6_dai_mi2s_probe,
  5349. .remove = msm_dai_q6_dai_mi2s_remove,
  5350. },
  5351. {
  5352. .playback = {
  5353. .stream_name = "INT5 MI2S Playback",
  5354. .aif_name = "INT5_MI2S_RX",
  5355. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5356. SNDRV_PCM_RATE_16000,
  5357. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5358. SNDRV_PCM_FMTBIT_S24_LE |
  5359. SNDRV_PCM_FMTBIT_S24_3LE,
  5360. .rate_min = 8000,
  5361. .rate_max = 48000,
  5362. },
  5363. .capture = {
  5364. .stream_name = "INT5 MI2S Capture",
  5365. .aif_name = "INT5_MI2S_TX",
  5366. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5367. SNDRV_PCM_RATE_16000,
  5368. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5369. .rate_min = 8000,
  5370. .rate_max = 48000,
  5371. },
  5372. .ops = &msm_dai_q6_mi2s_ops,
  5373. .name = "INT5 MI2S",
  5374. .id = MSM_INT5_MI2S,
  5375. .probe = msm_dai_q6_dai_mi2s_probe,
  5376. .remove = msm_dai_q6_dai_mi2s_remove,
  5377. },
  5378. {
  5379. .playback = {
  5380. .stream_name = "INT6 MI2S Playback",
  5381. .aif_name = "INT6_MI2S_RX",
  5382. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5383. SNDRV_PCM_RATE_16000,
  5384. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5385. SNDRV_PCM_FMTBIT_S24_LE |
  5386. SNDRV_PCM_FMTBIT_S24_3LE,
  5387. .rate_min = 8000,
  5388. .rate_max = 48000,
  5389. },
  5390. .capture = {
  5391. .stream_name = "INT6 MI2S Capture",
  5392. .aif_name = "INT6_MI2S_TX",
  5393. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5394. SNDRV_PCM_RATE_16000,
  5395. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5396. .rate_min = 8000,
  5397. .rate_max = 48000,
  5398. },
  5399. .ops = &msm_dai_q6_mi2s_ops,
  5400. .name = "INT6 MI2S",
  5401. .id = MSM_INT6_MI2S,
  5402. .probe = msm_dai_q6_dai_mi2s_probe,
  5403. .remove = msm_dai_q6_dai_mi2s_remove,
  5404. },
  5405. };
  5406. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5407. unsigned int *ch_cnt)
  5408. {
  5409. u8 num_of_sd_lines;
  5410. num_of_sd_lines = num_of_bits_set(sd_lines);
  5411. switch (num_of_sd_lines) {
  5412. case 0:
  5413. pr_debug("%s: no line is assigned\n", __func__);
  5414. break;
  5415. case 1:
  5416. switch (sd_lines) {
  5417. case MSM_MI2S_SD0:
  5418. *config_ptr = AFE_PORT_I2S_SD0;
  5419. break;
  5420. case MSM_MI2S_SD1:
  5421. *config_ptr = AFE_PORT_I2S_SD1;
  5422. break;
  5423. case MSM_MI2S_SD2:
  5424. *config_ptr = AFE_PORT_I2S_SD2;
  5425. break;
  5426. case MSM_MI2S_SD3:
  5427. *config_ptr = AFE_PORT_I2S_SD3;
  5428. break;
  5429. case MSM_MI2S_SD4:
  5430. *config_ptr = AFE_PORT_I2S_SD4;
  5431. break;
  5432. case MSM_MI2S_SD5:
  5433. *config_ptr = AFE_PORT_I2S_SD5;
  5434. break;
  5435. case MSM_MI2S_SD6:
  5436. *config_ptr = AFE_PORT_I2S_SD6;
  5437. break;
  5438. case MSM_MI2S_SD7:
  5439. *config_ptr = AFE_PORT_I2S_SD7;
  5440. break;
  5441. default:
  5442. pr_err("%s: invalid SD lines %d\n",
  5443. __func__, sd_lines);
  5444. goto error_invalid_data;
  5445. }
  5446. break;
  5447. case 2:
  5448. switch (sd_lines) {
  5449. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5450. *config_ptr = AFE_PORT_I2S_QUAD01;
  5451. break;
  5452. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5453. *config_ptr = AFE_PORT_I2S_QUAD23;
  5454. break;
  5455. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5456. *config_ptr = AFE_PORT_I2S_QUAD45;
  5457. break;
  5458. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5459. *config_ptr = AFE_PORT_I2S_QUAD67;
  5460. break;
  5461. default:
  5462. pr_err("%s: invalid SD lines %d\n",
  5463. __func__, sd_lines);
  5464. goto error_invalid_data;
  5465. }
  5466. break;
  5467. case 3:
  5468. switch (sd_lines) {
  5469. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5470. *config_ptr = AFE_PORT_I2S_6CHS;
  5471. break;
  5472. default:
  5473. pr_err("%s: invalid SD lines %d\n",
  5474. __func__, sd_lines);
  5475. goto error_invalid_data;
  5476. }
  5477. break;
  5478. case 4:
  5479. switch (sd_lines) {
  5480. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5481. *config_ptr = AFE_PORT_I2S_8CHS;
  5482. break;
  5483. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5484. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5485. break;
  5486. default:
  5487. pr_err("%s: invalid SD lines %d\n",
  5488. __func__, sd_lines);
  5489. goto error_invalid_data;
  5490. }
  5491. break;
  5492. case 5:
  5493. switch (sd_lines) {
  5494. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5495. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5496. *config_ptr = AFE_PORT_I2S_10CHS;
  5497. break;
  5498. default:
  5499. pr_err("%s: invalid SD lines %d\n",
  5500. __func__, sd_lines);
  5501. goto error_invalid_data;
  5502. }
  5503. break;
  5504. case 6:
  5505. switch (sd_lines) {
  5506. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5507. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5508. *config_ptr = AFE_PORT_I2S_12CHS;
  5509. break;
  5510. default:
  5511. pr_err("%s: invalid SD lines %d\n",
  5512. __func__, sd_lines);
  5513. goto error_invalid_data;
  5514. }
  5515. break;
  5516. case 7:
  5517. switch (sd_lines) {
  5518. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5519. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  5520. *config_ptr = AFE_PORT_I2S_14CHS;
  5521. break;
  5522. default:
  5523. pr_err("%s: invalid SD lines %d\n",
  5524. __func__, sd_lines);
  5525. goto error_invalid_data;
  5526. }
  5527. break;
  5528. case 8:
  5529. switch (sd_lines) {
  5530. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5531. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5532. *config_ptr = AFE_PORT_I2S_16CHS;
  5533. break;
  5534. default:
  5535. pr_err("%s: invalid SD lines %d\n",
  5536. __func__, sd_lines);
  5537. goto error_invalid_data;
  5538. }
  5539. break;
  5540. default:
  5541. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  5542. goto error_invalid_data;
  5543. }
  5544. *ch_cnt = num_of_sd_lines;
  5545. return 0;
  5546. error_invalid_data:
  5547. pr_err("%s: invalid data\n", __func__);
  5548. return -EINVAL;
  5549. }
  5550. static int msm_dai_q6_mi2s_platform_data_validation(
  5551. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  5552. {
  5553. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  5554. struct msm_mi2s_pdata *mi2s_pdata =
  5555. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  5556. unsigned int ch_cnt;
  5557. int rc = 0;
  5558. u16 sd_line;
  5559. if (mi2s_pdata == NULL) {
  5560. pr_err("%s: mi2s_pdata NULL", __func__);
  5561. return -EINVAL;
  5562. }
  5563. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  5564. &sd_line, &ch_cnt);
  5565. if (rc < 0) {
  5566. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  5567. goto rtn;
  5568. }
  5569. if (ch_cnt) {
  5570. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5571. sd_line;
  5572. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  5573. dai_driver->playback.channels_min = 1;
  5574. dai_driver->playback.channels_max = ch_cnt << 1;
  5575. } else {
  5576. dai_driver->playback.channels_min = 0;
  5577. dai_driver->playback.channels_max = 0;
  5578. }
  5579. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  5580. &sd_line, &ch_cnt);
  5581. if (rc < 0) {
  5582. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  5583. goto rtn;
  5584. }
  5585. if (ch_cnt) {
  5586. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5587. sd_line;
  5588. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  5589. dai_driver->capture.channels_min = 1;
  5590. dai_driver->capture.channels_max = ch_cnt << 1;
  5591. } else {
  5592. dai_driver->capture.channels_min = 0;
  5593. dai_driver->capture.channels_max = 0;
  5594. }
  5595. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  5596. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  5597. dai_data->tx_dai.pdata_mi2s_lines);
  5598. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  5599. __func__, dai_driver->playback.channels_max,
  5600. dai_driver->capture.channels_max);
  5601. rtn:
  5602. return rc;
  5603. }
  5604. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  5605. .name = "msm-dai-q6-mi2s",
  5606. };
  5607. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  5608. {
  5609. struct msm_dai_q6_mi2s_dai_data *dai_data;
  5610. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  5611. u32 tx_line = 0;
  5612. u32 rx_line = 0;
  5613. u32 mi2s_intf = 0;
  5614. struct msm_mi2s_pdata *mi2s_pdata;
  5615. int rc;
  5616. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  5617. &mi2s_intf);
  5618. if (rc) {
  5619. dev_err(&pdev->dev,
  5620. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  5621. goto rtn;
  5622. }
  5623. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  5624. mi2s_intf);
  5625. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  5626. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  5627. dev_err(&pdev->dev,
  5628. "%s: Invalid MI2S ID %u from Device Tree\n",
  5629. __func__, mi2s_intf);
  5630. rc = -ENXIO;
  5631. goto rtn;
  5632. }
  5633. pdev->id = mi2s_intf;
  5634. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  5635. if (!mi2s_pdata) {
  5636. rc = -ENOMEM;
  5637. goto rtn;
  5638. }
  5639. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  5640. &rx_line);
  5641. if (rc) {
  5642. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  5643. "qcom,msm-mi2s-rx-lines");
  5644. goto free_pdata;
  5645. }
  5646. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  5647. &tx_line);
  5648. if (rc) {
  5649. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  5650. "qcom,msm-mi2s-tx-lines");
  5651. goto free_pdata;
  5652. }
  5653. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  5654. dev_name(&pdev->dev), rx_line, tx_line);
  5655. mi2s_pdata->rx_sd_lines = rx_line;
  5656. mi2s_pdata->tx_sd_lines = tx_line;
  5657. mi2s_pdata->intf_id = mi2s_intf;
  5658. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  5659. GFP_KERNEL);
  5660. if (!dai_data) {
  5661. rc = -ENOMEM;
  5662. goto free_pdata;
  5663. } else
  5664. dev_set_drvdata(&pdev->dev, dai_data);
  5665. rc = of_property_read_u32(pdev->dev.of_node,
  5666. "qcom,msm-dai-is-island-supported",
  5667. &dai_data->is_island_dai);
  5668. if (rc)
  5669. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5670. pdev->dev.platform_data = mi2s_pdata;
  5671. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  5672. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  5673. if (rc < 0)
  5674. goto free_dai_data;
  5675. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  5676. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  5677. if (rc < 0)
  5678. goto err_register;
  5679. return 0;
  5680. err_register:
  5681. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  5682. free_dai_data:
  5683. kfree(dai_data);
  5684. free_pdata:
  5685. kfree(mi2s_pdata);
  5686. rtn:
  5687. return rc;
  5688. }
  5689. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  5690. {
  5691. snd_soc_unregister_component(&pdev->dev);
  5692. return 0;
  5693. }
  5694. static const struct snd_soc_component_driver msm_dai_q6_component = {
  5695. .name = "msm-dai-q6-dev",
  5696. };
  5697. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  5698. {
  5699. int rc, id, i, len;
  5700. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  5701. char stream_name[80];
  5702. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  5703. if (rc) {
  5704. dev_err(&pdev->dev,
  5705. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  5706. return rc;
  5707. }
  5708. pdev->id = id;
  5709. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5710. dev_name(&pdev->dev), pdev->id);
  5711. switch (id) {
  5712. case SLIMBUS_0_RX:
  5713. strlcpy(stream_name, "Slimbus Playback", 80);
  5714. goto register_slim_playback;
  5715. case SLIMBUS_2_RX:
  5716. strlcpy(stream_name, "Slimbus2 Playback", 80);
  5717. goto register_slim_playback;
  5718. case SLIMBUS_1_RX:
  5719. strlcpy(stream_name, "Slimbus1 Playback", 80);
  5720. goto register_slim_playback;
  5721. case SLIMBUS_3_RX:
  5722. strlcpy(stream_name, "Slimbus3 Playback", 80);
  5723. goto register_slim_playback;
  5724. case SLIMBUS_4_RX:
  5725. strlcpy(stream_name, "Slimbus4 Playback", 80);
  5726. goto register_slim_playback;
  5727. case SLIMBUS_5_RX:
  5728. strlcpy(stream_name, "Slimbus5 Playback", 80);
  5729. goto register_slim_playback;
  5730. case SLIMBUS_6_RX:
  5731. strlcpy(stream_name, "Slimbus6 Playback", 80);
  5732. goto register_slim_playback;
  5733. case SLIMBUS_7_RX:
  5734. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  5735. goto register_slim_playback;
  5736. case SLIMBUS_8_RX:
  5737. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  5738. goto register_slim_playback;
  5739. case SLIMBUS_9_RX:
  5740. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  5741. goto register_slim_playback;
  5742. register_slim_playback:
  5743. rc = -ENODEV;
  5744. len = strnlen(stream_name, 80);
  5745. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  5746. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  5747. !strcmp(stream_name,
  5748. msm_dai_q6_slimbus_rx_dai[i]
  5749. .playback.stream_name)) {
  5750. rc = snd_soc_register_component(&pdev->dev,
  5751. &msm_dai_q6_component,
  5752. &msm_dai_q6_slimbus_rx_dai[i], 1);
  5753. break;
  5754. }
  5755. }
  5756. if (rc)
  5757. pr_err("%s: Device not found stream name %s\n",
  5758. __func__, stream_name);
  5759. break;
  5760. case SLIMBUS_0_TX:
  5761. strlcpy(stream_name, "Slimbus Capture", 80);
  5762. goto register_slim_capture;
  5763. case SLIMBUS_1_TX:
  5764. strlcpy(stream_name, "Slimbus1 Capture", 80);
  5765. goto register_slim_capture;
  5766. case SLIMBUS_2_TX:
  5767. strlcpy(stream_name, "Slimbus2 Capture", 80);
  5768. goto register_slim_capture;
  5769. case SLIMBUS_3_TX:
  5770. strlcpy(stream_name, "Slimbus3 Capture", 80);
  5771. goto register_slim_capture;
  5772. case SLIMBUS_4_TX:
  5773. strlcpy(stream_name, "Slimbus4 Capture", 80);
  5774. goto register_slim_capture;
  5775. case SLIMBUS_5_TX:
  5776. strlcpy(stream_name, "Slimbus5 Capture", 80);
  5777. goto register_slim_capture;
  5778. case SLIMBUS_6_TX:
  5779. strlcpy(stream_name, "Slimbus6 Capture", 80);
  5780. goto register_slim_capture;
  5781. case SLIMBUS_7_TX:
  5782. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  5783. goto register_slim_capture;
  5784. case SLIMBUS_8_TX:
  5785. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  5786. goto register_slim_capture;
  5787. case SLIMBUS_9_TX:
  5788. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  5789. goto register_slim_capture;
  5790. register_slim_capture:
  5791. rc = -ENODEV;
  5792. len = strnlen(stream_name, 80);
  5793. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  5794. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  5795. !strcmp(stream_name,
  5796. msm_dai_q6_slimbus_tx_dai[i]
  5797. .capture.stream_name)) {
  5798. rc = snd_soc_register_component(&pdev->dev,
  5799. &msm_dai_q6_component,
  5800. &msm_dai_q6_slimbus_tx_dai[i], 1);
  5801. break;
  5802. }
  5803. }
  5804. if (rc)
  5805. pr_err("%s: Device not found stream name %s\n",
  5806. __func__, stream_name);
  5807. break;
  5808. case AFE_LOOPBACK_TX:
  5809. rc = snd_soc_register_component(&pdev->dev,
  5810. &msm_dai_q6_component,
  5811. &msm_dai_q6_afe_lb_tx_dai[0],
  5812. 1);
  5813. break;
  5814. case INT_BT_SCO_RX:
  5815. rc = snd_soc_register_component(&pdev->dev,
  5816. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  5817. break;
  5818. case INT_BT_SCO_TX:
  5819. rc = snd_soc_register_component(&pdev->dev,
  5820. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  5821. break;
  5822. case INT_BT_A2DP_RX:
  5823. rc = snd_soc_register_component(&pdev->dev,
  5824. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  5825. break;
  5826. case INT_FM_RX:
  5827. rc = snd_soc_register_component(&pdev->dev,
  5828. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  5829. break;
  5830. case INT_FM_TX:
  5831. rc = snd_soc_register_component(&pdev->dev,
  5832. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  5833. break;
  5834. case AFE_PORT_ID_USB_RX:
  5835. rc = snd_soc_register_component(&pdev->dev,
  5836. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  5837. break;
  5838. case AFE_PORT_ID_USB_TX:
  5839. rc = snd_soc_register_component(&pdev->dev,
  5840. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  5841. break;
  5842. case RT_PROXY_DAI_001_RX:
  5843. strlcpy(stream_name, "AFE Playback", 80);
  5844. goto register_afe_playback;
  5845. case RT_PROXY_DAI_002_RX:
  5846. strlcpy(stream_name, "AFE-PROXY RX", 80);
  5847. register_afe_playback:
  5848. rc = -ENODEV;
  5849. len = strnlen(stream_name, 80);
  5850. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  5851. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  5852. !strcmp(stream_name,
  5853. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  5854. rc = snd_soc_register_component(&pdev->dev,
  5855. &msm_dai_q6_component,
  5856. &msm_dai_q6_afe_rx_dai[i], 1);
  5857. break;
  5858. }
  5859. }
  5860. if (rc)
  5861. pr_err("%s: Device not found stream name %s\n",
  5862. __func__, stream_name);
  5863. break;
  5864. case RT_PROXY_DAI_001_TX:
  5865. strlcpy(stream_name, "AFE-PROXY TX", 80);
  5866. goto register_afe_capture;
  5867. case RT_PROXY_DAI_002_TX:
  5868. strlcpy(stream_name, "AFE Capture", 80);
  5869. register_afe_capture:
  5870. rc = -ENODEV;
  5871. len = strnlen(stream_name, 80);
  5872. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  5873. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  5874. !strcmp(stream_name,
  5875. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  5876. rc = snd_soc_register_component(&pdev->dev,
  5877. &msm_dai_q6_component,
  5878. &msm_dai_q6_afe_tx_dai[i], 1);
  5879. break;
  5880. }
  5881. }
  5882. if (rc)
  5883. pr_err("%s: Device not found stream name %s\n",
  5884. __func__, stream_name);
  5885. break;
  5886. case VOICE_PLAYBACK_TX:
  5887. strlcpy(stream_name, "Voice Farend Playback", 80);
  5888. goto register_voice_playback;
  5889. case VOICE2_PLAYBACK_TX:
  5890. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  5891. register_voice_playback:
  5892. rc = -ENODEV;
  5893. len = strnlen(stream_name, 80);
  5894. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  5895. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  5896. && !strcmp(stream_name,
  5897. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  5898. rc = snd_soc_register_component(&pdev->dev,
  5899. &msm_dai_q6_component,
  5900. &msm_dai_q6_voc_playback_dai[i], 1);
  5901. break;
  5902. }
  5903. }
  5904. if (rc)
  5905. pr_err("%s Device not found stream name %s\n",
  5906. __func__, stream_name);
  5907. break;
  5908. case VOICE_RECORD_RX:
  5909. strlcpy(stream_name, "Voice Downlink Capture", 80);
  5910. goto register_uplink_capture;
  5911. case VOICE_RECORD_TX:
  5912. strlcpy(stream_name, "Voice Uplink Capture", 80);
  5913. register_uplink_capture:
  5914. rc = -ENODEV;
  5915. len = strnlen(stream_name, 80);
  5916. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  5917. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  5918. && !strcmp(stream_name,
  5919. msm_dai_q6_incall_record_dai[i].
  5920. capture.stream_name)) {
  5921. rc = snd_soc_register_component(&pdev->dev,
  5922. &msm_dai_q6_component,
  5923. &msm_dai_q6_incall_record_dai[i], 1);
  5924. break;
  5925. }
  5926. }
  5927. if (rc)
  5928. pr_err("%s: Device not found stream name %s\n",
  5929. __func__, stream_name);
  5930. break;
  5931. default:
  5932. rc = -ENODEV;
  5933. break;
  5934. }
  5935. return rc;
  5936. }
  5937. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  5938. {
  5939. snd_soc_unregister_component(&pdev->dev);
  5940. return 0;
  5941. }
  5942. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  5943. { .compatible = "qcom,msm-dai-q6-dev", },
  5944. { }
  5945. };
  5946. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  5947. static struct platform_driver msm_dai_q6_dev = {
  5948. .probe = msm_dai_q6_dev_probe,
  5949. .remove = msm_dai_q6_dev_remove,
  5950. .driver = {
  5951. .name = "msm-dai-q6-dev",
  5952. .owner = THIS_MODULE,
  5953. .of_match_table = msm_dai_q6_dev_dt_match,
  5954. .suppress_bind_attrs = true,
  5955. },
  5956. };
  5957. static int msm_dai_q6_probe(struct platform_device *pdev)
  5958. {
  5959. int rc;
  5960. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5961. dev_name(&pdev->dev), pdev->id);
  5962. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5963. if (rc) {
  5964. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5965. __func__, rc);
  5966. } else
  5967. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5968. return rc;
  5969. }
  5970. static int msm_dai_q6_remove(struct platform_device *pdev)
  5971. {
  5972. of_platform_depopulate(&pdev->dev);
  5973. return 0;
  5974. }
  5975. static const struct of_device_id msm_dai_q6_dt_match[] = {
  5976. { .compatible = "qcom,msm-dai-q6", },
  5977. { }
  5978. };
  5979. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  5980. static struct platform_driver msm_dai_q6 = {
  5981. .probe = msm_dai_q6_probe,
  5982. .remove = msm_dai_q6_remove,
  5983. .driver = {
  5984. .name = "msm-dai-q6",
  5985. .owner = THIS_MODULE,
  5986. .of_match_table = msm_dai_q6_dt_match,
  5987. .suppress_bind_attrs = true,
  5988. },
  5989. };
  5990. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  5991. {
  5992. int rc;
  5993. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5994. if (rc) {
  5995. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5996. __func__, rc);
  5997. } else
  5998. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5999. return rc;
  6000. }
  6001. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  6002. {
  6003. return 0;
  6004. }
  6005. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  6006. { .compatible = "qcom,msm-dai-mi2s", },
  6007. { }
  6008. };
  6009. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  6010. static struct platform_driver msm_dai_mi2s_q6 = {
  6011. .probe = msm_dai_mi2s_q6_probe,
  6012. .remove = msm_dai_mi2s_q6_remove,
  6013. .driver = {
  6014. .name = "msm-dai-mi2s",
  6015. .owner = THIS_MODULE,
  6016. .of_match_table = msm_dai_mi2s_dt_match,
  6017. .suppress_bind_attrs = true,
  6018. },
  6019. };
  6020. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  6021. { .compatible = "qcom,msm-dai-q6-mi2s", },
  6022. { }
  6023. };
  6024. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  6025. static struct platform_driver msm_dai_q6_mi2s_driver = {
  6026. .probe = msm_dai_q6_mi2s_dev_probe,
  6027. .remove = msm_dai_q6_mi2s_dev_remove,
  6028. .driver = {
  6029. .name = "msm-dai-q6-mi2s",
  6030. .owner = THIS_MODULE,
  6031. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  6032. .suppress_bind_attrs = true,
  6033. },
  6034. };
  6035. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  6036. {
  6037. int rc, id;
  6038. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6039. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6040. if (rc) {
  6041. dev_err(&pdev->dev,
  6042. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6043. return rc;
  6044. }
  6045. pdev->id = id;
  6046. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6047. dev_name(&pdev->dev), pdev->id);
  6048. switch (pdev->id) {
  6049. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  6050. rc = snd_soc_register_component(&pdev->dev,
  6051. &msm_dai_spdif_q6_component,
  6052. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  6053. break;
  6054. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  6055. rc = snd_soc_register_component(&pdev->dev,
  6056. &msm_dai_spdif_q6_component,
  6057. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  6058. break;
  6059. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  6060. rc = snd_soc_register_component(&pdev->dev,
  6061. &msm_dai_spdif_q6_component,
  6062. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  6063. break;
  6064. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  6065. rc = snd_soc_register_component(&pdev->dev,
  6066. &msm_dai_spdif_q6_component,
  6067. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  6068. break;
  6069. default:
  6070. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  6071. rc = -ENODEV;
  6072. break;
  6073. }
  6074. return rc;
  6075. }
  6076. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  6077. {
  6078. snd_soc_unregister_component(&pdev->dev);
  6079. return 0;
  6080. }
  6081. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  6082. {.compatible = "qcom,msm-dai-q6-spdif"},
  6083. {}
  6084. };
  6085. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  6086. static struct platform_driver msm_dai_q6_spdif_driver = {
  6087. .probe = msm_dai_q6_spdif_dev_probe,
  6088. .remove = msm_dai_q6_spdif_dev_remove,
  6089. .driver = {
  6090. .name = "msm-dai-q6-spdif",
  6091. .owner = THIS_MODULE,
  6092. .of_match_table = msm_dai_q6_spdif_dt_match,
  6093. .suppress_bind_attrs = true,
  6094. },
  6095. };
  6096. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  6097. struct afe_clk_set *clk_set, u32 mode)
  6098. {
  6099. switch (group_id) {
  6100. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  6101. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  6102. if (mode)
  6103. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  6104. else
  6105. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  6106. break;
  6107. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  6108. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  6109. if (mode)
  6110. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  6111. else
  6112. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  6113. break;
  6114. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  6115. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  6116. if (mode)
  6117. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  6118. else
  6119. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  6120. break;
  6121. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  6122. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  6123. if (mode)
  6124. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  6125. else
  6126. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  6127. break;
  6128. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  6129. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  6130. if (mode)
  6131. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  6132. else
  6133. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  6134. break;
  6135. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  6136. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  6137. if (mode)
  6138. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  6139. else
  6140. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  6141. break;
  6142. default:
  6143. return -EINVAL;
  6144. }
  6145. return 0;
  6146. }
  6147. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  6148. {
  6149. int rc = 0;
  6150. const uint32_t *port_id_array = NULL;
  6151. uint32_t array_length = 0;
  6152. int i = 0;
  6153. int group_idx = 0;
  6154. u32 clk_mode = 0;
  6155. /* extract tdm group info into static */
  6156. rc = of_property_read_u32(pdev->dev.of_node,
  6157. "qcom,msm-cpudai-tdm-group-id",
  6158. (u32 *)&tdm_group_cfg.group_id);
  6159. if (rc) {
  6160. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  6161. __func__, "qcom,msm-cpudai-tdm-group-id");
  6162. goto rtn;
  6163. }
  6164. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  6165. __func__, tdm_group_cfg.group_id);
  6166. rc = of_property_read_u32(pdev->dev.of_node,
  6167. "qcom,msm-cpudai-tdm-group-num-ports",
  6168. &num_tdm_group_ports);
  6169. if (rc) {
  6170. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  6171. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  6172. goto rtn;
  6173. }
  6174. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  6175. __func__, num_tdm_group_ports);
  6176. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  6177. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  6178. __func__, num_tdm_group_ports,
  6179. AFE_GROUP_DEVICE_NUM_PORTS);
  6180. rc = -EINVAL;
  6181. goto rtn;
  6182. }
  6183. port_id_array = of_get_property(pdev->dev.of_node,
  6184. "qcom,msm-cpudai-tdm-group-port-id",
  6185. &array_length);
  6186. if (port_id_array == NULL) {
  6187. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  6188. __func__);
  6189. rc = -EINVAL;
  6190. goto rtn;
  6191. }
  6192. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  6193. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  6194. __func__, array_length,
  6195. sizeof(uint32_t) * num_tdm_group_ports);
  6196. rc = -EINVAL;
  6197. goto rtn;
  6198. }
  6199. for (i = 0; i < num_tdm_group_ports; i++)
  6200. tdm_group_cfg.port_id[i] =
  6201. (u16)be32_to_cpu(port_id_array[i]);
  6202. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  6203. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  6204. tdm_group_cfg.port_id[i] =
  6205. AFE_PORT_INVALID;
  6206. /* extract tdm clk info into static */
  6207. rc = of_property_read_u32(pdev->dev.of_node,
  6208. "qcom,msm-cpudai-tdm-clk-rate",
  6209. &tdm_clk_set.clk_freq_in_hz);
  6210. if (rc) {
  6211. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  6212. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  6213. goto rtn;
  6214. }
  6215. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  6216. __func__, tdm_clk_set.clk_freq_in_hz);
  6217. /* initialize static tdm clk attribute to default value */
  6218. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  6219. /* extract tdm clk attribute into static */
  6220. if (of_find_property(pdev->dev.of_node,
  6221. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  6222. rc = of_property_read_u16(pdev->dev.of_node,
  6223. "qcom,msm-cpudai-tdm-clk-attribute",
  6224. &tdm_clk_set.clk_attri);
  6225. if (rc) {
  6226. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  6227. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  6228. goto rtn;
  6229. }
  6230. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  6231. __func__, tdm_clk_set.clk_attri);
  6232. } else
  6233. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  6234. /* extract tdm lane cfg to static */
  6235. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  6236. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  6237. if (of_find_property(pdev->dev.of_node,
  6238. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  6239. rc = of_property_read_u16(pdev->dev.of_node,
  6240. "qcom,msm-cpudai-tdm-lane-mask",
  6241. &tdm_lane_cfg.lane_mask);
  6242. if (rc) {
  6243. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  6244. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  6245. goto rtn;
  6246. }
  6247. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  6248. __func__, tdm_lane_cfg.lane_mask);
  6249. } else
  6250. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  6251. /* extract tdm clk src master/slave info into static */
  6252. rc = of_property_read_u32(pdev->dev.of_node,
  6253. "qcom,msm-cpudai-tdm-clk-internal",
  6254. &clk_mode);
  6255. if (rc) {
  6256. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  6257. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  6258. goto rtn;
  6259. }
  6260. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  6261. __func__, clk_mode);
  6262. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  6263. &tdm_clk_set, clk_mode);
  6264. if (rc) {
  6265. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  6266. __func__, tdm_group_cfg.group_id);
  6267. goto rtn;
  6268. }
  6269. /* other initializations within device group */
  6270. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  6271. if (group_idx < 0) {
  6272. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  6273. __func__, tdm_group_cfg.group_id);
  6274. rc = -EINVAL;
  6275. goto rtn;
  6276. }
  6277. atomic_set(&tdm_group_ref[group_idx], 0);
  6278. /* probe child node info */
  6279. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6280. if (rc) {
  6281. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6282. __func__, rc);
  6283. goto rtn;
  6284. } else
  6285. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6286. rtn:
  6287. return rc;
  6288. }
  6289. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  6290. {
  6291. return 0;
  6292. }
  6293. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  6294. { .compatible = "qcom,msm-dai-tdm", },
  6295. {}
  6296. };
  6297. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  6298. static struct platform_driver msm_dai_tdm_q6 = {
  6299. .probe = msm_dai_tdm_q6_probe,
  6300. .remove = msm_dai_tdm_q6_remove,
  6301. .driver = {
  6302. .name = "msm-dai-tdm",
  6303. .owner = THIS_MODULE,
  6304. .of_match_table = msm_dai_tdm_dt_match,
  6305. .suppress_bind_attrs = true,
  6306. },
  6307. };
  6308. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  6309. struct snd_ctl_elem_value *ucontrol)
  6310. {
  6311. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6312. int value = ucontrol->value.integer.value[0];
  6313. switch (value) {
  6314. case 0:
  6315. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  6316. break;
  6317. case 1:
  6318. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  6319. break;
  6320. case 2:
  6321. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  6322. break;
  6323. default:
  6324. pr_err("%s: data_format invalid\n", __func__);
  6325. break;
  6326. }
  6327. pr_debug("%s: data_format = %d\n",
  6328. __func__, dai_data->port_cfg.tdm.data_format);
  6329. return 0;
  6330. }
  6331. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  6332. struct snd_ctl_elem_value *ucontrol)
  6333. {
  6334. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6335. ucontrol->value.integer.value[0] =
  6336. dai_data->port_cfg.tdm.data_format;
  6337. pr_debug("%s: data_format = %d\n",
  6338. __func__, dai_data->port_cfg.tdm.data_format);
  6339. return 0;
  6340. }
  6341. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  6342. struct snd_ctl_elem_value *ucontrol)
  6343. {
  6344. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6345. int value = ucontrol->value.integer.value[0];
  6346. dai_data->port_cfg.custom_tdm_header.header_type = value;
  6347. pr_debug("%s: header_type = %d\n",
  6348. __func__,
  6349. dai_data->port_cfg.custom_tdm_header.header_type);
  6350. return 0;
  6351. }
  6352. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  6353. struct snd_ctl_elem_value *ucontrol)
  6354. {
  6355. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6356. ucontrol->value.integer.value[0] =
  6357. dai_data->port_cfg.custom_tdm_header.header_type;
  6358. pr_debug("%s: header_type = %d\n",
  6359. __func__,
  6360. dai_data->port_cfg.custom_tdm_header.header_type);
  6361. return 0;
  6362. }
  6363. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  6364. struct snd_ctl_elem_value *ucontrol)
  6365. {
  6366. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6367. int i = 0;
  6368. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  6369. dai_data->port_cfg.custom_tdm_header.header[i] =
  6370. (u16)ucontrol->value.integer.value[i];
  6371. pr_debug("%s: header #%d = 0x%x\n",
  6372. __func__, i,
  6373. dai_data->port_cfg.custom_tdm_header.header[i]);
  6374. }
  6375. return 0;
  6376. }
  6377. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  6378. struct snd_ctl_elem_value *ucontrol)
  6379. {
  6380. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6381. int i = 0;
  6382. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  6383. ucontrol->value.integer.value[i] =
  6384. dai_data->port_cfg.custom_tdm_header.header[i];
  6385. pr_debug("%s: header #%d = 0x%x\n",
  6386. __func__, i,
  6387. dai_data->port_cfg.custom_tdm_header.header[i]);
  6388. }
  6389. return 0;
  6390. }
  6391. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  6392. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  6393. msm_dai_q6_tdm_data_format_get,
  6394. msm_dai_q6_tdm_data_format_put),
  6395. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  6396. msm_dai_q6_tdm_data_format_get,
  6397. msm_dai_q6_tdm_data_format_put),
  6398. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  6399. msm_dai_q6_tdm_data_format_get,
  6400. msm_dai_q6_tdm_data_format_put),
  6401. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  6402. msm_dai_q6_tdm_data_format_get,
  6403. msm_dai_q6_tdm_data_format_put),
  6404. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  6405. msm_dai_q6_tdm_data_format_get,
  6406. msm_dai_q6_tdm_data_format_put),
  6407. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  6408. msm_dai_q6_tdm_data_format_get,
  6409. msm_dai_q6_tdm_data_format_put),
  6410. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  6411. msm_dai_q6_tdm_data_format_get,
  6412. msm_dai_q6_tdm_data_format_put),
  6413. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  6414. msm_dai_q6_tdm_data_format_get,
  6415. msm_dai_q6_tdm_data_format_put),
  6416. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  6417. msm_dai_q6_tdm_data_format_get,
  6418. msm_dai_q6_tdm_data_format_put),
  6419. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  6420. msm_dai_q6_tdm_data_format_get,
  6421. msm_dai_q6_tdm_data_format_put),
  6422. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  6423. msm_dai_q6_tdm_data_format_get,
  6424. msm_dai_q6_tdm_data_format_put),
  6425. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  6426. msm_dai_q6_tdm_data_format_get,
  6427. msm_dai_q6_tdm_data_format_put),
  6428. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  6429. msm_dai_q6_tdm_data_format_get,
  6430. msm_dai_q6_tdm_data_format_put),
  6431. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  6432. msm_dai_q6_tdm_data_format_get,
  6433. msm_dai_q6_tdm_data_format_put),
  6434. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  6435. msm_dai_q6_tdm_data_format_get,
  6436. msm_dai_q6_tdm_data_format_put),
  6437. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  6438. msm_dai_q6_tdm_data_format_get,
  6439. msm_dai_q6_tdm_data_format_put),
  6440. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  6441. msm_dai_q6_tdm_data_format_get,
  6442. msm_dai_q6_tdm_data_format_put),
  6443. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  6444. msm_dai_q6_tdm_data_format_get,
  6445. msm_dai_q6_tdm_data_format_put),
  6446. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  6447. msm_dai_q6_tdm_data_format_get,
  6448. msm_dai_q6_tdm_data_format_put),
  6449. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  6450. msm_dai_q6_tdm_data_format_get,
  6451. msm_dai_q6_tdm_data_format_put),
  6452. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  6453. msm_dai_q6_tdm_data_format_get,
  6454. msm_dai_q6_tdm_data_format_put),
  6455. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  6456. msm_dai_q6_tdm_data_format_get,
  6457. msm_dai_q6_tdm_data_format_put),
  6458. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  6459. msm_dai_q6_tdm_data_format_get,
  6460. msm_dai_q6_tdm_data_format_put),
  6461. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  6462. msm_dai_q6_tdm_data_format_get,
  6463. msm_dai_q6_tdm_data_format_put),
  6464. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  6465. msm_dai_q6_tdm_data_format_get,
  6466. msm_dai_q6_tdm_data_format_put),
  6467. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  6468. msm_dai_q6_tdm_data_format_get,
  6469. msm_dai_q6_tdm_data_format_put),
  6470. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  6471. msm_dai_q6_tdm_data_format_get,
  6472. msm_dai_q6_tdm_data_format_put),
  6473. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  6474. msm_dai_q6_tdm_data_format_get,
  6475. msm_dai_q6_tdm_data_format_put),
  6476. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  6477. msm_dai_q6_tdm_data_format_get,
  6478. msm_dai_q6_tdm_data_format_put),
  6479. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  6480. msm_dai_q6_tdm_data_format_get,
  6481. msm_dai_q6_tdm_data_format_put),
  6482. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  6483. msm_dai_q6_tdm_data_format_get,
  6484. msm_dai_q6_tdm_data_format_put),
  6485. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  6486. msm_dai_q6_tdm_data_format_get,
  6487. msm_dai_q6_tdm_data_format_put),
  6488. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  6489. msm_dai_q6_tdm_data_format_get,
  6490. msm_dai_q6_tdm_data_format_put),
  6491. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  6492. msm_dai_q6_tdm_data_format_get,
  6493. msm_dai_q6_tdm_data_format_put),
  6494. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  6495. msm_dai_q6_tdm_data_format_get,
  6496. msm_dai_q6_tdm_data_format_put),
  6497. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  6498. msm_dai_q6_tdm_data_format_get,
  6499. msm_dai_q6_tdm_data_format_put),
  6500. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  6501. msm_dai_q6_tdm_data_format_get,
  6502. msm_dai_q6_tdm_data_format_put),
  6503. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  6504. msm_dai_q6_tdm_data_format_get,
  6505. msm_dai_q6_tdm_data_format_put),
  6506. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  6507. msm_dai_q6_tdm_data_format_get,
  6508. msm_dai_q6_tdm_data_format_put),
  6509. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  6510. msm_dai_q6_tdm_data_format_get,
  6511. msm_dai_q6_tdm_data_format_put),
  6512. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  6513. msm_dai_q6_tdm_data_format_get,
  6514. msm_dai_q6_tdm_data_format_put),
  6515. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  6516. msm_dai_q6_tdm_data_format_get,
  6517. msm_dai_q6_tdm_data_format_put),
  6518. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  6519. msm_dai_q6_tdm_data_format_get,
  6520. msm_dai_q6_tdm_data_format_put),
  6521. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  6522. msm_dai_q6_tdm_data_format_get,
  6523. msm_dai_q6_tdm_data_format_put),
  6524. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  6525. msm_dai_q6_tdm_data_format_get,
  6526. msm_dai_q6_tdm_data_format_put),
  6527. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  6528. msm_dai_q6_tdm_data_format_get,
  6529. msm_dai_q6_tdm_data_format_put),
  6530. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  6531. msm_dai_q6_tdm_data_format_get,
  6532. msm_dai_q6_tdm_data_format_put),
  6533. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  6534. msm_dai_q6_tdm_data_format_get,
  6535. msm_dai_q6_tdm_data_format_put),
  6536. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  6537. msm_dai_q6_tdm_data_format_get,
  6538. msm_dai_q6_tdm_data_format_put),
  6539. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  6540. msm_dai_q6_tdm_data_format_get,
  6541. msm_dai_q6_tdm_data_format_put),
  6542. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  6543. msm_dai_q6_tdm_data_format_get,
  6544. msm_dai_q6_tdm_data_format_put),
  6545. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  6546. msm_dai_q6_tdm_data_format_get,
  6547. msm_dai_q6_tdm_data_format_put),
  6548. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  6549. msm_dai_q6_tdm_data_format_get,
  6550. msm_dai_q6_tdm_data_format_put),
  6551. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  6552. msm_dai_q6_tdm_data_format_get,
  6553. msm_dai_q6_tdm_data_format_put),
  6554. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  6555. msm_dai_q6_tdm_data_format_get,
  6556. msm_dai_q6_tdm_data_format_put),
  6557. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  6558. msm_dai_q6_tdm_data_format_get,
  6559. msm_dai_q6_tdm_data_format_put),
  6560. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  6561. msm_dai_q6_tdm_data_format_get,
  6562. msm_dai_q6_tdm_data_format_put),
  6563. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  6564. msm_dai_q6_tdm_data_format_get,
  6565. msm_dai_q6_tdm_data_format_put),
  6566. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  6567. msm_dai_q6_tdm_data_format_get,
  6568. msm_dai_q6_tdm_data_format_put),
  6569. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  6570. msm_dai_q6_tdm_data_format_get,
  6571. msm_dai_q6_tdm_data_format_put),
  6572. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  6573. msm_dai_q6_tdm_data_format_get,
  6574. msm_dai_q6_tdm_data_format_put),
  6575. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  6576. msm_dai_q6_tdm_data_format_get,
  6577. msm_dai_q6_tdm_data_format_put),
  6578. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  6579. msm_dai_q6_tdm_data_format_get,
  6580. msm_dai_q6_tdm_data_format_put),
  6581. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  6582. msm_dai_q6_tdm_data_format_get,
  6583. msm_dai_q6_tdm_data_format_put),
  6584. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  6585. msm_dai_q6_tdm_data_format_get,
  6586. msm_dai_q6_tdm_data_format_put),
  6587. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  6588. msm_dai_q6_tdm_data_format_get,
  6589. msm_dai_q6_tdm_data_format_put),
  6590. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  6591. msm_dai_q6_tdm_data_format_get,
  6592. msm_dai_q6_tdm_data_format_put),
  6593. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  6594. msm_dai_q6_tdm_data_format_get,
  6595. msm_dai_q6_tdm_data_format_put),
  6596. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  6597. msm_dai_q6_tdm_data_format_get,
  6598. msm_dai_q6_tdm_data_format_put),
  6599. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  6600. msm_dai_q6_tdm_data_format_get,
  6601. msm_dai_q6_tdm_data_format_put),
  6602. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  6603. msm_dai_q6_tdm_data_format_get,
  6604. msm_dai_q6_tdm_data_format_put),
  6605. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  6606. msm_dai_q6_tdm_data_format_get,
  6607. msm_dai_q6_tdm_data_format_put),
  6608. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  6609. msm_dai_q6_tdm_data_format_get,
  6610. msm_dai_q6_tdm_data_format_put),
  6611. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  6612. msm_dai_q6_tdm_data_format_get,
  6613. msm_dai_q6_tdm_data_format_put),
  6614. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  6615. msm_dai_q6_tdm_data_format_get,
  6616. msm_dai_q6_tdm_data_format_put),
  6617. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  6618. msm_dai_q6_tdm_data_format_get,
  6619. msm_dai_q6_tdm_data_format_put),
  6620. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  6621. msm_dai_q6_tdm_data_format_get,
  6622. msm_dai_q6_tdm_data_format_put),
  6623. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  6624. msm_dai_q6_tdm_data_format_get,
  6625. msm_dai_q6_tdm_data_format_put),
  6626. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  6627. msm_dai_q6_tdm_data_format_get,
  6628. msm_dai_q6_tdm_data_format_put),
  6629. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  6630. msm_dai_q6_tdm_data_format_get,
  6631. msm_dai_q6_tdm_data_format_put),
  6632. SOC_ENUM_EXT("SEN_TDM_RX_0 Data Format", tdm_config_enum[0],
  6633. msm_dai_q6_tdm_data_format_get,
  6634. msm_dai_q6_tdm_data_format_put),
  6635. SOC_ENUM_EXT("SEN_TDM_RX_1 Data Format", tdm_config_enum[0],
  6636. msm_dai_q6_tdm_data_format_get,
  6637. msm_dai_q6_tdm_data_format_put),
  6638. SOC_ENUM_EXT("SEN_TDM_RX_2 Data Format", tdm_config_enum[0],
  6639. msm_dai_q6_tdm_data_format_get,
  6640. msm_dai_q6_tdm_data_format_put),
  6641. SOC_ENUM_EXT("SEN_TDM_RX_3 Data Format", tdm_config_enum[0],
  6642. msm_dai_q6_tdm_data_format_get,
  6643. msm_dai_q6_tdm_data_format_put),
  6644. SOC_ENUM_EXT("SEN_TDM_RX_4 Data Format", tdm_config_enum[0],
  6645. msm_dai_q6_tdm_data_format_get,
  6646. msm_dai_q6_tdm_data_format_put),
  6647. SOC_ENUM_EXT("SEN_TDM_RX_5 Data Format", tdm_config_enum[0],
  6648. msm_dai_q6_tdm_data_format_get,
  6649. msm_dai_q6_tdm_data_format_put),
  6650. SOC_ENUM_EXT("SEN_TDM_RX_6 Data Format", tdm_config_enum[0],
  6651. msm_dai_q6_tdm_data_format_get,
  6652. msm_dai_q6_tdm_data_format_put),
  6653. SOC_ENUM_EXT("SEN_TDM_RX_7 Data Format", tdm_config_enum[0],
  6654. msm_dai_q6_tdm_data_format_get,
  6655. msm_dai_q6_tdm_data_format_put),
  6656. SOC_ENUM_EXT("SEN_TDM_TX_0 Data Format", tdm_config_enum[0],
  6657. msm_dai_q6_tdm_data_format_get,
  6658. msm_dai_q6_tdm_data_format_put),
  6659. SOC_ENUM_EXT("SEN_TDM_TX_1 Data Format", tdm_config_enum[0],
  6660. msm_dai_q6_tdm_data_format_get,
  6661. msm_dai_q6_tdm_data_format_put),
  6662. SOC_ENUM_EXT("SEN_TDM_TX_2 Data Format", tdm_config_enum[0],
  6663. msm_dai_q6_tdm_data_format_get,
  6664. msm_dai_q6_tdm_data_format_put),
  6665. SOC_ENUM_EXT("SEN_TDM_TX_3 Data Format", tdm_config_enum[0],
  6666. msm_dai_q6_tdm_data_format_get,
  6667. msm_dai_q6_tdm_data_format_put),
  6668. SOC_ENUM_EXT("SEN_TDM_TX_4 Data Format", tdm_config_enum[0],
  6669. msm_dai_q6_tdm_data_format_get,
  6670. msm_dai_q6_tdm_data_format_put),
  6671. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  6672. msm_dai_q6_tdm_data_format_get,
  6673. msm_dai_q6_tdm_data_format_put),
  6674. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  6675. msm_dai_q6_tdm_data_format_get,
  6676. msm_dai_q6_tdm_data_format_put),
  6677. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  6678. msm_dai_q6_tdm_data_format_get,
  6679. msm_dai_q6_tdm_data_format_put),
  6680. };
  6681. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  6682. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  6683. msm_dai_q6_tdm_header_type_get,
  6684. msm_dai_q6_tdm_header_type_put),
  6685. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  6686. msm_dai_q6_tdm_header_type_get,
  6687. msm_dai_q6_tdm_header_type_put),
  6688. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  6689. msm_dai_q6_tdm_header_type_get,
  6690. msm_dai_q6_tdm_header_type_put),
  6691. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  6692. msm_dai_q6_tdm_header_type_get,
  6693. msm_dai_q6_tdm_header_type_put),
  6694. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  6695. msm_dai_q6_tdm_header_type_get,
  6696. msm_dai_q6_tdm_header_type_put),
  6697. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  6698. msm_dai_q6_tdm_header_type_get,
  6699. msm_dai_q6_tdm_header_type_put),
  6700. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  6701. msm_dai_q6_tdm_header_type_get,
  6702. msm_dai_q6_tdm_header_type_put),
  6703. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  6704. msm_dai_q6_tdm_header_type_get,
  6705. msm_dai_q6_tdm_header_type_put),
  6706. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  6707. msm_dai_q6_tdm_header_type_get,
  6708. msm_dai_q6_tdm_header_type_put),
  6709. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  6710. msm_dai_q6_tdm_header_type_get,
  6711. msm_dai_q6_tdm_header_type_put),
  6712. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  6713. msm_dai_q6_tdm_header_type_get,
  6714. msm_dai_q6_tdm_header_type_put),
  6715. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  6716. msm_dai_q6_tdm_header_type_get,
  6717. msm_dai_q6_tdm_header_type_put),
  6718. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  6719. msm_dai_q6_tdm_header_type_get,
  6720. msm_dai_q6_tdm_header_type_put),
  6721. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  6722. msm_dai_q6_tdm_header_type_get,
  6723. msm_dai_q6_tdm_header_type_put),
  6724. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  6725. msm_dai_q6_tdm_header_type_get,
  6726. msm_dai_q6_tdm_header_type_put),
  6727. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  6728. msm_dai_q6_tdm_header_type_get,
  6729. msm_dai_q6_tdm_header_type_put),
  6730. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  6731. msm_dai_q6_tdm_header_type_get,
  6732. msm_dai_q6_tdm_header_type_put),
  6733. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  6734. msm_dai_q6_tdm_header_type_get,
  6735. msm_dai_q6_tdm_header_type_put),
  6736. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  6737. msm_dai_q6_tdm_header_type_get,
  6738. msm_dai_q6_tdm_header_type_put),
  6739. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  6740. msm_dai_q6_tdm_header_type_get,
  6741. msm_dai_q6_tdm_header_type_put),
  6742. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  6743. msm_dai_q6_tdm_header_type_get,
  6744. msm_dai_q6_tdm_header_type_put),
  6745. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  6746. msm_dai_q6_tdm_header_type_get,
  6747. msm_dai_q6_tdm_header_type_put),
  6748. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  6749. msm_dai_q6_tdm_header_type_get,
  6750. msm_dai_q6_tdm_header_type_put),
  6751. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  6752. msm_dai_q6_tdm_header_type_get,
  6753. msm_dai_q6_tdm_header_type_put),
  6754. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  6755. msm_dai_q6_tdm_header_type_get,
  6756. msm_dai_q6_tdm_header_type_put),
  6757. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  6758. msm_dai_q6_tdm_header_type_get,
  6759. msm_dai_q6_tdm_header_type_put),
  6760. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  6761. msm_dai_q6_tdm_header_type_get,
  6762. msm_dai_q6_tdm_header_type_put),
  6763. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  6764. msm_dai_q6_tdm_header_type_get,
  6765. msm_dai_q6_tdm_header_type_put),
  6766. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  6767. msm_dai_q6_tdm_header_type_get,
  6768. msm_dai_q6_tdm_header_type_put),
  6769. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  6770. msm_dai_q6_tdm_header_type_get,
  6771. msm_dai_q6_tdm_header_type_put),
  6772. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  6773. msm_dai_q6_tdm_header_type_get,
  6774. msm_dai_q6_tdm_header_type_put),
  6775. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  6776. msm_dai_q6_tdm_header_type_get,
  6777. msm_dai_q6_tdm_header_type_put),
  6778. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  6779. msm_dai_q6_tdm_header_type_get,
  6780. msm_dai_q6_tdm_header_type_put),
  6781. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  6782. msm_dai_q6_tdm_header_type_get,
  6783. msm_dai_q6_tdm_header_type_put),
  6784. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  6785. msm_dai_q6_tdm_header_type_get,
  6786. msm_dai_q6_tdm_header_type_put),
  6787. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  6788. msm_dai_q6_tdm_header_type_get,
  6789. msm_dai_q6_tdm_header_type_put),
  6790. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  6791. msm_dai_q6_tdm_header_type_get,
  6792. msm_dai_q6_tdm_header_type_put),
  6793. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  6794. msm_dai_q6_tdm_header_type_get,
  6795. msm_dai_q6_tdm_header_type_put),
  6796. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  6797. msm_dai_q6_tdm_header_type_get,
  6798. msm_dai_q6_tdm_header_type_put),
  6799. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  6800. msm_dai_q6_tdm_header_type_get,
  6801. msm_dai_q6_tdm_header_type_put),
  6802. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  6803. msm_dai_q6_tdm_header_type_get,
  6804. msm_dai_q6_tdm_header_type_put),
  6805. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  6806. msm_dai_q6_tdm_header_type_get,
  6807. msm_dai_q6_tdm_header_type_put),
  6808. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  6809. msm_dai_q6_tdm_header_type_get,
  6810. msm_dai_q6_tdm_header_type_put),
  6811. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  6812. msm_dai_q6_tdm_header_type_get,
  6813. msm_dai_q6_tdm_header_type_put),
  6814. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  6815. msm_dai_q6_tdm_header_type_get,
  6816. msm_dai_q6_tdm_header_type_put),
  6817. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  6818. msm_dai_q6_tdm_header_type_get,
  6819. msm_dai_q6_tdm_header_type_put),
  6820. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  6821. msm_dai_q6_tdm_header_type_get,
  6822. msm_dai_q6_tdm_header_type_put),
  6823. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6824. msm_dai_q6_tdm_header_type_get,
  6825. msm_dai_q6_tdm_header_type_put),
  6826. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  6827. msm_dai_q6_tdm_header_type_get,
  6828. msm_dai_q6_tdm_header_type_put),
  6829. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  6830. msm_dai_q6_tdm_header_type_get,
  6831. msm_dai_q6_tdm_header_type_put),
  6832. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  6833. msm_dai_q6_tdm_header_type_get,
  6834. msm_dai_q6_tdm_header_type_put),
  6835. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  6836. msm_dai_q6_tdm_header_type_get,
  6837. msm_dai_q6_tdm_header_type_put),
  6838. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  6839. msm_dai_q6_tdm_header_type_get,
  6840. msm_dai_q6_tdm_header_type_put),
  6841. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  6842. msm_dai_q6_tdm_header_type_get,
  6843. msm_dai_q6_tdm_header_type_put),
  6844. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  6845. msm_dai_q6_tdm_header_type_get,
  6846. msm_dai_q6_tdm_header_type_put),
  6847. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  6848. msm_dai_q6_tdm_header_type_get,
  6849. msm_dai_q6_tdm_header_type_put),
  6850. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  6851. msm_dai_q6_tdm_header_type_get,
  6852. msm_dai_q6_tdm_header_type_put),
  6853. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  6854. msm_dai_q6_tdm_header_type_get,
  6855. msm_dai_q6_tdm_header_type_put),
  6856. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  6857. msm_dai_q6_tdm_header_type_get,
  6858. msm_dai_q6_tdm_header_type_put),
  6859. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  6860. msm_dai_q6_tdm_header_type_get,
  6861. msm_dai_q6_tdm_header_type_put),
  6862. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  6863. msm_dai_q6_tdm_header_type_get,
  6864. msm_dai_q6_tdm_header_type_put),
  6865. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  6866. msm_dai_q6_tdm_header_type_get,
  6867. msm_dai_q6_tdm_header_type_put),
  6868. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  6869. msm_dai_q6_tdm_header_type_get,
  6870. msm_dai_q6_tdm_header_type_put),
  6871. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6872. msm_dai_q6_tdm_header_type_get,
  6873. msm_dai_q6_tdm_header_type_put),
  6874. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  6875. msm_dai_q6_tdm_header_type_get,
  6876. msm_dai_q6_tdm_header_type_put),
  6877. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  6878. msm_dai_q6_tdm_header_type_get,
  6879. msm_dai_q6_tdm_header_type_put),
  6880. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  6881. msm_dai_q6_tdm_header_type_get,
  6882. msm_dai_q6_tdm_header_type_put),
  6883. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  6884. msm_dai_q6_tdm_header_type_get,
  6885. msm_dai_q6_tdm_header_type_put),
  6886. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  6887. msm_dai_q6_tdm_header_type_get,
  6888. msm_dai_q6_tdm_header_type_put),
  6889. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  6890. msm_dai_q6_tdm_header_type_get,
  6891. msm_dai_q6_tdm_header_type_put),
  6892. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  6893. msm_dai_q6_tdm_header_type_get,
  6894. msm_dai_q6_tdm_header_type_put),
  6895. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  6896. msm_dai_q6_tdm_header_type_get,
  6897. msm_dai_q6_tdm_header_type_put),
  6898. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  6899. msm_dai_q6_tdm_header_type_get,
  6900. msm_dai_q6_tdm_header_type_put),
  6901. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  6902. msm_dai_q6_tdm_header_type_get,
  6903. msm_dai_q6_tdm_header_type_put),
  6904. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  6905. msm_dai_q6_tdm_header_type_get,
  6906. msm_dai_q6_tdm_header_type_put),
  6907. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  6908. msm_dai_q6_tdm_header_type_get,
  6909. msm_dai_q6_tdm_header_type_put),
  6910. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  6911. msm_dai_q6_tdm_header_type_get,
  6912. msm_dai_q6_tdm_header_type_put),
  6913. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  6914. msm_dai_q6_tdm_header_type_get,
  6915. msm_dai_q6_tdm_header_type_put),
  6916. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  6917. msm_dai_q6_tdm_header_type_get,
  6918. msm_dai_q6_tdm_header_type_put),
  6919. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  6920. msm_dai_q6_tdm_header_type_get,
  6921. msm_dai_q6_tdm_header_type_put),
  6922. SOC_ENUM_EXT("SEN_TDM_RX_0 Header Type", tdm_config_enum[1],
  6923. msm_dai_q6_tdm_header_type_get,
  6924. msm_dai_q6_tdm_header_type_put),
  6925. SOC_ENUM_EXT("SEN_TDM_RX_1 Header Type", tdm_config_enum[1],
  6926. msm_dai_q6_tdm_header_type_get,
  6927. msm_dai_q6_tdm_header_type_put),
  6928. SOC_ENUM_EXT("SEN_TDM_RX_2 Header Type", tdm_config_enum[1],
  6929. msm_dai_q6_tdm_header_type_get,
  6930. msm_dai_q6_tdm_header_type_put),
  6931. SOC_ENUM_EXT("SEN_TDM_RX_3 Header Type", tdm_config_enum[1],
  6932. msm_dai_q6_tdm_header_type_get,
  6933. msm_dai_q6_tdm_header_type_put),
  6934. SOC_ENUM_EXT("SEN_TDM_RX_4 Header Type", tdm_config_enum[1],
  6935. msm_dai_q6_tdm_header_type_get,
  6936. msm_dai_q6_tdm_header_type_put),
  6937. SOC_ENUM_EXT("SEN_TDM_RX_5 Header Type", tdm_config_enum[1],
  6938. msm_dai_q6_tdm_header_type_get,
  6939. msm_dai_q6_tdm_header_type_put),
  6940. SOC_ENUM_EXT("SEN_TDM_RX_6 Header Type", tdm_config_enum[1],
  6941. msm_dai_q6_tdm_header_type_get,
  6942. msm_dai_q6_tdm_header_type_put),
  6943. SOC_ENUM_EXT("SEN_TDM_RX_7 Header Type", tdm_config_enum[1],
  6944. msm_dai_q6_tdm_header_type_get,
  6945. msm_dai_q6_tdm_header_type_put),
  6946. SOC_ENUM_EXT("SEN_TDM_TX_0 Header Type", tdm_config_enum[1],
  6947. msm_dai_q6_tdm_header_type_get,
  6948. msm_dai_q6_tdm_header_type_put),
  6949. SOC_ENUM_EXT("SEN_TDM_TX_1 Header Type", tdm_config_enum[1],
  6950. msm_dai_q6_tdm_header_type_get,
  6951. msm_dai_q6_tdm_header_type_put),
  6952. SOC_ENUM_EXT("SEN_TDM_TX_2 Header Type", tdm_config_enum[1],
  6953. msm_dai_q6_tdm_header_type_get,
  6954. msm_dai_q6_tdm_header_type_put),
  6955. SOC_ENUM_EXT("SEN_TDM_TX_3 Header Type", tdm_config_enum[1],
  6956. msm_dai_q6_tdm_header_type_get,
  6957. msm_dai_q6_tdm_header_type_put),
  6958. SOC_ENUM_EXT("SEN_TDM_TX_4 Header Type", tdm_config_enum[1],
  6959. msm_dai_q6_tdm_header_type_get,
  6960. msm_dai_q6_tdm_header_type_put),
  6961. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  6962. msm_dai_q6_tdm_header_type_get,
  6963. msm_dai_q6_tdm_header_type_put),
  6964. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  6965. msm_dai_q6_tdm_header_type_get,
  6966. msm_dai_q6_tdm_header_type_put),
  6967. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  6968. msm_dai_q6_tdm_header_type_get,
  6969. msm_dai_q6_tdm_header_type_put),
  6970. };
  6971. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  6972. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  6973. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6974. msm_dai_q6_tdm_header_get,
  6975. msm_dai_q6_tdm_header_put),
  6976. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  6977. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6978. msm_dai_q6_tdm_header_get,
  6979. msm_dai_q6_tdm_header_put),
  6980. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  6981. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6982. msm_dai_q6_tdm_header_get,
  6983. msm_dai_q6_tdm_header_put),
  6984. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  6985. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6986. msm_dai_q6_tdm_header_get,
  6987. msm_dai_q6_tdm_header_put),
  6988. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  6989. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6990. msm_dai_q6_tdm_header_get,
  6991. msm_dai_q6_tdm_header_put),
  6992. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  6993. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6994. msm_dai_q6_tdm_header_get,
  6995. msm_dai_q6_tdm_header_put),
  6996. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  6997. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6998. msm_dai_q6_tdm_header_get,
  6999. msm_dai_q6_tdm_header_put),
  7000. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  7001. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7002. msm_dai_q6_tdm_header_get,
  7003. msm_dai_q6_tdm_header_put),
  7004. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  7005. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7006. msm_dai_q6_tdm_header_get,
  7007. msm_dai_q6_tdm_header_put),
  7008. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  7009. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7010. msm_dai_q6_tdm_header_get,
  7011. msm_dai_q6_tdm_header_put),
  7012. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  7013. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7014. msm_dai_q6_tdm_header_get,
  7015. msm_dai_q6_tdm_header_put),
  7016. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  7017. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7018. msm_dai_q6_tdm_header_get,
  7019. msm_dai_q6_tdm_header_put),
  7020. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  7021. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7022. msm_dai_q6_tdm_header_get,
  7023. msm_dai_q6_tdm_header_put),
  7024. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  7025. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7026. msm_dai_q6_tdm_header_get,
  7027. msm_dai_q6_tdm_header_put),
  7028. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  7029. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7030. msm_dai_q6_tdm_header_get,
  7031. msm_dai_q6_tdm_header_put),
  7032. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  7033. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7034. msm_dai_q6_tdm_header_get,
  7035. msm_dai_q6_tdm_header_put),
  7036. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  7037. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7038. msm_dai_q6_tdm_header_get,
  7039. msm_dai_q6_tdm_header_put),
  7040. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  7041. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7042. msm_dai_q6_tdm_header_get,
  7043. msm_dai_q6_tdm_header_put),
  7044. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  7045. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7046. msm_dai_q6_tdm_header_get,
  7047. msm_dai_q6_tdm_header_put),
  7048. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  7049. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7050. msm_dai_q6_tdm_header_get,
  7051. msm_dai_q6_tdm_header_put),
  7052. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  7053. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7054. msm_dai_q6_tdm_header_get,
  7055. msm_dai_q6_tdm_header_put),
  7056. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  7057. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7058. msm_dai_q6_tdm_header_get,
  7059. msm_dai_q6_tdm_header_put),
  7060. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  7061. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7062. msm_dai_q6_tdm_header_get,
  7063. msm_dai_q6_tdm_header_put),
  7064. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  7065. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7066. msm_dai_q6_tdm_header_get,
  7067. msm_dai_q6_tdm_header_put),
  7068. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  7069. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7070. msm_dai_q6_tdm_header_get,
  7071. msm_dai_q6_tdm_header_put),
  7072. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  7073. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7074. msm_dai_q6_tdm_header_get,
  7075. msm_dai_q6_tdm_header_put),
  7076. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  7077. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7078. msm_dai_q6_tdm_header_get,
  7079. msm_dai_q6_tdm_header_put),
  7080. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  7081. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7082. msm_dai_q6_tdm_header_get,
  7083. msm_dai_q6_tdm_header_put),
  7084. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  7085. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7086. msm_dai_q6_tdm_header_get,
  7087. msm_dai_q6_tdm_header_put),
  7088. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  7089. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7090. msm_dai_q6_tdm_header_get,
  7091. msm_dai_q6_tdm_header_put),
  7092. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  7093. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7094. msm_dai_q6_tdm_header_get,
  7095. msm_dai_q6_tdm_header_put),
  7096. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  7097. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7098. msm_dai_q6_tdm_header_get,
  7099. msm_dai_q6_tdm_header_put),
  7100. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  7101. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7102. msm_dai_q6_tdm_header_get,
  7103. msm_dai_q6_tdm_header_put),
  7104. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  7105. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7106. msm_dai_q6_tdm_header_get,
  7107. msm_dai_q6_tdm_header_put),
  7108. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  7109. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7110. msm_dai_q6_tdm_header_get,
  7111. msm_dai_q6_tdm_header_put),
  7112. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  7113. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7114. msm_dai_q6_tdm_header_get,
  7115. msm_dai_q6_tdm_header_put),
  7116. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  7117. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7118. msm_dai_q6_tdm_header_get,
  7119. msm_dai_q6_tdm_header_put),
  7120. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  7121. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7122. msm_dai_q6_tdm_header_get,
  7123. msm_dai_q6_tdm_header_put),
  7124. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  7125. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7126. msm_dai_q6_tdm_header_get,
  7127. msm_dai_q6_tdm_header_put),
  7128. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  7129. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7130. msm_dai_q6_tdm_header_get,
  7131. msm_dai_q6_tdm_header_put),
  7132. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  7133. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7134. msm_dai_q6_tdm_header_get,
  7135. msm_dai_q6_tdm_header_put),
  7136. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  7137. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7138. msm_dai_q6_tdm_header_get,
  7139. msm_dai_q6_tdm_header_put),
  7140. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  7141. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7142. msm_dai_q6_tdm_header_get,
  7143. msm_dai_q6_tdm_header_put),
  7144. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  7145. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7146. msm_dai_q6_tdm_header_get,
  7147. msm_dai_q6_tdm_header_put),
  7148. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  7149. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7150. msm_dai_q6_tdm_header_get,
  7151. msm_dai_q6_tdm_header_put),
  7152. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  7153. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7154. msm_dai_q6_tdm_header_get,
  7155. msm_dai_q6_tdm_header_put),
  7156. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  7157. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7158. msm_dai_q6_tdm_header_get,
  7159. msm_dai_q6_tdm_header_put),
  7160. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  7161. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7162. msm_dai_q6_tdm_header_get,
  7163. msm_dai_q6_tdm_header_put),
  7164. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  7165. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7166. msm_dai_q6_tdm_header_get,
  7167. msm_dai_q6_tdm_header_put),
  7168. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  7169. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7170. msm_dai_q6_tdm_header_get,
  7171. msm_dai_q6_tdm_header_put),
  7172. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  7173. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7174. msm_dai_q6_tdm_header_get,
  7175. msm_dai_q6_tdm_header_put),
  7176. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  7177. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7178. msm_dai_q6_tdm_header_get,
  7179. msm_dai_q6_tdm_header_put),
  7180. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  7181. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7182. msm_dai_q6_tdm_header_get,
  7183. msm_dai_q6_tdm_header_put),
  7184. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  7185. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7186. msm_dai_q6_tdm_header_get,
  7187. msm_dai_q6_tdm_header_put),
  7188. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  7189. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7190. msm_dai_q6_tdm_header_get,
  7191. msm_dai_q6_tdm_header_put),
  7192. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  7193. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7194. msm_dai_q6_tdm_header_get,
  7195. msm_dai_q6_tdm_header_put),
  7196. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  7197. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7198. msm_dai_q6_tdm_header_get,
  7199. msm_dai_q6_tdm_header_put),
  7200. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  7201. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7202. msm_dai_q6_tdm_header_get,
  7203. msm_dai_q6_tdm_header_put),
  7204. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  7205. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7206. msm_dai_q6_tdm_header_get,
  7207. msm_dai_q6_tdm_header_put),
  7208. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  7209. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7210. msm_dai_q6_tdm_header_get,
  7211. msm_dai_q6_tdm_header_put),
  7212. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  7213. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7214. msm_dai_q6_tdm_header_get,
  7215. msm_dai_q6_tdm_header_put),
  7216. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  7217. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7218. msm_dai_q6_tdm_header_get,
  7219. msm_dai_q6_tdm_header_put),
  7220. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  7221. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7222. msm_dai_q6_tdm_header_get,
  7223. msm_dai_q6_tdm_header_put),
  7224. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  7225. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7226. msm_dai_q6_tdm_header_get,
  7227. msm_dai_q6_tdm_header_put),
  7228. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  7229. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7230. msm_dai_q6_tdm_header_get,
  7231. msm_dai_q6_tdm_header_put),
  7232. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  7233. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7234. msm_dai_q6_tdm_header_get,
  7235. msm_dai_q6_tdm_header_put),
  7236. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  7237. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7238. msm_dai_q6_tdm_header_get,
  7239. msm_dai_q6_tdm_header_put),
  7240. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  7241. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7242. msm_dai_q6_tdm_header_get,
  7243. msm_dai_q6_tdm_header_put),
  7244. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  7245. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7246. msm_dai_q6_tdm_header_get,
  7247. msm_dai_q6_tdm_header_put),
  7248. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  7249. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7250. msm_dai_q6_tdm_header_get,
  7251. msm_dai_q6_tdm_header_put),
  7252. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  7253. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7254. msm_dai_q6_tdm_header_get,
  7255. msm_dai_q6_tdm_header_put),
  7256. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  7257. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7258. msm_dai_q6_tdm_header_get,
  7259. msm_dai_q6_tdm_header_put),
  7260. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  7261. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7262. msm_dai_q6_tdm_header_get,
  7263. msm_dai_q6_tdm_header_put),
  7264. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  7265. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7266. msm_dai_q6_tdm_header_get,
  7267. msm_dai_q6_tdm_header_put),
  7268. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  7269. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7270. msm_dai_q6_tdm_header_get,
  7271. msm_dai_q6_tdm_header_put),
  7272. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  7273. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7274. msm_dai_q6_tdm_header_get,
  7275. msm_dai_q6_tdm_header_put),
  7276. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  7277. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7278. msm_dai_q6_tdm_header_get,
  7279. msm_dai_q6_tdm_header_put),
  7280. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  7281. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7282. msm_dai_q6_tdm_header_get,
  7283. msm_dai_q6_tdm_header_put),
  7284. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  7285. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7286. msm_dai_q6_tdm_header_get,
  7287. msm_dai_q6_tdm_header_put),
  7288. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  7289. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7290. msm_dai_q6_tdm_header_get,
  7291. msm_dai_q6_tdm_header_put),
  7292. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_0 Header",
  7293. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7294. msm_dai_q6_tdm_header_get,
  7295. msm_dai_q6_tdm_header_put),
  7296. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_1 Header",
  7297. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7298. msm_dai_q6_tdm_header_get,
  7299. msm_dai_q6_tdm_header_put),
  7300. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_2 Header",
  7301. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7302. msm_dai_q6_tdm_header_get,
  7303. msm_dai_q6_tdm_header_put),
  7304. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_3 Header",
  7305. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7306. msm_dai_q6_tdm_header_get,
  7307. msm_dai_q6_tdm_header_put),
  7308. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_4 Header",
  7309. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7310. msm_dai_q6_tdm_header_get,
  7311. msm_dai_q6_tdm_header_put),
  7312. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_5 Header",
  7313. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7314. msm_dai_q6_tdm_header_get,
  7315. msm_dai_q6_tdm_header_put),
  7316. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_6 Header",
  7317. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7318. msm_dai_q6_tdm_header_get,
  7319. msm_dai_q6_tdm_header_put),
  7320. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_7 Header",
  7321. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7322. msm_dai_q6_tdm_header_get,
  7323. msm_dai_q6_tdm_header_put),
  7324. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_0 Header",
  7325. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7326. msm_dai_q6_tdm_header_get,
  7327. msm_dai_q6_tdm_header_put),
  7328. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_1 Header",
  7329. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7330. msm_dai_q6_tdm_header_get,
  7331. msm_dai_q6_tdm_header_put),
  7332. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_2 Header",
  7333. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7334. msm_dai_q6_tdm_header_get,
  7335. msm_dai_q6_tdm_header_put),
  7336. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_3 Header",
  7337. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7338. msm_dai_q6_tdm_header_get,
  7339. msm_dai_q6_tdm_header_put),
  7340. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_4 Header",
  7341. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7342. msm_dai_q6_tdm_header_get,
  7343. msm_dai_q6_tdm_header_put),
  7344. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_5 Header",
  7345. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7346. msm_dai_q6_tdm_header_get,
  7347. msm_dai_q6_tdm_header_put),
  7348. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_6 Header",
  7349. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7350. msm_dai_q6_tdm_header_get,
  7351. msm_dai_q6_tdm_header_put),
  7352. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_7 Header",
  7353. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7354. msm_dai_q6_tdm_header_get,
  7355. msm_dai_q6_tdm_header_put),
  7356. };
  7357. static int msm_dai_q6_tdm_set_clk(
  7358. struct msm_dai_q6_tdm_dai_data *dai_data,
  7359. u16 port_id, bool enable)
  7360. {
  7361. int rc = 0;
  7362. dai_data->clk_set.enable = enable;
  7363. rc = afe_set_lpass_clock_v2(port_id,
  7364. &dai_data->clk_set);
  7365. if (rc < 0)
  7366. pr_err("%s: afe lpass clock failed, err:%d\n",
  7367. __func__, rc);
  7368. return rc;
  7369. }
  7370. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  7371. {
  7372. int rc = 0;
  7373. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  7374. struct snd_kcontrol *data_format_kcontrol = NULL;
  7375. struct snd_kcontrol *header_type_kcontrol = NULL;
  7376. struct snd_kcontrol *header_kcontrol = NULL;
  7377. int port_idx = 0;
  7378. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  7379. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  7380. const struct snd_kcontrol_new *header_ctrl = NULL;
  7381. tdm_dai_data = dev_get_drvdata(dai->dev);
  7382. msm_dai_q6_set_dai_id(dai);
  7383. port_idx = msm_dai_q6_get_port_idx(dai->id);
  7384. if (port_idx < 0) {
  7385. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7386. __func__, dai->id);
  7387. rc = -EINVAL;
  7388. goto rtn;
  7389. }
  7390. data_format_ctrl =
  7391. &tdm_config_controls_data_format[port_idx];
  7392. header_type_ctrl =
  7393. &tdm_config_controls_header_type[port_idx];
  7394. header_ctrl =
  7395. &tdm_config_controls_header[port_idx];
  7396. if (data_format_ctrl) {
  7397. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  7398. tdm_dai_data);
  7399. rc = snd_ctl_add(dai->component->card->snd_card,
  7400. data_format_kcontrol);
  7401. if (rc < 0) {
  7402. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  7403. __func__, dai->name);
  7404. goto rtn;
  7405. }
  7406. }
  7407. if (header_type_ctrl) {
  7408. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  7409. tdm_dai_data);
  7410. rc = snd_ctl_add(dai->component->card->snd_card,
  7411. header_type_kcontrol);
  7412. if (rc < 0) {
  7413. if (data_format_kcontrol)
  7414. snd_ctl_remove(dai->component->card->snd_card,
  7415. data_format_kcontrol);
  7416. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  7417. __func__, dai->name);
  7418. goto rtn;
  7419. }
  7420. }
  7421. if (header_ctrl) {
  7422. header_kcontrol = snd_ctl_new1(header_ctrl,
  7423. tdm_dai_data);
  7424. rc = snd_ctl_add(dai->component->card->snd_card,
  7425. header_kcontrol);
  7426. if (rc < 0) {
  7427. if (header_type_kcontrol)
  7428. snd_ctl_remove(dai->component->card->snd_card,
  7429. header_type_kcontrol);
  7430. if (data_format_kcontrol)
  7431. snd_ctl_remove(dai->component->card->snd_card,
  7432. data_format_kcontrol);
  7433. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  7434. __func__, dai->name);
  7435. goto rtn;
  7436. }
  7437. }
  7438. if (tdm_dai_data->is_island_dai)
  7439. rc = msm_dai_q6_add_island_mx_ctls(
  7440. dai->component->card->snd_card,
  7441. dai->name,
  7442. dai->id, (void *)tdm_dai_data);
  7443. rc = msm_dai_q6_dai_add_route(dai);
  7444. rtn:
  7445. return rc;
  7446. }
  7447. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  7448. {
  7449. int rc = 0;
  7450. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  7451. dev_get_drvdata(dai->dev);
  7452. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  7453. int group_idx = 0;
  7454. atomic_t *group_ref = NULL;
  7455. group_idx = msm_dai_q6_get_group_idx(dai->id);
  7456. if (group_idx < 0) {
  7457. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7458. __func__, dai->id);
  7459. return -EINVAL;
  7460. }
  7461. group_ref = &tdm_group_ref[group_idx];
  7462. /* If AFE port is still up, close it */
  7463. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  7464. rc = afe_close(dai->id); /* can block */
  7465. if (rc < 0) {
  7466. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  7467. __func__, dai->id);
  7468. }
  7469. atomic_dec(group_ref);
  7470. clear_bit(STATUS_PORT_STARTED,
  7471. tdm_dai_data->status_mask);
  7472. if (atomic_read(group_ref) == 0) {
  7473. rc = afe_port_group_enable(group_id,
  7474. NULL, false, NULL);
  7475. if (rc < 0) {
  7476. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  7477. group_id);
  7478. }
  7479. }
  7480. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  7481. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  7482. dai->id, false);
  7483. if (rc < 0) {
  7484. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  7485. __func__, dai->id);
  7486. }
  7487. }
  7488. }
  7489. return 0;
  7490. }
  7491. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  7492. unsigned int tx_mask,
  7493. unsigned int rx_mask,
  7494. int slots, int slot_width)
  7495. {
  7496. int rc = 0;
  7497. struct msm_dai_q6_tdm_dai_data *dai_data =
  7498. dev_get_drvdata(dai->dev);
  7499. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  7500. &dai_data->group_cfg.tdm_cfg;
  7501. unsigned int cap_mask;
  7502. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  7503. /* HW only supports 16 and 32 bit slot width configuration */
  7504. if ((slot_width != 16) && (slot_width != 32)) {
  7505. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  7506. __func__, slot_width);
  7507. return -EINVAL;
  7508. }
  7509. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  7510. switch (slots) {
  7511. case 1:
  7512. cap_mask = 0x01;
  7513. break;
  7514. case 2:
  7515. cap_mask = 0x03;
  7516. break;
  7517. case 4:
  7518. cap_mask = 0x0F;
  7519. break;
  7520. case 8:
  7521. cap_mask = 0xFF;
  7522. break;
  7523. case 16:
  7524. cap_mask = 0xFFFF;
  7525. break;
  7526. case 32:
  7527. cap_mask = 0xFFFFFFFF;
  7528. break;
  7529. default:
  7530. dev_err(dai->dev, "%s: invalid slots %d\n",
  7531. __func__, slots);
  7532. return -EINVAL;
  7533. }
  7534. switch (dai->id) {
  7535. case AFE_PORT_ID_PRIMARY_TDM_RX:
  7536. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  7537. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  7538. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  7539. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  7540. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  7541. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  7542. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  7543. case AFE_PORT_ID_SECONDARY_TDM_RX:
  7544. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  7545. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  7546. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  7547. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  7548. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  7549. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  7550. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  7551. case AFE_PORT_ID_TERTIARY_TDM_RX:
  7552. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  7553. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  7554. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  7555. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  7556. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  7557. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  7558. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  7559. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  7560. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  7561. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  7562. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  7563. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  7564. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  7565. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  7566. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  7567. case AFE_PORT_ID_QUINARY_TDM_RX:
  7568. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  7569. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  7570. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  7571. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  7572. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  7573. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  7574. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  7575. case AFE_PORT_ID_SENARY_TDM_RX:
  7576. case AFE_PORT_ID_SENARY_TDM_RX_1:
  7577. case AFE_PORT_ID_SENARY_TDM_RX_2:
  7578. case AFE_PORT_ID_SENARY_TDM_RX_3:
  7579. case AFE_PORT_ID_SENARY_TDM_RX_4:
  7580. case AFE_PORT_ID_SENARY_TDM_RX_5:
  7581. case AFE_PORT_ID_SENARY_TDM_RX_6:
  7582. case AFE_PORT_ID_SENARY_TDM_RX_7:
  7583. tdm_group->nslots_per_frame = slots;
  7584. tdm_group->slot_width = slot_width;
  7585. tdm_group->slot_mask = rx_mask & cap_mask;
  7586. break;
  7587. case AFE_PORT_ID_PRIMARY_TDM_TX:
  7588. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  7589. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  7590. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  7591. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  7592. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  7593. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  7594. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  7595. case AFE_PORT_ID_SECONDARY_TDM_TX:
  7596. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  7597. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  7598. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  7599. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  7600. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  7601. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  7602. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  7603. case AFE_PORT_ID_TERTIARY_TDM_TX:
  7604. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  7605. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  7606. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  7607. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  7608. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  7609. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  7610. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  7611. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  7612. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  7613. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  7614. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  7615. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  7616. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  7617. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  7618. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  7619. case AFE_PORT_ID_QUINARY_TDM_TX:
  7620. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  7621. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  7622. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  7623. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  7624. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  7625. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  7626. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  7627. case AFE_PORT_ID_SENARY_TDM_TX:
  7628. case AFE_PORT_ID_SENARY_TDM_TX_1:
  7629. case AFE_PORT_ID_SENARY_TDM_TX_2:
  7630. case AFE_PORT_ID_SENARY_TDM_TX_3:
  7631. case AFE_PORT_ID_SENARY_TDM_TX_4:
  7632. case AFE_PORT_ID_SENARY_TDM_TX_5:
  7633. case AFE_PORT_ID_SENARY_TDM_TX_6:
  7634. case AFE_PORT_ID_SENARY_TDM_TX_7:
  7635. tdm_group->nslots_per_frame = slots;
  7636. tdm_group->slot_width = slot_width;
  7637. tdm_group->slot_mask = tx_mask & cap_mask;
  7638. break;
  7639. default:
  7640. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7641. __func__, dai->id);
  7642. return -EINVAL;
  7643. }
  7644. return rc;
  7645. }
  7646. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  7647. int clk_id, unsigned int freq, int dir)
  7648. {
  7649. struct msm_dai_q6_tdm_dai_data *dai_data =
  7650. dev_get_drvdata(dai->dev);
  7651. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  7652. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  7653. dai_data->clk_set.clk_freq_in_hz = freq;
  7654. } else {
  7655. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7656. __func__, dai->id);
  7657. return -EINVAL;
  7658. }
  7659. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  7660. __func__, dai->id, freq);
  7661. return 0;
  7662. }
  7663. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  7664. unsigned int tx_num, unsigned int *tx_slot,
  7665. unsigned int rx_num, unsigned int *rx_slot)
  7666. {
  7667. int rc = 0;
  7668. struct msm_dai_q6_tdm_dai_data *dai_data =
  7669. dev_get_drvdata(dai->dev);
  7670. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  7671. &dai_data->port_cfg.slot_mapping;
  7672. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  7673. &dai_data->port_cfg.slot_mapping_v2;
  7674. int i = 0;
  7675. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  7676. switch (dai->id) {
  7677. case AFE_PORT_ID_PRIMARY_TDM_RX:
  7678. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  7679. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  7680. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  7681. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  7682. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  7683. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  7684. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  7685. case AFE_PORT_ID_SECONDARY_TDM_RX:
  7686. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  7687. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  7688. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  7689. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  7690. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  7691. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  7692. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  7693. case AFE_PORT_ID_TERTIARY_TDM_RX:
  7694. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  7695. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  7696. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  7697. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  7698. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  7699. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  7700. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  7701. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  7702. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  7703. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  7704. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  7705. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  7706. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  7707. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  7708. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  7709. case AFE_PORT_ID_QUINARY_TDM_RX:
  7710. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  7711. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  7712. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  7713. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  7714. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  7715. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  7716. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  7717. case AFE_PORT_ID_SENARY_TDM_RX:
  7718. case AFE_PORT_ID_SENARY_TDM_RX_1:
  7719. case AFE_PORT_ID_SENARY_TDM_RX_2:
  7720. case AFE_PORT_ID_SENARY_TDM_RX_3:
  7721. case AFE_PORT_ID_SENARY_TDM_RX_4:
  7722. case AFE_PORT_ID_SENARY_TDM_RX_5:
  7723. case AFE_PORT_ID_SENARY_TDM_RX_6:
  7724. case AFE_PORT_ID_SENARY_TDM_RX_7:
  7725. if (q6core_get_avcs_api_version_per_service(
  7726. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  7727. if (!rx_slot) {
  7728. dev_err(dai->dev, "%s: rx slot not found\n",
  7729. __func__);
  7730. return -EINVAL;
  7731. }
  7732. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  7733. dev_err(dai->dev, "%s: invalid rx num %d\n",
  7734. __func__,
  7735. rx_num);
  7736. return -EINVAL;
  7737. }
  7738. for (i = 0; i < rx_num; i++)
  7739. slot_mapping_v2->offset[i] = rx_slot[i];
  7740. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  7741. i++)
  7742. slot_mapping_v2->offset[i] =
  7743. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7744. slot_mapping_v2->num_channel = rx_num;
  7745. } else {
  7746. if (!rx_slot) {
  7747. dev_err(dai->dev, "%s: rx slot not found\n",
  7748. __func__);
  7749. return -EINVAL;
  7750. }
  7751. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  7752. dev_err(dai->dev, "%s: invalid rx num %d\n",
  7753. __func__,
  7754. rx_num);
  7755. return -EINVAL;
  7756. }
  7757. for (i = 0; i < rx_num; i++)
  7758. slot_mapping->offset[i] = rx_slot[i];
  7759. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  7760. slot_mapping->offset[i] =
  7761. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7762. slot_mapping->num_channel = rx_num;
  7763. }
  7764. break;
  7765. case AFE_PORT_ID_PRIMARY_TDM_TX:
  7766. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  7767. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  7768. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  7769. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  7770. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  7771. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  7772. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  7773. case AFE_PORT_ID_SECONDARY_TDM_TX:
  7774. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  7775. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  7776. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  7777. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  7778. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  7779. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  7780. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  7781. case AFE_PORT_ID_TERTIARY_TDM_TX:
  7782. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  7783. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  7784. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  7785. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  7786. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  7787. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  7788. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  7789. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  7790. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  7791. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  7792. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  7793. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  7794. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  7795. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  7796. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  7797. case AFE_PORT_ID_QUINARY_TDM_TX:
  7798. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  7799. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  7800. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  7801. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  7802. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  7803. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  7804. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  7805. case AFE_PORT_ID_SENARY_TDM_TX:
  7806. case AFE_PORT_ID_SENARY_TDM_TX_1:
  7807. case AFE_PORT_ID_SENARY_TDM_TX_2:
  7808. case AFE_PORT_ID_SENARY_TDM_TX_3:
  7809. case AFE_PORT_ID_SENARY_TDM_TX_4:
  7810. case AFE_PORT_ID_SENARY_TDM_TX_5:
  7811. case AFE_PORT_ID_SENARY_TDM_TX_6:
  7812. case AFE_PORT_ID_SENARY_TDM_TX_7:
  7813. if (q6core_get_avcs_api_version_per_service(
  7814. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  7815. if (!tx_slot) {
  7816. dev_err(dai->dev, "%s: tx slot not found\n",
  7817. __func__);
  7818. return -EINVAL;
  7819. }
  7820. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  7821. dev_err(dai->dev, "%s: invalid tx num %d\n",
  7822. __func__,
  7823. tx_num);
  7824. return -EINVAL;
  7825. }
  7826. for (i = 0; i < tx_num; i++)
  7827. slot_mapping_v2->offset[i] = tx_slot[i];
  7828. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  7829. i++)
  7830. slot_mapping_v2->offset[i] =
  7831. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7832. slot_mapping_v2->num_channel = tx_num;
  7833. } else {
  7834. if (!tx_slot) {
  7835. dev_err(dai->dev, "%s: tx slot not found\n",
  7836. __func__);
  7837. return -EINVAL;
  7838. }
  7839. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  7840. dev_err(dai->dev, "%s: invalid tx num %d\n",
  7841. __func__,
  7842. tx_num);
  7843. return -EINVAL;
  7844. }
  7845. for (i = 0; i < tx_num; i++)
  7846. slot_mapping->offset[i] = tx_slot[i];
  7847. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  7848. slot_mapping->offset[i] =
  7849. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7850. slot_mapping->num_channel = tx_num;
  7851. }
  7852. break;
  7853. default:
  7854. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7855. __func__, dai->id);
  7856. return -EINVAL;
  7857. }
  7858. return rc;
  7859. }
  7860. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  7861. struct snd_pcm_hw_params *params,
  7862. struct snd_soc_dai *dai)
  7863. {
  7864. struct msm_dai_q6_tdm_dai_data *dai_data =
  7865. dev_get_drvdata(dai->dev);
  7866. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  7867. &dai_data->group_cfg.tdm_cfg;
  7868. struct afe_param_id_tdm_cfg *tdm =
  7869. &dai_data->port_cfg.tdm;
  7870. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  7871. &dai_data->port_cfg.slot_mapping;
  7872. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  7873. &dai_data->port_cfg.slot_mapping_v2;
  7874. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  7875. &dai_data->port_cfg.custom_tdm_header;
  7876. pr_debug("%s: dev_name: %s\n",
  7877. __func__, dev_name(dai->dev));
  7878. if ((params_channels(params) == 0) ||
  7879. (params_channels(params) > 32)) {
  7880. dev_err(dai->dev, "%s: invalid param channels %d\n",
  7881. __func__, params_channels(params));
  7882. return -EINVAL;
  7883. }
  7884. switch (params_format(params)) {
  7885. case SNDRV_PCM_FORMAT_S16_LE:
  7886. dai_data->bitwidth = 16;
  7887. break;
  7888. case SNDRV_PCM_FORMAT_S24_LE:
  7889. case SNDRV_PCM_FORMAT_S24_3LE:
  7890. dai_data->bitwidth = 24;
  7891. break;
  7892. case SNDRV_PCM_FORMAT_S32_LE:
  7893. dai_data->bitwidth = 32;
  7894. break;
  7895. default:
  7896. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  7897. __func__, params_format(params));
  7898. return -EINVAL;
  7899. }
  7900. dai_data->channels = params_channels(params);
  7901. dai_data->rate = params_rate(params);
  7902. /*
  7903. * update tdm group config param
  7904. * NOTE: group config is set to the same as slot config.
  7905. */
  7906. tdm_group->bit_width = tdm_group->slot_width;
  7907. /*
  7908. * for multi lane scenario
  7909. * Total number of active channels = number of active lanes * number of active slots.
  7910. */
  7911. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  7912. tdm_group->num_channels = tdm_group->nslots_per_frame
  7913. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  7914. else
  7915. tdm_group->num_channels = tdm_group->nslots_per_frame;
  7916. tdm_group->sample_rate = dai_data->rate;
  7917. pr_debug("%s: TDM GROUP:\n"
  7918. "num_channels=%d sample_rate=%d bit_width=%d\n"
  7919. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  7920. __func__,
  7921. tdm_group->num_channels,
  7922. tdm_group->sample_rate,
  7923. tdm_group->bit_width,
  7924. tdm_group->nslots_per_frame,
  7925. tdm_group->slot_width,
  7926. tdm_group->slot_mask);
  7927. pr_debug("%s: TDM GROUP:\n"
  7928. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  7929. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  7930. __func__,
  7931. tdm_group->port_id[0],
  7932. tdm_group->port_id[1],
  7933. tdm_group->port_id[2],
  7934. tdm_group->port_id[3],
  7935. tdm_group->port_id[4],
  7936. tdm_group->port_id[5],
  7937. tdm_group->port_id[6],
  7938. tdm_group->port_id[7]);
  7939. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  7940. __func__,
  7941. tdm_group->group_id,
  7942. dai_data->lane_cfg.lane_mask);
  7943. /*
  7944. * update tdm config param
  7945. * NOTE: channels/rate/bitwidth are per stream property
  7946. */
  7947. tdm->num_channels = dai_data->channels;
  7948. tdm->sample_rate = dai_data->rate;
  7949. tdm->bit_width = dai_data->bitwidth;
  7950. /*
  7951. * port slot config is the same as group slot config
  7952. * port slot mask should be set according to offset
  7953. */
  7954. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  7955. tdm->slot_width = tdm_group->slot_width;
  7956. tdm->slot_mask = tdm_group->slot_mask;
  7957. pr_debug("%s: TDM:\n"
  7958. "num_channels=%d sample_rate=%d bit_width=%d\n"
  7959. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  7960. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  7961. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  7962. __func__,
  7963. tdm->num_channels,
  7964. tdm->sample_rate,
  7965. tdm->bit_width,
  7966. tdm->nslots_per_frame,
  7967. tdm->slot_width,
  7968. tdm->slot_mask,
  7969. tdm->data_format,
  7970. tdm->sync_mode,
  7971. tdm->sync_src,
  7972. tdm->ctrl_data_out_enable,
  7973. tdm->ctrl_invert_sync_pulse,
  7974. tdm->ctrl_sync_data_delay);
  7975. if (q6core_get_avcs_api_version_per_service(
  7976. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  7977. /*
  7978. * update slot mapping v2 config param
  7979. * NOTE: channels/rate/bitwidth are per stream property
  7980. */
  7981. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  7982. pr_debug("%s: SLOT MAPPING_V2:\n"
  7983. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  7984. __func__,
  7985. slot_mapping_v2->num_channel,
  7986. slot_mapping_v2->bitwidth,
  7987. slot_mapping_v2->data_align_type);
  7988. pr_debug("%s: SLOT MAPPING V2:\n"
  7989. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  7990. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  7991. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  7992. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  7993. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  7994. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  7995. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  7996. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  7997. __func__,
  7998. slot_mapping_v2->offset[0],
  7999. slot_mapping_v2->offset[1],
  8000. slot_mapping_v2->offset[2],
  8001. slot_mapping_v2->offset[3],
  8002. slot_mapping_v2->offset[4],
  8003. slot_mapping_v2->offset[5],
  8004. slot_mapping_v2->offset[6],
  8005. slot_mapping_v2->offset[7],
  8006. slot_mapping_v2->offset[8],
  8007. slot_mapping_v2->offset[9],
  8008. slot_mapping_v2->offset[10],
  8009. slot_mapping_v2->offset[11],
  8010. slot_mapping_v2->offset[12],
  8011. slot_mapping_v2->offset[13],
  8012. slot_mapping_v2->offset[14],
  8013. slot_mapping_v2->offset[15],
  8014. slot_mapping_v2->offset[16],
  8015. slot_mapping_v2->offset[17],
  8016. slot_mapping_v2->offset[18],
  8017. slot_mapping_v2->offset[19],
  8018. slot_mapping_v2->offset[20],
  8019. slot_mapping_v2->offset[21],
  8020. slot_mapping_v2->offset[22],
  8021. slot_mapping_v2->offset[23],
  8022. slot_mapping_v2->offset[24],
  8023. slot_mapping_v2->offset[25],
  8024. slot_mapping_v2->offset[26],
  8025. slot_mapping_v2->offset[27],
  8026. slot_mapping_v2->offset[28],
  8027. slot_mapping_v2->offset[29],
  8028. slot_mapping_v2->offset[30],
  8029. slot_mapping_v2->offset[31]);
  8030. } else {
  8031. /*
  8032. * update slot mapping config param
  8033. * NOTE: channels/rate/bitwidth are per stream property
  8034. */
  8035. slot_mapping->bitwidth = dai_data->bitwidth;
  8036. pr_debug("%s: SLOT MAPPING:\n"
  8037. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8038. __func__,
  8039. slot_mapping->num_channel,
  8040. slot_mapping->bitwidth,
  8041. slot_mapping->data_align_type);
  8042. pr_debug("%s: SLOT MAPPING:\n"
  8043. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8044. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  8045. __func__,
  8046. slot_mapping->offset[0],
  8047. slot_mapping->offset[1],
  8048. slot_mapping->offset[2],
  8049. slot_mapping->offset[3],
  8050. slot_mapping->offset[4],
  8051. slot_mapping->offset[5],
  8052. slot_mapping->offset[6],
  8053. slot_mapping->offset[7]);
  8054. }
  8055. /*
  8056. * update custom header config param
  8057. * NOTE: channels/rate/bitwidth are per playback stream property.
  8058. * custom tdm header only applicable to playback stream.
  8059. */
  8060. if (custom_tdm_header->header_type !=
  8061. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  8062. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8063. "start_offset=0x%x header_width=%d\n"
  8064. "num_frame_repeat=%d header_type=0x%x\n",
  8065. __func__,
  8066. custom_tdm_header->start_offset,
  8067. custom_tdm_header->header_width,
  8068. custom_tdm_header->num_frame_repeat,
  8069. custom_tdm_header->header_type);
  8070. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8071. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  8072. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  8073. __func__,
  8074. custom_tdm_header->header[0],
  8075. custom_tdm_header->header[1],
  8076. custom_tdm_header->header[2],
  8077. custom_tdm_header->header[3],
  8078. custom_tdm_header->header[4],
  8079. custom_tdm_header->header[5],
  8080. custom_tdm_header->header[6],
  8081. custom_tdm_header->header[7]);
  8082. }
  8083. return 0;
  8084. }
  8085. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  8086. struct snd_soc_dai *dai)
  8087. {
  8088. int rc = 0;
  8089. struct msm_dai_q6_tdm_dai_data *dai_data =
  8090. dev_get_drvdata(dai->dev);
  8091. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8092. int group_idx = 0;
  8093. atomic_t *group_ref = NULL;
  8094. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  8095. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  8096. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  8097. dev_dbg(dai->dev,
  8098. "%s: Custom tdm header not supported\n", __func__);
  8099. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8100. if (group_idx < 0) {
  8101. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8102. __func__, dai->id);
  8103. return -EINVAL;
  8104. }
  8105. mutex_lock(&tdm_mutex);
  8106. group_ref = &tdm_group_ref[group_idx];
  8107. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8108. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8109. /* TX and RX share the same clk. So enable the clk
  8110. * per TDM interface. */
  8111. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8112. dai->id, true);
  8113. if (rc < 0) {
  8114. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  8115. __func__, dai->id);
  8116. goto rtn;
  8117. }
  8118. }
  8119. /* PORT START should be set if prepare called
  8120. * in active state.
  8121. */
  8122. if (atomic_read(group_ref) == 0) {
  8123. /*
  8124. * if only one port, don't do group enable as there
  8125. * is no group need for only one port
  8126. */
  8127. if (dai_data->num_group_ports > 1) {
  8128. rc = afe_port_group_enable(group_id,
  8129. &dai_data->group_cfg, true,
  8130. &dai_data->lane_cfg);
  8131. if (rc < 0) {
  8132. dev_err(dai->dev,
  8133. "%s: fail to enable AFE group 0x%x\n",
  8134. __func__, group_id);
  8135. goto rtn;
  8136. }
  8137. }
  8138. }
  8139. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  8140. dai_data->rate, dai_data->num_group_ports);
  8141. if (rc < 0) {
  8142. if (atomic_read(group_ref) == 0) {
  8143. afe_port_group_enable(group_id,
  8144. NULL, false, NULL);
  8145. }
  8146. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8147. msm_dai_q6_tdm_set_clk(dai_data,
  8148. dai->id, false);
  8149. }
  8150. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  8151. __func__, dai->id);
  8152. } else {
  8153. set_bit(STATUS_PORT_STARTED,
  8154. dai_data->status_mask);
  8155. atomic_inc(group_ref);
  8156. }
  8157. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8158. /* NOTE: AFE should error out if HW resource contention */
  8159. }
  8160. rtn:
  8161. mutex_unlock(&tdm_mutex);
  8162. return rc;
  8163. }
  8164. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  8165. struct snd_soc_dai *dai)
  8166. {
  8167. int rc = 0;
  8168. struct msm_dai_q6_tdm_dai_data *dai_data =
  8169. dev_get_drvdata(dai->dev);
  8170. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8171. int group_idx = 0;
  8172. atomic_t *group_ref = NULL;
  8173. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8174. if (group_idx < 0) {
  8175. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8176. __func__, dai->id);
  8177. return;
  8178. }
  8179. mutex_lock(&tdm_mutex);
  8180. group_ref = &tdm_group_ref[group_idx];
  8181. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8182. rc = afe_close(dai->id);
  8183. if (rc < 0) {
  8184. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8185. __func__, dai->id);
  8186. }
  8187. atomic_dec(group_ref);
  8188. clear_bit(STATUS_PORT_STARTED,
  8189. dai_data->status_mask);
  8190. if (atomic_read(group_ref) == 0) {
  8191. rc = afe_port_group_enable(group_id,
  8192. NULL, false, NULL);
  8193. if (rc < 0) {
  8194. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  8195. __func__, group_id);
  8196. }
  8197. }
  8198. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8199. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8200. dai->id, false);
  8201. if (rc < 0) {
  8202. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8203. __func__, dai->id);
  8204. }
  8205. }
  8206. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8207. /* NOTE: AFE should error out if HW resource contention */
  8208. }
  8209. mutex_unlock(&tdm_mutex);
  8210. }
  8211. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  8212. .prepare = msm_dai_q6_tdm_prepare,
  8213. .hw_params = msm_dai_q6_tdm_hw_params,
  8214. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  8215. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  8216. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  8217. .shutdown = msm_dai_q6_tdm_shutdown,
  8218. };
  8219. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  8220. {
  8221. .playback = {
  8222. .stream_name = "Primary TDM0 Playback",
  8223. .aif_name = "PRI_TDM_RX_0",
  8224. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8225. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8226. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8227. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8228. SNDRV_PCM_FMTBIT_S24_LE |
  8229. SNDRV_PCM_FMTBIT_S32_LE,
  8230. .channels_min = 1,
  8231. .channels_max = 16,
  8232. .rate_min = 8000,
  8233. .rate_max = 352800,
  8234. },
  8235. .name = "PRI_TDM_RX_0",
  8236. .ops = &msm_dai_q6_tdm_ops,
  8237. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  8238. .probe = msm_dai_q6_dai_tdm_probe,
  8239. .remove = msm_dai_q6_dai_tdm_remove,
  8240. },
  8241. {
  8242. .playback = {
  8243. .stream_name = "Primary TDM1 Playback",
  8244. .aif_name = "PRI_TDM_RX_1",
  8245. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8246. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8247. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8248. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8249. SNDRV_PCM_FMTBIT_S24_LE |
  8250. SNDRV_PCM_FMTBIT_S32_LE,
  8251. .channels_min = 1,
  8252. .channels_max = 16,
  8253. .rate_min = 8000,
  8254. .rate_max = 352800,
  8255. },
  8256. .name = "PRI_TDM_RX_1",
  8257. .ops = &msm_dai_q6_tdm_ops,
  8258. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  8259. .probe = msm_dai_q6_dai_tdm_probe,
  8260. .remove = msm_dai_q6_dai_tdm_remove,
  8261. },
  8262. {
  8263. .playback = {
  8264. .stream_name = "Primary TDM2 Playback",
  8265. .aif_name = "PRI_TDM_RX_2",
  8266. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8267. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8268. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8269. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8270. SNDRV_PCM_FMTBIT_S24_LE |
  8271. SNDRV_PCM_FMTBIT_S32_LE,
  8272. .channels_min = 1,
  8273. .channels_max = 16,
  8274. .rate_min = 8000,
  8275. .rate_max = 352800,
  8276. },
  8277. .name = "PRI_TDM_RX_2",
  8278. .ops = &msm_dai_q6_tdm_ops,
  8279. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  8280. .probe = msm_dai_q6_dai_tdm_probe,
  8281. .remove = msm_dai_q6_dai_tdm_remove,
  8282. },
  8283. {
  8284. .playback = {
  8285. .stream_name = "Primary TDM3 Playback",
  8286. .aif_name = "PRI_TDM_RX_3",
  8287. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8288. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8289. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8290. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8291. SNDRV_PCM_FMTBIT_S24_LE |
  8292. SNDRV_PCM_FMTBIT_S32_LE,
  8293. .channels_min = 1,
  8294. .channels_max = 16,
  8295. .rate_min = 8000,
  8296. .rate_max = 352800,
  8297. },
  8298. .name = "PRI_TDM_RX_3",
  8299. .ops = &msm_dai_q6_tdm_ops,
  8300. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  8301. .probe = msm_dai_q6_dai_tdm_probe,
  8302. .remove = msm_dai_q6_dai_tdm_remove,
  8303. },
  8304. {
  8305. .playback = {
  8306. .stream_name = "Primary TDM4 Playback",
  8307. .aif_name = "PRI_TDM_RX_4",
  8308. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8309. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8310. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8311. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8312. SNDRV_PCM_FMTBIT_S24_LE |
  8313. SNDRV_PCM_FMTBIT_S32_LE,
  8314. .channels_min = 1,
  8315. .channels_max = 16,
  8316. .rate_min = 8000,
  8317. .rate_max = 352800,
  8318. },
  8319. .name = "PRI_TDM_RX_4",
  8320. .ops = &msm_dai_q6_tdm_ops,
  8321. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  8322. .probe = msm_dai_q6_dai_tdm_probe,
  8323. .remove = msm_dai_q6_dai_tdm_remove,
  8324. },
  8325. {
  8326. .playback = {
  8327. .stream_name = "Primary TDM5 Playback",
  8328. .aif_name = "PRI_TDM_RX_5",
  8329. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8330. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8331. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8332. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8333. SNDRV_PCM_FMTBIT_S24_LE |
  8334. SNDRV_PCM_FMTBIT_S32_LE,
  8335. .channels_min = 1,
  8336. .channels_max = 16,
  8337. .rate_min = 8000,
  8338. .rate_max = 352800,
  8339. },
  8340. .name = "PRI_TDM_RX_5",
  8341. .ops = &msm_dai_q6_tdm_ops,
  8342. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  8343. .probe = msm_dai_q6_dai_tdm_probe,
  8344. .remove = msm_dai_q6_dai_tdm_remove,
  8345. },
  8346. {
  8347. .playback = {
  8348. .stream_name = "Primary TDM6 Playback",
  8349. .aif_name = "PRI_TDM_RX_6",
  8350. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8351. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8352. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8353. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8354. SNDRV_PCM_FMTBIT_S24_LE |
  8355. SNDRV_PCM_FMTBIT_S32_LE,
  8356. .channels_min = 1,
  8357. .channels_max = 16,
  8358. .rate_min = 8000,
  8359. .rate_max = 352800,
  8360. },
  8361. .name = "PRI_TDM_RX_6",
  8362. .ops = &msm_dai_q6_tdm_ops,
  8363. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  8364. .probe = msm_dai_q6_dai_tdm_probe,
  8365. .remove = msm_dai_q6_dai_tdm_remove,
  8366. },
  8367. {
  8368. .playback = {
  8369. .stream_name = "Primary TDM7 Playback",
  8370. .aif_name = "PRI_TDM_RX_7",
  8371. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8372. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8373. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8374. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8375. SNDRV_PCM_FMTBIT_S24_LE |
  8376. SNDRV_PCM_FMTBIT_S32_LE,
  8377. .channels_min = 1,
  8378. .channels_max = 16,
  8379. .rate_min = 8000,
  8380. .rate_max = 352800,
  8381. },
  8382. .name = "PRI_TDM_RX_7",
  8383. .ops = &msm_dai_q6_tdm_ops,
  8384. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  8385. .probe = msm_dai_q6_dai_tdm_probe,
  8386. .remove = msm_dai_q6_dai_tdm_remove,
  8387. },
  8388. {
  8389. .capture = {
  8390. .stream_name = "Primary TDM0 Capture",
  8391. .aif_name = "PRI_TDM_TX_0",
  8392. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8393. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8394. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8395. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8396. SNDRV_PCM_FMTBIT_S24_LE |
  8397. SNDRV_PCM_FMTBIT_S32_LE,
  8398. .channels_min = 1,
  8399. .channels_max = 16,
  8400. .rate_min = 8000,
  8401. .rate_max = 352800,
  8402. },
  8403. .name = "PRI_TDM_TX_0",
  8404. .ops = &msm_dai_q6_tdm_ops,
  8405. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  8406. .probe = msm_dai_q6_dai_tdm_probe,
  8407. .remove = msm_dai_q6_dai_tdm_remove,
  8408. },
  8409. {
  8410. .capture = {
  8411. .stream_name = "Primary TDM1 Capture",
  8412. .aif_name = "PRI_TDM_TX_1",
  8413. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8414. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8415. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8416. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8417. SNDRV_PCM_FMTBIT_S24_LE |
  8418. SNDRV_PCM_FMTBIT_S32_LE,
  8419. .channels_min = 1,
  8420. .channels_max = 16,
  8421. .rate_min = 8000,
  8422. .rate_max = 352800,
  8423. },
  8424. .name = "PRI_TDM_TX_1",
  8425. .ops = &msm_dai_q6_tdm_ops,
  8426. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  8427. .probe = msm_dai_q6_dai_tdm_probe,
  8428. .remove = msm_dai_q6_dai_tdm_remove,
  8429. },
  8430. {
  8431. .capture = {
  8432. .stream_name = "Primary TDM2 Capture",
  8433. .aif_name = "PRI_TDM_TX_2",
  8434. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8435. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8436. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8437. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8438. SNDRV_PCM_FMTBIT_S24_LE |
  8439. SNDRV_PCM_FMTBIT_S32_LE,
  8440. .channels_min = 1,
  8441. .channels_max = 16,
  8442. .rate_min = 8000,
  8443. .rate_max = 352800,
  8444. },
  8445. .name = "PRI_TDM_TX_2",
  8446. .ops = &msm_dai_q6_tdm_ops,
  8447. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  8448. .probe = msm_dai_q6_dai_tdm_probe,
  8449. .remove = msm_dai_q6_dai_tdm_remove,
  8450. },
  8451. {
  8452. .capture = {
  8453. .stream_name = "Primary TDM3 Capture",
  8454. .aif_name = "PRI_TDM_TX_3",
  8455. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8456. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8457. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8458. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8459. SNDRV_PCM_FMTBIT_S24_LE |
  8460. SNDRV_PCM_FMTBIT_S32_LE,
  8461. .channels_min = 1,
  8462. .channels_max = 16,
  8463. .rate_min = 8000,
  8464. .rate_max = 352800,
  8465. },
  8466. .name = "PRI_TDM_TX_3",
  8467. .ops = &msm_dai_q6_tdm_ops,
  8468. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  8469. .probe = msm_dai_q6_dai_tdm_probe,
  8470. .remove = msm_dai_q6_dai_tdm_remove,
  8471. },
  8472. {
  8473. .capture = {
  8474. .stream_name = "Primary TDM4 Capture",
  8475. .aif_name = "PRI_TDM_TX_4",
  8476. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8477. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8478. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8479. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8480. SNDRV_PCM_FMTBIT_S24_LE |
  8481. SNDRV_PCM_FMTBIT_S32_LE,
  8482. .channels_min = 1,
  8483. .channels_max = 16,
  8484. .rate_min = 8000,
  8485. .rate_max = 352800,
  8486. },
  8487. .name = "PRI_TDM_TX_4",
  8488. .ops = &msm_dai_q6_tdm_ops,
  8489. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  8490. .probe = msm_dai_q6_dai_tdm_probe,
  8491. .remove = msm_dai_q6_dai_tdm_remove,
  8492. },
  8493. {
  8494. .capture = {
  8495. .stream_name = "Primary TDM5 Capture",
  8496. .aif_name = "PRI_TDM_TX_5",
  8497. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8498. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8499. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8500. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8501. SNDRV_PCM_FMTBIT_S24_LE |
  8502. SNDRV_PCM_FMTBIT_S32_LE,
  8503. .channels_min = 1,
  8504. .channels_max = 16,
  8505. .rate_min = 8000,
  8506. .rate_max = 352800,
  8507. },
  8508. .name = "PRI_TDM_TX_5",
  8509. .ops = &msm_dai_q6_tdm_ops,
  8510. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  8511. .probe = msm_dai_q6_dai_tdm_probe,
  8512. .remove = msm_dai_q6_dai_tdm_remove,
  8513. },
  8514. {
  8515. .capture = {
  8516. .stream_name = "Primary TDM6 Capture",
  8517. .aif_name = "PRI_TDM_TX_6",
  8518. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8519. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8520. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8521. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8522. SNDRV_PCM_FMTBIT_S24_LE |
  8523. SNDRV_PCM_FMTBIT_S32_LE,
  8524. .channels_min = 1,
  8525. .channels_max = 16,
  8526. .rate_min = 8000,
  8527. .rate_max = 352800,
  8528. },
  8529. .name = "PRI_TDM_TX_6",
  8530. .ops = &msm_dai_q6_tdm_ops,
  8531. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  8532. .probe = msm_dai_q6_dai_tdm_probe,
  8533. .remove = msm_dai_q6_dai_tdm_remove,
  8534. },
  8535. {
  8536. .capture = {
  8537. .stream_name = "Primary TDM7 Capture",
  8538. .aif_name = "PRI_TDM_TX_7",
  8539. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8540. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8541. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8542. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8543. SNDRV_PCM_FMTBIT_S24_LE |
  8544. SNDRV_PCM_FMTBIT_S32_LE,
  8545. .channels_min = 1,
  8546. .channels_max = 16,
  8547. .rate_min = 8000,
  8548. .rate_max = 352800,
  8549. },
  8550. .name = "PRI_TDM_TX_7",
  8551. .ops = &msm_dai_q6_tdm_ops,
  8552. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  8553. .probe = msm_dai_q6_dai_tdm_probe,
  8554. .remove = msm_dai_q6_dai_tdm_remove,
  8555. },
  8556. {
  8557. .playback = {
  8558. .stream_name = "Secondary TDM0 Playback",
  8559. .aif_name = "SEC_TDM_RX_0",
  8560. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8561. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8562. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8563. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8564. SNDRV_PCM_FMTBIT_S24_LE |
  8565. SNDRV_PCM_FMTBIT_S32_LE,
  8566. .channels_min = 1,
  8567. .channels_max = 16,
  8568. .rate_min = 8000,
  8569. .rate_max = 352800,
  8570. },
  8571. .name = "SEC_TDM_RX_0",
  8572. .ops = &msm_dai_q6_tdm_ops,
  8573. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  8574. .probe = msm_dai_q6_dai_tdm_probe,
  8575. .remove = msm_dai_q6_dai_tdm_remove,
  8576. },
  8577. {
  8578. .playback = {
  8579. .stream_name = "Secondary TDM1 Playback",
  8580. .aif_name = "SEC_TDM_RX_1",
  8581. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8582. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8583. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8584. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8585. SNDRV_PCM_FMTBIT_S24_LE |
  8586. SNDRV_PCM_FMTBIT_S32_LE,
  8587. .channels_min = 1,
  8588. .channels_max = 16,
  8589. .rate_min = 8000,
  8590. .rate_max = 352800,
  8591. },
  8592. .name = "SEC_TDM_RX_1",
  8593. .ops = &msm_dai_q6_tdm_ops,
  8594. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  8595. .probe = msm_dai_q6_dai_tdm_probe,
  8596. .remove = msm_dai_q6_dai_tdm_remove,
  8597. },
  8598. {
  8599. .playback = {
  8600. .stream_name = "Secondary TDM2 Playback",
  8601. .aif_name = "SEC_TDM_RX_2",
  8602. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8603. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8604. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8605. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8606. SNDRV_PCM_FMTBIT_S24_LE |
  8607. SNDRV_PCM_FMTBIT_S32_LE,
  8608. .channels_min = 1,
  8609. .channels_max = 16,
  8610. .rate_min = 8000,
  8611. .rate_max = 352800,
  8612. },
  8613. .name = "SEC_TDM_RX_2",
  8614. .ops = &msm_dai_q6_tdm_ops,
  8615. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  8616. .probe = msm_dai_q6_dai_tdm_probe,
  8617. .remove = msm_dai_q6_dai_tdm_remove,
  8618. },
  8619. {
  8620. .playback = {
  8621. .stream_name = "Secondary TDM3 Playback",
  8622. .aif_name = "SEC_TDM_RX_3",
  8623. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8624. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8625. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8626. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8627. SNDRV_PCM_FMTBIT_S24_LE |
  8628. SNDRV_PCM_FMTBIT_S32_LE,
  8629. .channels_min = 1,
  8630. .channels_max = 16,
  8631. .rate_min = 8000,
  8632. .rate_max = 352800,
  8633. },
  8634. .name = "SEC_TDM_RX_3",
  8635. .ops = &msm_dai_q6_tdm_ops,
  8636. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  8637. .probe = msm_dai_q6_dai_tdm_probe,
  8638. .remove = msm_dai_q6_dai_tdm_remove,
  8639. },
  8640. {
  8641. .playback = {
  8642. .stream_name = "Secondary TDM4 Playback",
  8643. .aif_name = "SEC_TDM_RX_4",
  8644. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8645. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8646. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8647. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8648. SNDRV_PCM_FMTBIT_S24_LE |
  8649. SNDRV_PCM_FMTBIT_S32_LE,
  8650. .channels_min = 1,
  8651. .channels_max = 16,
  8652. .rate_min = 8000,
  8653. .rate_max = 352800,
  8654. },
  8655. .name = "SEC_TDM_RX_4",
  8656. .ops = &msm_dai_q6_tdm_ops,
  8657. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  8658. .probe = msm_dai_q6_dai_tdm_probe,
  8659. .remove = msm_dai_q6_dai_tdm_remove,
  8660. },
  8661. {
  8662. .playback = {
  8663. .stream_name = "Secondary TDM5 Playback",
  8664. .aif_name = "SEC_TDM_RX_5",
  8665. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8666. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8667. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8668. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8669. SNDRV_PCM_FMTBIT_S24_LE |
  8670. SNDRV_PCM_FMTBIT_S32_LE,
  8671. .channels_min = 1,
  8672. .channels_max = 16,
  8673. .rate_min = 8000,
  8674. .rate_max = 352800,
  8675. },
  8676. .name = "SEC_TDM_RX_5",
  8677. .ops = &msm_dai_q6_tdm_ops,
  8678. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  8679. .probe = msm_dai_q6_dai_tdm_probe,
  8680. .remove = msm_dai_q6_dai_tdm_remove,
  8681. },
  8682. {
  8683. .playback = {
  8684. .stream_name = "Secondary TDM6 Playback",
  8685. .aif_name = "SEC_TDM_RX_6",
  8686. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8687. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8688. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8689. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8690. SNDRV_PCM_FMTBIT_S24_LE |
  8691. SNDRV_PCM_FMTBIT_S32_LE,
  8692. .channels_min = 1,
  8693. .channels_max = 16,
  8694. .rate_min = 8000,
  8695. .rate_max = 352800,
  8696. },
  8697. .name = "SEC_TDM_RX_6",
  8698. .ops = &msm_dai_q6_tdm_ops,
  8699. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  8700. .probe = msm_dai_q6_dai_tdm_probe,
  8701. .remove = msm_dai_q6_dai_tdm_remove,
  8702. },
  8703. {
  8704. .playback = {
  8705. .stream_name = "Secondary TDM7 Playback",
  8706. .aif_name = "SEC_TDM_RX_7",
  8707. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8708. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8709. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8710. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8711. SNDRV_PCM_FMTBIT_S24_LE |
  8712. SNDRV_PCM_FMTBIT_S32_LE,
  8713. .channels_min = 1,
  8714. .channels_max = 16,
  8715. .rate_min = 8000,
  8716. .rate_max = 352800,
  8717. },
  8718. .name = "SEC_TDM_RX_7",
  8719. .ops = &msm_dai_q6_tdm_ops,
  8720. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  8721. .probe = msm_dai_q6_dai_tdm_probe,
  8722. .remove = msm_dai_q6_dai_tdm_remove,
  8723. },
  8724. {
  8725. .capture = {
  8726. .stream_name = "Secondary TDM0 Capture",
  8727. .aif_name = "SEC_TDM_TX_0",
  8728. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8729. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8730. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8731. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8732. SNDRV_PCM_FMTBIT_S24_LE |
  8733. SNDRV_PCM_FMTBIT_S32_LE,
  8734. .channels_min = 1,
  8735. .channels_max = 16,
  8736. .rate_min = 8000,
  8737. .rate_max = 352800,
  8738. },
  8739. .name = "SEC_TDM_TX_0",
  8740. .ops = &msm_dai_q6_tdm_ops,
  8741. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  8742. .probe = msm_dai_q6_dai_tdm_probe,
  8743. .remove = msm_dai_q6_dai_tdm_remove,
  8744. },
  8745. {
  8746. .capture = {
  8747. .stream_name = "Secondary TDM1 Capture",
  8748. .aif_name = "SEC_TDM_TX_1",
  8749. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8750. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8751. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8752. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8753. SNDRV_PCM_FMTBIT_S24_LE |
  8754. SNDRV_PCM_FMTBIT_S32_LE,
  8755. .channels_min = 1,
  8756. .channels_max = 16,
  8757. .rate_min = 8000,
  8758. .rate_max = 352800,
  8759. },
  8760. .name = "SEC_TDM_TX_1",
  8761. .ops = &msm_dai_q6_tdm_ops,
  8762. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  8763. .probe = msm_dai_q6_dai_tdm_probe,
  8764. .remove = msm_dai_q6_dai_tdm_remove,
  8765. },
  8766. {
  8767. .capture = {
  8768. .stream_name = "Secondary TDM2 Capture",
  8769. .aif_name = "SEC_TDM_TX_2",
  8770. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8771. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8772. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8773. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8774. SNDRV_PCM_FMTBIT_S24_LE |
  8775. SNDRV_PCM_FMTBIT_S32_LE,
  8776. .channels_min = 1,
  8777. .channels_max = 16,
  8778. .rate_min = 8000,
  8779. .rate_max = 352800,
  8780. },
  8781. .name = "SEC_TDM_TX_2",
  8782. .ops = &msm_dai_q6_tdm_ops,
  8783. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  8784. .probe = msm_dai_q6_dai_tdm_probe,
  8785. .remove = msm_dai_q6_dai_tdm_remove,
  8786. },
  8787. {
  8788. .capture = {
  8789. .stream_name = "Secondary TDM3 Capture",
  8790. .aif_name = "SEC_TDM_TX_3",
  8791. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8792. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8793. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8795. SNDRV_PCM_FMTBIT_S24_LE |
  8796. SNDRV_PCM_FMTBIT_S32_LE,
  8797. .channels_min = 1,
  8798. .channels_max = 16,
  8799. .rate_min = 8000,
  8800. .rate_max = 352800,
  8801. },
  8802. .name = "SEC_TDM_TX_3",
  8803. .ops = &msm_dai_q6_tdm_ops,
  8804. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  8805. .probe = msm_dai_q6_dai_tdm_probe,
  8806. .remove = msm_dai_q6_dai_tdm_remove,
  8807. },
  8808. {
  8809. .capture = {
  8810. .stream_name = "Secondary TDM4 Capture",
  8811. .aif_name = "SEC_TDM_TX_4",
  8812. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8813. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8814. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8815. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8816. SNDRV_PCM_FMTBIT_S24_LE |
  8817. SNDRV_PCM_FMTBIT_S32_LE,
  8818. .channels_min = 1,
  8819. .channels_max = 16,
  8820. .rate_min = 8000,
  8821. .rate_max = 352800,
  8822. },
  8823. .name = "SEC_TDM_TX_4",
  8824. .ops = &msm_dai_q6_tdm_ops,
  8825. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  8826. .probe = msm_dai_q6_dai_tdm_probe,
  8827. .remove = msm_dai_q6_dai_tdm_remove,
  8828. },
  8829. {
  8830. .capture = {
  8831. .stream_name = "Secondary TDM5 Capture",
  8832. .aif_name = "SEC_TDM_TX_5",
  8833. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8834. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8835. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8836. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8837. SNDRV_PCM_FMTBIT_S24_LE |
  8838. SNDRV_PCM_FMTBIT_S32_LE,
  8839. .channels_min = 1,
  8840. .channels_max = 16,
  8841. .rate_min = 8000,
  8842. .rate_max = 352800,
  8843. },
  8844. .name = "SEC_TDM_TX_5",
  8845. .ops = &msm_dai_q6_tdm_ops,
  8846. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  8847. .probe = msm_dai_q6_dai_tdm_probe,
  8848. .remove = msm_dai_q6_dai_tdm_remove,
  8849. },
  8850. {
  8851. .capture = {
  8852. .stream_name = "Secondary TDM6 Capture",
  8853. .aif_name = "SEC_TDM_TX_6",
  8854. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8855. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8856. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8857. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8858. SNDRV_PCM_FMTBIT_S24_LE |
  8859. SNDRV_PCM_FMTBIT_S32_LE,
  8860. .channels_min = 1,
  8861. .channels_max = 16,
  8862. .rate_min = 8000,
  8863. .rate_max = 352800,
  8864. },
  8865. .name = "SEC_TDM_TX_6",
  8866. .ops = &msm_dai_q6_tdm_ops,
  8867. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  8868. .probe = msm_dai_q6_dai_tdm_probe,
  8869. .remove = msm_dai_q6_dai_tdm_remove,
  8870. },
  8871. {
  8872. .capture = {
  8873. .stream_name = "Secondary TDM7 Capture",
  8874. .aif_name = "SEC_TDM_TX_7",
  8875. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8876. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8877. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8878. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8879. SNDRV_PCM_FMTBIT_S24_LE |
  8880. SNDRV_PCM_FMTBIT_S32_LE,
  8881. .channels_min = 1,
  8882. .channels_max = 16,
  8883. .rate_min = 8000,
  8884. .rate_max = 352800,
  8885. },
  8886. .name = "SEC_TDM_TX_7",
  8887. .ops = &msm_dai_q6_tdm_ops,
  8888. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  8889. .probe = msm_dai_q6_dai_tdm_probe,
  8890. .remove = msm_dai_q6_dai_tdm_remove,
  8891. },
  8892. {
  8893. .playback = {
  8894. .stream_name = "Tertiary TDM0 Playback",
  8895. .aif_name = "TERT_TDM_RX_0",
  8896. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8897. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8898. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8899. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8900. SNDRV_PCM_FMTBIT_S24_LE |
  8901. SNDRV_PCM_FMTBIT_S32_LE,
  8902. .channels_min = 1,
  8903. .channels_max = 16,
  8904. .rate_min = 8000,
  8905. .rate_max = 352800,
  8906. },
  8907. .name = "TERT_TDM_RX_0",
  8908. .ops = &msm_dai_q6_tdm_ops,
  8909. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  8910. .probe = msm_dai_q6_dai_tdm_probe,
  8911. .remove = msm_dai_q6_dai_tdm_remove,
  8912. },
  8913. {
  8914. .playback = {
  8915. .stream_name = "Tertiary TDM1 Playback",
  8916. .aif_name = "TERT_TDM_RX_1",
  8917. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8918. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8919. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8920. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8921. SNDRV_PCM_FMTBIT_S24_LE |
  8922. SNDRV_PCM_FMTBIT_S32_LE,
  8923. .channels_min = 1,
  8924. .channels_max = 16,
  8925. .rate_min = 8000,
  8926. .rate_max = 352800,
  8927. },
  8928. .name = "TERT_TDM_RX_1",
  8929. .ops = &msm_dai_q6_tdm_ops,
  8930. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  8931. .probe = msm_dai_q6_dai_tdm_probe,
  8932. .remove = msm_dai_q6_dai_tdm_remove,
  8933. },
  8934. {
  8935. .playback = {
  8936. .stream_name = "Tertiary TDM2 Playback",
  8937. .aif_name = "TERT_TDM_RX_2",
  8938. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8939. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8940. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8941. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8942. SNDRV_PCM_FMTBIT_S24_LE |
  8943. SNDRV_PCM_FMTBIT_S32_LE,
  8944. .channels_min = 1,
  8945. .channels_max = 16,
  8946. .rate_min = 8000,
  8947. .rate_max = 352800,
  8948. },
  8949. .name = "TERT_TDM_RX_2",
  8950. .ops = &msm_dai_q6_tdm_ops,
  8951. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  8952. .probe = msm_dai_q6_dai_tdm_probe,
  8953. .remove = msm_dai_q6_dai_tdm_remove,
  8954. },
  8955. {
  8956. .playback = {
  8957. .stream_name = "Tertiary TDM3 Playback",
  8958. .aif_name = "TERT_TDM_RX_3",
  8959. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8960. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8961. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8962. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8963. SNDRV_PCM_FMTBIT_S24_LE |
  8964. SNDRV_PCM_FMTBIT_S32_LE,
  8965. .channels_min = 1,
  8966. .channels_max = 16,
  8967. .rate_min = 8000,
  8968. .rate_max = 352800,
  8969. },
  8970. .name = "TERT_TDM_RX_3",
  8971. .ops = &msm_dai_q6_tdm_ops,
  8972. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  8973. .probe = msm_dai_q6_dai_tdm_probe,
  8974. .remove = msm_dai_q6_dai_tdm_remove,
  8975. },
  8976. {
  8977. .playback = {
  8978. .stream_name = "Tertiary TDM4 Playback",
  8979. .aif_name = "TERT_TDM_RX_4",
  8980. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8981. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8982. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8983. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8984. SNDRV_PCM_FMTBIT_S24_LE |
  8985. SNDRV_PCM_FMTBIT_S32_LE,
  8986. .channels_min = 1,
  8987. .channels_max = 16,
  8988. .rate_min = 8000,
  8989. .rate_max = 352800,
  8990. },
  8991. .name = "TERT_TDM_RX_4",
  8992. .ops = &msm_dai_q6_tdm_ops,
  8993. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  8994. .probe = msm_dai_q6_dai_tdm_probe,
  8995. .remove = msm_dai_q6_dai_tdm_remove,
  8996. },
  8997. {
  8998. .playback = {
  8999. .stream_name = "Tertiary TDM5 Playback",
  9000. .aif_name = "TERT_TDM_RX_5",
  9001. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9002. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9003. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9004. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9005. SNDRV_PCM_FMTBIT_S24_LE |
  9006. SNDRV_PCM_FMTBIT_S32_LE,
  9007. .channels_min = 1,
  9008. .channels_max = 16,
  9009. .rate_min = 8000,
  9010. .rate_max = 352800,
  9011. },
  9012. .name = "TERT_TDM_RX_5",
  9013. .ops = &msm_dai_q6_tdm_ops,
  9014. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  9015. .probe = msm_dai_q6_dai_tdm_probe,
  9016. .remove = msm_dai_q6_dai_tdm_remove,
  9017. },
  9018. {
  9019. .playback = {
  9020. .stream_name = "Tertiary TDM6 Playback",
  9021. .aif_name = "TERT_TDM_RX_6",
  9022. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9023. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9024. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9025. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9026. SNDRV_PCM_FMTBIT_S24_LE |
  9027. SNDRV_PCM_FMTBIT_S32_LE,
  9028. .channels_min = 1,
  9029. .channels_max = 16,
  9030. .rate_min = 8000,
  9031. .rate_max = 352800,
  9032. },
  9033. .name = "TERT_TDM_RX_6",
  9034. .ops = &msm_dai_q6_tdm_ops,
  9035. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  9036. .probe = msm_dai_q6_dai_tdm_probe,
  9037. .remove = msm_dai_q6_dai_tdm_remove,
  9038. },
  9039. {
  9040. .playback = {
  9041. .stream_name = "Tertiary TDM7 Playback",
  9042. .aif_name = "TERT_TDM_RX_7",
  9043. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9044. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9045. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9046. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9047. SNDRV_PCM_FMTBIT_S24_LE |
  9048. SNDRV_PCM_FMTBIT_S32_LE,
  9049. .channels_min = 1,
  9050. .channels_max = 16,
  9051. .rate_min = 8000,
  9052. .rate_max = 352800,
  9053. },
  9054. .name = "TERT_TDM_RX_7",
  9055. .ops = &msm_dai_q6_tdm_ops,
  9056. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  9057. .probe = msm_dai_q6_dai_tdm_probe,
  9058. .remove = msm_dai_q6_dai_tdm_remove,
  9059. },
  9060. {
  9061. .capture = {
  9062. .stream_name = "Tertiary TDM0 Capture",
  9063. .aif_name = "TERT_TDM_TX_0",
  9064. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9065. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9066. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9067. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9068. SNDRV_PCM_FMTBIT_S24_LE |
  9069. SNDRV_PCM_FMTBIT_S32_LE,
  9070. .channels_min = 1,
  9071. .channels_max = 16,
  9072. .rate_min = 8000,
  9073. .rate_max = 352800,
  9074. },
  9075. .name = "TERT_TDM_TX_0",
  9076. .ops = &msm_dai_q6_tdm_ops,
  9077. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  9078. .probe = msm_dai_q6_dai_tdm_probe,
  9079. .remove = msm_dai_q6_dai_tdm_remove,
  9080. },
  9081. {
  9082. .capture = {
  9083. .stream_name = "Tertiary TDM1 Capture",
  9084. .aif_name = "TERT_TDM_TX_1",
  9085. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9086. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9087. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9088. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9089. SNDRV_PCM_FMTBIT_S24_LE |
  9090. SNDRV_PCM_FMTBIT_S32_LE,
  9091. .channels_min = 1,
  9092. .channels_max = 16,
  9093. .rate_min = 8000,
  9094. .rate_max = 352800,
  9095. },
  9096. .name = "TERT_TDM_TX_1",
  9097. .ops = &msm_dai_q6_tdm_ops,
  9098. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  9099. .probe = msm_dai_q6_dai_tdm_probe,
  9100. .remove = msm_dai_q6_dai_tdm_remove,
  9101. },
  9102. {
  9103. .capture = {
  9104. .stream_name = "Tertiary TDM2 Capture",
  9105. .aif_name = "TERT_TDM_TX_2",
  9106. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9107. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9108. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9109. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9110. SNDRV_PCM_FMTBIT_S24_LE |
  9111. SNDRV_PCM_FMTBIT_S32_LE,
  9112. .channels_min = 1,
  9113. .channels_max = 16,
  9114. .rate_min = 8000,
  9115. .rate_max = 352800,
  9116. },
  9117. .name = "TERT_TDM_TX_2",
  9118. .ops = &msm_dai_q6_tdm_ops,
  9119. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  9120. .probe = msm_dai_q6_dai_tdm_probe,
  9121. .remove = msm_dai_q6_dai_tdm_remove,
  9122. },
  9123. {
  9124. .capture = {
  9125. .stream_name = "Tertiary TDM3 Capture",
  9126. .aif_name = "TERT_TDM_TX_3",
  9127. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9128. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9129. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9130. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9131. SNDRV_PCM_FMTBIT_S24_LE |
  9132. SNDRV_PCM_FMTBIT_S32_LE,
  9133. .channels_min = 1,
  9134. .channels_max = 16,
  9135. .rate_min = 8000,
  9136. .rate_max = 352800,
  9137. },
  9138. .name = "TERT_TDM_TX_3",
  9139. .ops = &msm_dai_q6_tdm_ops,
  9140. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  9141. .probe = msm_dai_q6_dai_tdm_probe,
  9142. .remove = msm_dai_q6_dai_tdm_remove,
  9143. },
  9144. {
  9145. .capture = {
  9146. .stream_name = "Tertiary TDM4 Capture",
  9147. .aif_name = "TERT_TDM_TX_4",
  9148. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9149. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9150. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9151. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9152. SNDRV_PCM_FMTBIT_S24_LE |
  9153. SNDRV_PCM_FMTBIT_S32_LE,
  9154. .channels_min = 1,
  9155. .channels_max = 16,
  9156. .rate_min = 8000,
  9157. .rate_max = 352800,
  9158. },
  9159. .name = "TERT_TDM_TX_4",
  9160. .ops = &msm_dai_q6_tdm_ops,
  9161. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  9162. .probe = msm_dai_q6_dai_tdm_probe,
  9163. .remove = msm_dai_q6_dai_tdm_remove,
  9164. },
  9165. {
  9166. .capture = {
  9167. .stream_name = "Tertiary TDM5 Capture",
  9168. .aif_name = "TERT_TDM_TX_5",
  9169. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9170. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9171. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9172. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9173. SNDRV_PCM_FMTBIT_S24_LE |
  9174. SNDRV_PCM_FMTBIT_S32_LE,
  9175. .channels_min = 1,
  9176. .channels_max = 16,
  9177. .rate_min = 8000,
  9178. .rate_max = 352800,
  9179. },
  9180. .name = "TERT_TDM_TX_5",
  9181. .ops = &msm_dai_q6_tdm_ops,
  9182. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  9183. .probe = msm_dai_q6_dai_tdm_probe,
  9184. .remove = msm_dai_q6_dai_tdm_remove,
  9185. },
  9186. {
  9187. .capture = {
  9188. .stream_name = "Tertiary TDM6 Capture",
  9189. .aif_name = "TERT_TDM_TX_6",
  9190. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9191. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9192. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9193. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9194. SNDRV_PCM_FMTBIT_S24_LE |
  9195. SNDRV_PCM_FMTBIT_S32_LE,
  9196. .channels_min = 1,
  9197. .channels_max = 16,
  9198. .rate_min = 8000,
  9199. .rate_max = 352800,
  9200. },
  9201. .name = "TERT_TDM_TX_6",
  9202. .ops = &msm_dai_q6_tdm_ops,
  9203. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  9204. .probe = msm_dai_q6_dai_tdm_probe,
  9205. .remove = msm_dai_q6_dai_tdm_remove,
  9206. },
  9207. {
  9208. .capture = {
  9209. .stream_name = "Tertiary TDM7 Capture",
  9210. .aif_name = "TERT_TDM_TX_7",
  9211. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9212. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9213. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9214. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9215. SNDRV_PCM_FMTBIT_S24_LE |
  9216. SNDRV_PCM_FMTBIT_S32_LE,
  9217. .channels_min = 1,
  9218. .channels_max = 16,
  9219. .rate_min = 8000,
  9220. .rate_max = 352800,
  9221. },
  9222. .name = "TERT_TDM_TX_7",
  9223. .ops = &msm_dai_q6_tdm_ops,
  9224. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  9225. .probe = msm_dai_q6_dai_tdm_probe,
  9226. .remove = msm_dai_q6_dai_tdm_remove,
  9227. },
  9228. {
  9229. .playback = {
  9230. .stream_name = "Quaternary TDM0 Playback",
  9231. .aif_name = "QUAT_TDM_RX_0",
  9232. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9233. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9234. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9235. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9236. SNDRV_PCM_FMTBIT_S24_LE |
  9237. SNDRV_PCM_FMTBIT_S32_LE,
  9238. .channels_min = 1,
  9239. .channels_max = 16,
  9240. .rate_min = 8000,
  9241. .rate_max = 352800,
  9242. },
  9243. .name = "QUAT_TDM_RX_0",
  9244. .ops = &msm_dai_q6_tdm_ops,
  9245. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  9246. .probe = msm_dai_q6_dai_tdm_probe,
  9247. .remove = msm_dai_q6_dai_tdm_remove,
  9248. },
  9249. {
  9250. .playback = {
  9251. .stream_name = "Quaternary TDM1 Playback",
  9252. .aif_name = "QUAT_TDM_RX_1",
  9253. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9254. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9255. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9256. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9257. SNDRV_PCM_FMTBIT_S24_LE |
  9258. SNDRV_PCM_FMTBIT_S32_LE,
  9259. .channels_min = 1,
  9260. .channels_max = 16,
  9261. .rate_min = 8000,
  9262. .rate_max = 352800,
  9263. },
  9264. .name = "QUAT_TDM_RX_1",
  9265. .ops = &msm_dai_q6_tdm_ops,
  9266. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  9267. .probe = msm_dai_q6_dai_tdm_probe,
  9268. .remove = msm_dai_q6_dai_tdm_remove,
  9269. },
  9270. {
  9271. .playback = {
  9272. .stream_name = "Quaternary TDM2 Playback",
  9273. .aif_name = "QUAT_TDM_RX_2",
  9274. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9275. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9276. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9277. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9278. SNDRV_PCM_FMTBIT_S24_LE |
  9279. SNDRV_PCM_FMTBIT_S32_LE,
  9280. .channels_min = 1,
  9281. .channels_max = 16,
  9282. .rate_min = 8000,
  9283. .rate_max = 352800,
  9284. },
  9285. .name = "QUAT_TDM_RX_2",
  9286. .ops = &msm_dai_q6_tdm_ops,
  9287. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  9288. .probe = msm_dai_q6_dai_tdm_probe,
  9289. .remove = msm_dai_q6_dai_tdm_remove,
  9290. },
  9291. {
  9292. .playback = {
  9293. .stream_name = "Quaternary TDM3 Playback",
  9294. .aif_name = "QUAT_TDM_RX_3",
  9295. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9296. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9297. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9298. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9299. SNDRV_PCM_FMTBIT_S24_LE |
  9300. SNDRV_PCM_FMTBIT_S32_LE,
  9301. .channels_min = 1,
  9302. .channels_max = 16,
  9303. .rate_min = 8000,
  9304. .rate_max = 352800,
  9305. },
  9306. .name = "QUAT_TDM_RX_3",
  9307. .ops = &msm_dai_q6_tdm_ops,
  9308. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  9309. .probe = msm_dai_q6_dai_tdm_probe,
  9310. .remove = msm_dai_q6_dai_tdm_remove,
  9311. },
  9312. {
  9313. .playback = {
  9314. .stream_name = "Quaternary TDM4 Playback",
  9315. .aif_name = "QUAT_TDM_RX_4",
  9316. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9317. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9318. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9319. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9320. SNDRV_PCM_FMTBIT_S24_LE |
  9321. SNDRV_PCM_FMTBIT_S32_LE,
  9322. .channels_min = 1,
  9323. .channels_max = 16,
  9324. .rate_min = 8000,
  9325. .rate_max = 352800,
  9326. },
  9327. .name = "QUAT_TDM_RX_4",
  9328. .ops = &msm_dai_q6_tdm_ops,
  9329. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  9330. .probe = msm_dai_q6_dai_tdm_probe,
  9331. .remove = msm_dai_q6_dai_tdm_remove,
  9332. },
  9333. {
  9334. .playback = {
  9335. .stream_name = "Quaternary TDM5 Playback",
  9336. .aif_name = "QUAT_TDM_RX_5",
  9337. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9338. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9339. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9340. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9341. SNDRV_PCM_FMTBIT_S24_LE |
  9342. SNDRV_PCM_FMTBIT_S32_LE,
  9343. .channels_min = 1,
  9344. .channels_max = 16,
  9345. .rate_min = 8000,
  9346. .rate_max = 352800,
  9347. },
  9348. .name = "QUAT_TDM_RX_5",
  9349. .ops = &msm_dai_q6_tdm_ops,
  9350. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  9351. .probe = msm_dai_q6_dai_tdm_probe,
  9352. .remove = msm_dai_q6_dai_tdm_remove,
  9353. },
  9354. {
  9355. .playback = {
  9356. .stream_name = "Quaternary TDM6 Playback",
  9357. .aif_name = "QUAT_TDM_RX_6",
  9358. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9359. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9360. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9361. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9362. SNDRV_PCM_FMTBIT_S24_LE |
  9363. SNDRV_PCM_FMTBIT_S32_LE,
  9364. .channels_min = 1,
  9365. .channels_max = 16,
  9366. .rate_min = 8000,
  9367. .rate_max = 352800,
  9368. },
  9369. .name = "QUAT_TDM_RX_6",
  9370. .ops = &msm_dai_q6_tdm_ops,
  9371. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  9372. .probe = msm_dai_q6_dai_tdm_probe,
  9373. .remove = msm_dai_q6_dai_tdm_remove,
  9374. },
  9375. {
  9376. .playback = {
  9377. .stream_name = "Quaternary TDM7 Playback",
  9378. .aif_name = "QUAT_TDM_RX_7",
  9379. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9380. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9381. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9382. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9383. SNDRV_PCM_FMTBIT_S24_LE |
  9384. SNDRV_PCM_FMTBIT_S32_LE,
  9385. .channels_min = 1,
  9386. .channels_max = 16,
  9387. .rate_min = 8000,
  9388. .rate_max = 352800,
  9389. },
  9390. .name = "QUAT_TDM_RX_7",
  9391. .ops = &msm_dai_q6_tdm_ops,
  9392. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  9393. .probe = msm_dai_q6_dai_tdm_probe,
  9394. .remove = msm_dai_q6_dai_tdm_remove,
  9395. },
  9396. {
  9397. .capture = {
  9398. .stream_name = "Quaternary TDM0 Capture",
  9399. .aif_name = "QUAT_TDM_TX_0",
  9400. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9401. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9402. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9403. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9404. SNDRV_PCM_FMTBIT_S24_LE |
  9405. SNDRV_PCM_FMTBIT_S32_LE,
  9406. .channels_min = 1,
  9407. .channels_max = 16,
  9408. .rate_min = 8000,
  9409. .rate_max = 352800,
  9410. },
  9411. .name = "QUAT_TDM_TX_0",
  9412. .ops = &msm_dai_q6_tdm_ops,
  9413. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  9414. .probe = msm_dai_q6_dai_tdm_probe,
  9415. .remove = msm_dai_q6_dai_tdm_remove,
  9416. },
  9417. {
  9418. .capture = {
  9419. .stream_name = "Quaternary TDM1 Capture",
  9420. .aif_name = "QUAT_TDM_TX_1",
  9421. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9422. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9423. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9424. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9425. SNDRV_PCM_FMTBIT_S24_LE |
  9426. SNDRV_PCM_FMTBIT_S32_LE,
  9427. .channels_min = 1,
  9428. .channels_max = 16,
  9429. .rate_min = 8000,
  9430. .rate_max = 352800,
  9431. },
  9432. .name = "QUAT_TDM_TX_1",
  9433. .ops = &msm_dai_q6_tdm_ops,
  9434. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  9435. .probe = msm_dai_q6_dai_tdm_probe,
  9436. .remove = msm_dai_q6_dai_tdm_remove,
  9437. },
  9438. {
  9439. .capture = {
  9440. .stream_name = "Quaternary TDM2 Capture",
  9441. .aif_name = "QUAT_TDM_TX_2",
  9442. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9443. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9444. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9445. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9446. SNDRV_PCM_FMTBIT_S24_LE |
  9447. SNDRV_PCM_FMTBIT_S32_LE,
  9448. .channels_min = 1,
  9449. .channels_max = 16,
  9450. .rate_min = 8000,
  9451. .rate_max = 352800,
  9452. },
  9453. .name = "QUAT_TDM_TX_2",
  9454. .ops = &msm_dai_q6_tdm_ops,
  9455. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  9456. .probe = msm_dai_q6_dai_tdm_probe,
  9457. .remove = msm_dai_q6_dai_tdm_remove,
  9458. },
  9459. {
  9460. .capture = {
  9461. .stream_name = "Quaternary TDM3 Capture",
  9462. .aif_name = "QUAT_TDM_TX_3",
  9463. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9464. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9465. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9466. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9467. SNDRV_PCM_FMTBIT_S24_LE |
  9468. SNDRV_PCM_FMTBIT_S32_LE,
  9469. .channels_min = 1,
  9470. .channels_max = 16,
  9471. .rate_min = 8000,
  9472. .rate_max = 352800,
  9473. },
  9474. .name = "QUAT_TDM_TX_3",
  9475. .ops = &msm_dai_q6_tdm_ops,
  9476. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  9477. .probe = msm_dai_q6_dai_tdm_probe,
  9478. .remove = msm_dai_q6_dai_tdm_remove,
  9479. },
  9480. {
  9481. .capture = {
  9482. .stream_name = "Quaternary TDM4 Capture",
  9483. .aif_name = "QUAT_TDM_TX_4",
  9484. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9485. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9486. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9487. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9488. SNDRV_PCM_FMTBIT_S24_LE |
  9489. SNDRV_PCM_FMTBIT_S32_LE,
  9490. .channels_min = 1,
  9491. .channels_max = 16,
  9492. .rate_min = 8000,
  9493. .rate_max = 352800,
  9494. },
  9495. .name = "QUAT_TDM_TX_4",
  9496. .ops = &msm_dai_q6_tdm_ops,
  9497. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  9498. .probe = msm_dai_q6_dai_tdm_probe,
  9499. .remove = msm_dai_q6_dai_tdm_remove,
  9500. },
  9501. {
  9502. .capture = {
  9503. .stream_name = "Quaternary TDM5 Capture",
  9504. .aif_name = "QUAT_TDM_TX_5",
  9505. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9506. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9507. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9508. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9509. SNDRV_PCM_FMTBIT_S24_LE |
  9510. SNDRV_PCM_FMTBIT_S32_LE,
  9511. .channels_min = 1,
  9512. .channels_max = 16,
  9513. .rate_min = 8000,
  9514. .rate_max = 352800,
  9515. },
  9516. .name = "QUAT_TDM_TX_5",
  9517. .ops = &msm_dai_q6_tdm_ops,
  9518. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  9519. .probe = msm_dai_q6_dai_tdm_probe,
  9520. .remove = msm_dai_q6_dai_tdm_remove,
  9521. },
  9522. {
  9523. .capture = {
  9524. .stream_name = "Quaternary TDM6 Capture",
  9525. .aif_name = "QUAT_TDM_TX_6",
  9526. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9527. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9528. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9529. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9530. SNDRV_PCM_FMTBIT_S24_LE |
  9531. SNDRV_PCM_FMTBIT_S32_LE,
  9532. .channels_min = 1,
  9533. .channels_max = 16,
  9534. .rate_min = 8000,
  9535. .rate_max = 352800,
  9536. },
  9537. .name = "QUAT_TDM_TX_6",
  9538. .ops = &msm_dai_q6_tdm_ops,
  9539. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  9540. .probe = msm_dai_q6_dai_tdm_probe,
  9541. .remove = msm_dai_q6_dai_tdm_remove,
  9542. },
  9543. {
  9544. .capture = {
  9545. .stream_name = "Quaternary TDM7 Capture",
  9546. .aif_name = "QUAT_TDM_TX_7",
  9547. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9548. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9549. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9550. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9551. SNDRV_PCM_FMTBIT_S24_LE |
  9552. SNDRV_PCM_FMTBIT_S32_LE,
  9553. .channels_min = 1,
  9554. .channels_max = 16,
  9555. .rate_min = 8000,
  9556. .rate_max = 352800,
  9557. },
  9558. .name = "QUAT_TDM_TX_7",
  9559. .ops = &msm_dai_q6_tdm_ops,
  9560. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  9561. .probe = msm_dai_q6_dai_tdm_probe,
  9562. .remove = msm_dai_q6_dai_tdm_remove,
  9563. },
  9564. {
  9565. .playback = {
  9566. .stream_name = "Quinary TDM0 Playback",
  9567. .aif_name = "QUIN_TDM_RX_0",
  9568. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9569. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9570. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9571. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9572. SNDRV_PCM_FMTBIT_S24_LE |
  9573. SNDRV_PCM_FMTBIT_S32_LE,
  9574. .channels_min = 1,
  9575. .channels_max = 16,
  9576. .rate_min = 8000,
  9577. .rate_max = 352800,
  9578. },
  9579. .name = "QUIN_TDM_RX_0",
  9580. .ops = &msm_dai_q6_tdm_ops,
  9581. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  9582. .probe = msm_dai_q6_dai_tdm_probe,
  9583. .remove = msm_dai_q6_dai_tdm_remove,
  9584. },
  9585. {
  9586. .playback = {
  9587. .stream_name = "Quinary TDM1 Playback",
  9588. .aif_name = "QUIN_TDM_RX_1",
  9589. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9590. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9591. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9592. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9593. SNDRV_PCM_FMTBIT_S24_LE |
  9594. SNDRV_PCM_FMTBIT_S32_LE,
  9595. .channels_min = 1,
  9596. .channels_max = 16,
  9597. .rate_min = 8000,
  9598. .rate_max = 352800,
  9599. },
  9600. .name = "QUIN_TDM_RX_1",
  9601. .ops = &msm_dai_q6_tdm_ops,
  9602. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  9603. .probe = msm_dai_q6_dai_tdm_probe,
  9604. .remove = msm_dai_q6_dai_tdm_remove,
  9605. },
  9606. {
  9607. .playback = {
  9608. .stream_name = "Quinary TDM2 Playback",
  9609. .aif_name = "QUIN_TDM_RX_2",
  9610. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9611. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9612. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9613. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9614. SNDRV_PCM_FMTBIT_S24_LE |
  9615. SNDRV_PCM_FMTBIT_S32_LE,
  9616. .channels_min = 1,
  9617. .channels_max = 16,
  9618. .rate_min = 8000,
  9619. .rate_max = 352800,
  9620. },
  9621. .name = "QUIN_TDM_RX_2",
  9622. .ops = &msm_dai_q6_tdm_ops,
  9623. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  9624. .probe = msm_dai_q6_dai_tdm_probe,
  9625. .remove = msm_dai_q6_dai_tdm_remove,
  9626. },
  9627. {
  9628. .playback = {
  9629. .stream_name = "Quinary TDM3 Playback",
  9630. .aif_name = "QUIN_TDM_RX_3",
  9631. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9632. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9633. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9634. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9635. SNDRV_PCM_FMTBIT_S24_LE |
  9636. SNDRV_PCM_FMTBIT_S32_LE,
  9637. .channels_min = 1,
  9638. .channels_max = 16,
  9639. .rate_min = 8000,
  9640. .rate_max = 352800,
  9641. },
  9642. .name = "QUIN_TDM_RX_3",
  9643. .ops = &msm_dai_q6_tdm_ops,
  9644. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  9645. .probe = msm_dai_q6_dai_tdm_probe,
  9646. .remove = msm_dai_q6_dai_tdm_remove,
  9647. },
  9648. {
  9649. .playback = {
  9650. .stream_name = "Quinary TDM4 Playback",
  9651. .aif_name = "QUIN_TDM_RX_4",
  9652. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9653. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9654. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9655. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9656. SNDRV_PCM_FMTBIT_S24_LE |
  9657. SNDRV_PCM_FMTBIT_S32_LE,
  9658. .channels_min = 1,
  9659. .channels_max = 16,
  9660. .rate_min = 8000,
  9661. .rate_max = 352800,
  9662. },
  9663. .name = "QUIN_TDM_RX_4",
  9664. .ops = &msm_dai_q6_tdm_ops,
  9665. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  9666. .probe = msm_dai_q6_dai_tdm_probe,
  9667. .remove = msm_dai_q6_dai_tdm_remove,
  9668. },
  9669. {
  9670. .playback = {
  9671. .stream_name = "Quinary TDM5 Playback",
  9672. .aif_name = "QUIN_TDM_RX_5",
  9673. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9674. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9675. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9676. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9677. SNDRV_PCM_FMTBIT_S24_LE |
  9678. SNDRV_PCM_FMTBIT_S32_LE,
  9679. .channels_min = 1,
  9680. .channels_max = 16,
  9681. .rate_min = 8000,
  9682. .rate_max = 352800,
  9683. },
  9684. .name = "QUIN_TDM_RX_5",
  9685. .ops = &msm_dai_q6_tdm_ops,
  9686. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  9687. .probe = msm_dai_q6_dai_tdm_probe,
  9688. .remove = msm_dai_q6_dai_tdm_remove,
  9689. },
  9690. {
  9691. .playback = {
  9692. .stream_name = "Quinary TDM6 Playback",
  9693. .aif_name = "QUIN_TDM_RX_6",
  9694. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9695. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9696. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9697. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9698. SNDRV_PCM_FMTBIT_S24_LE |
  9699. SNDRV_PCM_FMTBIT_S32_LE,
  9700. .channels_min = 1,
  9701. .channels_max = 16,
  9702. .rate_min = 8000,
  9703. .rate_max = 352800,
  9704. },
  9705. .name = "QUIN_TDM_RX_6",
  9706. .ops = &msm_dai_q6_tdm_ops,
  9707. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  9708. .probe = msm_dai_q6_dai_tdm_probe,
  9709. .remove = msm_dai_q6_dai_tdm_remove,
  9710. },
  9711. {
  9712. .playback = {
  9713. .stream_name = "Quinary TDM7 Playback",
  9714. .aif_name = "QUIN_TDM_RX_7",
  9715. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9716. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9717. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9718. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9719. SNDRV_PCM_FMTBIT_S24_LE |
  9720. SNDRV_PCM_FMTBIT_S32_LE,
  9721. .channels_min = 1,
  9722. .channels_max = 16,
  9723. .rate_min = 8000,
  9724. .rate_max = 352800,
  9725. },
  9726. .name = "QUIN_TDM_RX_7",
  9727. .ops = &msm_dai_q6_tdm_ops,
  9728. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  9729. .probe = msm_dai_q6_dai_tdm_probe,
  9730. .remove = msm_dai_q6_dai_tdm_remove,
  9731. },
  9732. {
  9733. .capture = {
  9734. .stream_name = "Quinary TDM0 Capture",
  9735. .aif_name = "QUIN_TDM_TX_0",
  9736. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9737. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9738. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9739. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9740. SNDRV_PCM_FMTBIT_S24_LE |
  9741. SNDRV_PCM_FMTBIT_S32_LE,
  9742. .channels_min = 1,
  9743. .channels_max = 16,
  9744. .rate_min = 8000,
  9745. .rate_max = 352800,
  9746. },
  9747. .name = "QUIN_TDM_TX_0",
  9748. .ops = &msm_dai_q6_tdm_ops,
  9749. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  9750. .probe = msm_dai_q6_dai_tdm_probe,
  9751. .remove = msm_dai_q6_dai_tdm_remove,
  9752. },
  9753. {
  9754. .capture = {
  9755. .stream_name = "Quinary TDM1 Capture",
  9756. .aif_name = "QUIN_TDM_TX_1",
  9757. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9758. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9759. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9760. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9761. SNDRV_PCM_FMTBIT_S24_LE |
  9762. SNDRV_PCM_FMTBIT_S32_LE,
  9763. .channels_min = 1,
  9764. .channels_max = 16,
  9765. .rate_min = 8000,
  9766. .rate_max = 352800,
  9767. },
  9768. .name = "QUIN_TDM_TX_1",
  9769. .ops = &msm_dai_q6_tdm_ops,
  9770. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  9771. .probe = msm_dai_q6_dai_tdm_probe,
  9772. .remove = msm_dai_q6_dai_tdm_remove,
  9773. },
  9774. {
  9775. .capture = {
  9776. .stream_name = "Quinary TDM2 Capture",
  9777. .aif_name = "QUIN_TDM_TX_2",
  9778. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9779. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9780. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9781. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9782. SNDRV_PCM_FMTBIT_S24_LE |
  9783. SNDRV_PCM_FMTBIT_S32_LE,
  9784. .channels_min = 1,
  9785. .channels_max = 16,
  9786. .rate_min = 8000,
  9787. .rate_max = 352800,
  9788. },
  9789. .name = "QUIN_TDM_TX_2",
  9790. .ops = &msm_dai_q6_tdm_ops,
  9791. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  9792. .probe = msm_dai_q6_dai_tdm_probe,
  9793. .remove = msm_dai_q6_dai_tdm_remove,
  9794. },
  9795. {
  9796. .capture = {
  9797. .stream_name = "Quinary TDM3 Capture",
  9798. .aif_name = "QUIN_TDM_TX_3",
  9799. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9800. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9801. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9802. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9803. SNDRV_PCM_FMTBIT_S24_LE |
  9804. SNDRV_PCM_FMTBIT_S32_LE,
  9805. .channels_min = 1,
  9806. .channels_max = 16,
  9807. .rate_min = 8000,
  9808. .rate_max = 352800,
  9809. },
  9810. .name = "QUIN_TDM_TX_3",
  9811. .ops = &msm_dai_q6_tdm_ops,
  9812. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  9813. .probe = msm_dai_q6_dai_tdm_probe,
  9814. .remove = msm_dai_q6_dai_tdm_remove,
  9815. },
  9816. {
  9817. .capture = {
  9818. .stream_name = "Quinary TDM4 Capture",
  9819. .aif_name = "QUIN_TDM_TX_4",
  9820. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9821. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9822. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9824. SNDRV_PCM_FMTBIT_S24_LE |
  9825. SNDRV_PCM_FMTBIT_S32_LE,
  9826. .channels_min = 1,
  9827. .channels_max = 16,
  9828. .rate_min = 8000,
  9829. .rate_max = 352800,
  9830. },
  9831. .name = "QUIN_TDM_TX_4",
  9832. .ops = &msm_dai_q6_tdm_ops,
  9833. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  9834. .probe = msm_dai_q6_dai_tdm_probe,
  9835. .remove = msm_dai_q6_dai_tdm_remove,
  9836. },
  9837. {
  9838. .capture = {
  9839. .stream_name = "Quinary TDM5 Capture",
  9840. .aif_name = "QUIN_TDM_TX_5",
  9841. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9842. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9843. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9844. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9845. SNDRV_PCM_FMTBIT_S24_LE |
  9846. SNDRV_PCM_FMTBIT_S32_LE,
  9847. .channels_min = 1,
  9848. .channels_max = 16,
  9849. .rate_min = 8000,
  9850. .rate_max = 352800,
  9851. },
  9852. .name = "QUIN_TDM_TX_5",
  9853. .ops = &msm_dai_q6_tdm_ops,
  9854. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  9855. .probe = msm_dai_q6_dai_tdm_probe,
  9856. .remove = msm_dai_q6_dai_tdm_remove,
  9857. },
  9858. {
  9859. .capture = {
  9860. .stream_name = "Quinary TDM6 Capture",
  9861. .aif_name = "QUIN_TDM_TX_6",
  9862. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9863. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9864. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9865. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9866. SNDRV_PCM_FMTBIT_S24_LE |
  9867. SNDRV_PCM_FMTBIT_S32_LE,
  9868. .channels_min = 1,
  9869. .channels_max = 16,
  9870. .rate_min = 8000,
  9871. .rate_max = 352800,
  9872. },
  9873. .name = "QUIN_TDM_TX_6",
  9874. .ops = &msm_dai_q6_tdm_ops,
  9875. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  9876. .probe = msm_dai_q6_dai_tdm_probe,
  9877. .remove = msm_dai_q6_dai_tdm_remove,
  9878. },
  9879. {
  9880. .capture = {
  9881. .stream_name = "Quinary TDM7 Capture",
  9882. .aif_name = "QUIN_TDM_TX_7",
  9883. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9884. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9885. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9886. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9887. SNDRV_PCM_FMTBIT_S24_LE |
  9888. SNDRV_PCM_FMTBIT_S32_LE,
  9889. .channels_min = 1,
  9890. .channels_max = 16,
  9891. .rate_min = 8000,
  9892. .rate_max = 352800,
  9893. },
  9894. .name = "QUIN_TDM_TX_7",
  9895. .ops = &msm_dai_q6_tdm_ops,
  9896. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  9897. .probe = msm_dai_q6_dai_tdm_probe,
  9898. .remove = msm_dai_q6_dai_tdm_remove,
  9899. },
  9900. {
  9901. .playback = {
  9902. .stream_name = "Senary TDM0 Playback",
  9903. .aif_name = "SEN_TDM_RX_0",
  9904. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9905. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9906. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9907. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9908. SNDRV_PCM_FMTBIT_S24_LE |
  9909. SNDRV_PCM_FMTBIT_S32_LE,
  9910. .channels_min = 1,
  9911. .channels_max = 8,
  9912. .rate_min = 8000,
  9913. .rate_max = 352800,
  9914. },
  9915. .name = "SEN_TDM_RX_0",
  9916. .ops = &msm_dai_q6_tdm_ops,
  9917. .id = AFE_PORT_ID_SENARY_TDM_RX,
  9918. .probe = msm_dai_q6_dai_tdm_probe,
  9919. .remove = msm_dai_q6_dai_tdm_remove,
  9920. },
  9921. {
  9922. .playback = {
  9923. .stream_name = "Senary TDM1 Playback",
  9924. .aif_name = "SEN_TDM_RX_1",
  9925. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9926. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9927. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9928. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9929. SNDRV_PCM_FMTBIT_S24_LE |
  9930. SNDRV_PCM_FMTBIT_S32_LE,
  9931. .channels_min = 1,
  9932. .channels_max = 8,
  9933. .rate_min = 8000,
  9934. .rate_max = 352800,
  9935. },
  9936. .name = "SEN_TDM_RX_1",
  9937. .ops = &msm_dai_q6_tdm_ops,
  9938. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  9939. .probe = msm_dai_q6_dai_tdm_probe,
  9940. .remove = msm_dai_q6_dai_tdm_remove,
  9941. },
  9942. {
  9943. .playback = {
  9944. .stream_name = "Senary TDM2 Playback",
  9945. .aif_name = "SEN_TDM_RX_2",
  9946. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9947. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9948. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9949. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9950. SNDRV_PCM_FMTBIT_S24_LE |
  9951. SNDRV_PCM_FMTBIT_S32_LE,
  9952. .channels_min = 1,
  9953. .channels_max = 8,
  9954. .rate_min = 8000,
  9955. .rate_max = 352800,
  9956. },
  9957. .name = "SEN_TDM_RX_2",
  9958. .ops = &msm_dai_q6_tdm_ops,
  9959. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  9960. .probe = msm_dai_q6_dai_tdm_probe,
  9961. .remove = msm_dai_q6_dai_tdm_remove,
  9962. },
  9963. {
  9964. .playback = {
  9965. .stream_name = "Senary TDM3 Playback",
  9966. .aif_name = "SEN_TDM_RX_3",
  9967. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9968. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9969. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9970. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9971. SNDRV_PCM_FMTBIT_S24_LE |
  9972. SNDRV_PCM_FMTBIT_S32_LE,
  9973. .channels_min = 1,
  9974. .channels_max = 8,
  9975. .rate_min = 8000,
  9976. .rate_max = 352800,
  9977. },
  9978. .name = "SEN_TDM_RX_3",
  9979. .ops = &msm_dai_q6_tdm_ops,
  9980. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  9981. .probe = msm_dai_q6_dai_tdm_probe,
  9982. .remove = msm_dai_q6_dai_tdm_remove,
  9983. },
  9984. {
  9985. .playback = {
  9986. .stream_name = "Senary TDM4 Playback",
  9987. .aif_name = "SEN_TDM_RX_4",
  9988. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9989. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9990. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9991. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9992. SNDRV_PCM_FMTBIT_S24_LE |
  9993. SNDRV_PCM_FMTBIT_S32_LE,
  9994. .channels_min = 1,
  9995. .channels_max = 8,
  9996. .rate_min = 8000,
  9997. .rate_max = 352800,
  9998. },
  9999. .name = "SEN_TDM_RX_4",
  10000. .ops = &msm_dai_q6_tdm_ops,
  10001. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  10002. .probe = msm_dai_q6_dai_tdm_probe,
  10003. .remove = msm_dai_q6_dai_tdm_remove,
  10004. },
  10005. {
  10006. .playback = {
  10007. .stream_name = "Senary TDM5 Playback",
  10008. .aif_name = "SEN_TDM_RX_5",
  10009. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10010. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10011. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10012. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10013. SNDRV_PCM_FMTBIT_S24_LE |
  10014. SNDRV_PCM_FMTBIT_S32_LE,
  10015. .channels_min = 1,
  10016. .channels_max = 8,
  10017. .rate_min = 8000,
  10018. .rate_max = 352800,
  10019. },
  10020. .name = "SEN_TDM_RX_5",
  10021. .ops = &msm_dai_q6_tdm_ops,
  10022. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  10023. .probe = msm_dai_q6_dai_tdm_probe,
  10024. .remove = msm_dai_q6_dai_tdm_remove,
  10025. },
  10026. {
  10027. .playback = {
  10028. .stream_name = "Senary TDM6 Playback",
  10029. .aif_name = "SEN_TDM_RX_6",
  10030. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10031. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10032. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10033. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10034. SNDRV_PCM_FMTBIT_S24_LE |
  10035. SNDRV_PCM_FMTBIT_S32_LE,
  10036. .channels_min = 1,
  10037. .channels_max = 8,
  10038. .rate_min = 8000,
  10039. .rate_max = 352800,
  10040. },
  10041. .name = "SEN_TDM_RX_6",
  10042. .ops = &msm_dai_q6_tdm_ops,
  10043. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  10044. .probe = msm_dai_q6_dai_tdm_probe,
  10045. .remove = msm_dai_q6_dai_tdm_remove,
  10046. },
  10047. {
  10048. .playback = {
  10049. .stream_name = "Senary TDM7 Playback",
  10050. .aif_name = "SEN_TDM_RX_7",
  10051. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10052. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10053. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10054. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10055. SNDRV_PCM_FMTBIT_S24_LE |
  10056. SNDRV_PCM_FMTBIT_S32_LE,
  10057. .channels_min = 1,
  10058. .channels_max = 8,
  10059. .rate_min = 8000,
  10060. .rate_max = 352800,
  10061. },
  10062. .name = "SEN_TDM_RX_7",
  10063. .ops = &msm_dai_q6_tdm_ops,
  10064. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  10065. .probe = msm_dai_q6_dai_tdm_probe,
  10066. .remove = msm_dai_q6_dai_tdm_remove,
  10067. },
  10068. {
  10069. .capture = {
  10070. .stream_name = "Senary TDM0 Capture",
  10071. .aif_name = "SEN_TDM_TX_0",
  10072. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10073. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10074. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10075. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10076. SNDRV_PCM_FMTBIT_S24_LE |
  10077. SNDRV_PCM_FMTBIT_S32_LE,
  10078. .channels_min = 1,
  10079. .channels_max = 8,
  10080. .rate_min = 8000,
  10081. .rate_max = 352800,
  10082. },
  10083. .name = "SEN_TDM_TX_0",
  10084. .ops = &msm_dai_q6_tdm_ops,
  10085. .id = AFE_PORT_ID_SENARY_TDM_TX,
  10086. .probe = msm_dai_q6_dai_tdm_probe,
  10087. .remove = msm_dai_q6_dai_tdm_remove,
  10088. },
  10089. {
  10090. .capture = {
  10091. .stream_name = "Senary TDM1 Capture",
  10092. .aif_name = "SEN_TDM_TX_1",
  10093. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10094. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10095. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10096. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10097. SNDRV_PCM_FMTBIT_S24_LE |
  10098. SNDRV_PCM_FMTBIT_S32_LE,
  10099. .channels_min = 1,
  10100. .channels_max = 8,
  10101. .rate_min = 8000,
  10102. .rate_max = 352800,
  10103. },
  10104. .name = "SEN_TDM_TX_1",
  10105. .ops = &msm_dai_q6_tdm_ops,
  10106. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  10107. .probe = msm_dai_q6_dai_tdm_probe,
  10108. .remove = msm_dai_q6_dai_tdm_remove,
  10109. },
  10110. {
  10111. .capture = {
  10112. .stream_name = "Senary TDM2 Capture",
  10113. .aif_name = "SEN_TDM_TX_2",
  10114. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10115. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10116. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10117. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10118. SNDRV_PCM_FMTBIT_S24_LE |
  10119. SNDRV_PCM_FMTBIT_S32_LE,
  10120. .channels_min = 1,
  10121. .channels_max = 8,
  10122. .rate_min = 8000,
  10123. .rate_max = 352800,
  10124. },
  10125. .name = "SEN_TDM_TX_2",
  10126. .ops = &msm_dai_q6_tdm_ops,
  10127. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  10128. .probe = msm_dai_q6_dai_tdm_probe,
  10129. .remove = msm_dai_q6_dai_tdm_remove,
  10130. },
  10131. {
  10132. .capture = {
  10133. .stream_name = "Senary TDM3 Capture",
  10134. .aif_name = "SEN_TDM_TX_3",
  10135. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10136. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10137. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10138. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10139. SNDRV_PCM_FMTBIT_S24_LE |
  10140. SNDRV_PCM_FMTBIT_S32_LE,
  10141. .channels_min = 1,
  10142. .channels_max = 8,
  10143. .rate_min = 8000,
  10144. .rate_max = 352800,
  10145. },
  10146. .name = "SEN_TDM_TX_3",
  10147. .ops = &msm_dai_q6_tdm_ops,
  10148. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  10149. .probe = msm_dai_q6_dai_tdm_probe,
  10150. .remove = msm_dai_q6_dai_tdm_remove,
  10151. },
  10152. {
  10153. .capture = {
  10154. .stream_name = "Senary TDM4 Capture",
  10155. .aif_name = "SEN_TDM_TX_4",
  10156. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10157. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10158. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10159. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10160. SNDRV_PCM_FMTBIT_S24_LE |
  10161. SNDRV_PCM_FMTBIT_S32_LE,
  10162. .channels_min = 1,
  10163. .channels_max = 8,
  10164. .rate_min = 8000,
  10165. .rate_max = 352800,
  10166. },
  10167. .name = "SEN_TDM_TX_4",
  10168. .ops = &msm_dai_q6_tdm_ops,
  10169. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  10170. .probe = msm_dai_q6_dai_tdm_probe,
  10171. .remove = msm_dai_q6_dai_tdm_remove,
  10172. },
  10173. {
  10174. .capture = {
  10175. .stream_name = "Senary TDM5 Capture",
  10176. .aif_name = "SEN_TDM_TX_5",
  10177. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10178. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10179. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10180. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10181. SNDRV_PCM_FMTBIT_S24_LE |
  10182. SNDRV_PCM_FMTBIT_S32_LE,
  10183. .channels_min = 1,
  10184. .channels_max = 8,
  10185. .rate_min = 8000,
  10186. .rate_max = 352800,
  10187. },
  10188. .name = "SEN_TDM_TX_5",
  10189. .ops = &msm_dai_q6_tdm_ops,
  10190. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  10191. .probe = msm_dai_q6_dai_tdm_probe,
  10192. .remove = msm_dai_q6_dai_tdm_remove,
  10193. },
  10194. {
  10195. .capture = {
  10196. .stream_name = "Senary TDM6 Capture",
  10197. .aif_name = "SEN_TDM_TX_6",
  10198. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10199. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10200. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10201. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10202. SNDRV_PCM_FMTBIT_S24_LE |
  10203. SNDRV_PCM_FMTBIT_S32_LE,
  10204. .channels_min = 1,
  10205. .channels_max = 8,
  10206. .rate_min = 8000,
  10207. .rate_max = 352800,
  10208. },
  10209. .name = "SEN_TDM_TX_6",
  10210. .ops = &msm_dai_q6_tdm_ops,
  10211. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  10212. .probe = msm_dai_q6_dai_tdm_probe,
  10213. .remove = msm_dai_q6_dai_tdm_remove,
  10214. },
  10215. {
  10216. .capture = {
  10217. .stream_name = "Senary TDM7 Capture",
  10218. .aif_name = "SEN_TDM_TX_7",
  10219. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10220. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10221. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10222. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10223. SNDRV_PCM_FMTBIT_S24_LE |
  10224. SNDRV_PCM_FMTBIT_S32_LE,
  10225. .channels_min = 1,
  10226. .channels_max = 8,
  10227. .rate_min = 8000,
  10228. .rate_max = 352800,
  10229. },
  10230. .name = "SEN_TDM_TX_7",
  10231. .ops = &msm_dai_q6_tdm_ops,
  10232. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  10233. .probe = msm_dai_q6_dai_tdm_probe,
  10234. .remove = msm_dai_q6_dai_tdm_remove,
  10235. },
  10236. };
  10237. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  10238. .name = "msm-dai-q6-tdm",
  10239. };
  10240. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  10241. {
  10242. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  10243. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  10244. int rc = 0;
  10245. u32 tdm_dev_id = 0;
  10246. int port_idx = 0;
  10247. struct device_node *tdm_parent_node = NULL;
  10248. /* retrieve device/afe id */
  10249. rc = of_property_read_u32(pdev->dev.of_node,
  10250. "qcom,msm-cpudai-tdm-dev-id",
  10251. &tdm_dev_id);
  10252. if (rc) {
  10253. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  10254. __func__);
  10255. goto rtn;
  10256. }
  10257. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  10258. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  10259. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  10260. __func__, tdm_dev_id);
  10261. rc = -ENXIO;
  10262. goto rtn;
  10263. }
  10264. pdev->id = tdm_dev_id;
  10265. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  10266. GFP_KERNEL);
  10267. if (!dai_data) {
  10268. rc = -ENOMEM;
  10269. dev_err(&pdev->dev,
  10270. "%s Failed to allocate memory for tdm dai_data\n",
  10271. __func__);
  10272. goto rtn;
  10273. }
  10274. memset(dai_data, 0, sizeof(*dai_data));
  10275. rc = of_property_read_u32(pdev->dev.of_node,
  10276. "qcom,msm-dai-is-island-supported",
  10277. &dai_data->is_island_dai);
  10278. if (rc)
  10279. dev_dbg(&pdev->dev, "island supported entry not found\n");
  10280. /* TDM CFG */
  10281. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  10282. rc = of_property_read_u32(tdm_parent_node,
  10283. "qcom,msm-cpudai-tdm-sync-mode",
  10284. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  10285. if (rc) {
  10286. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  10287. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  10288. goto free_dai_data;
  10289. }
  10290. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  10291. __func__, dai_data->port_cfg.tdm.sync_mode);
  10292. rc = of_property_read_u32(tdm_parent_node,
  10293. "qcom,msm-cpudai-tdm-sync-src",
  10294. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  10295. if (rc) {
  10296. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  10297. __func__, "qcom,msm-cpudai-tdm-sync-src");
  10298. goto free_dai_data;
  10299. }
  10300. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  10301. __func__, dai_data->port_cfg.tdm.sync_src);
  10302. rc = of_property_read_u32(tdm_parent_node,
  10303. "qcom,msm-cpudai-tdm-data-out",
  10304. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  10305. if (rc) {
  10306. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  10307. __func__, "qcom,msm-cpudai-tdm-data-out");
  10308. goto free_dai_data;
  10309. }
  10310. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  10311. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  10312. rc = of_property_read_u32(tdm_parent_node,
  10313. "qcom,msm-cpudai-tdm-invert-sync",
  10314. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  10315. if (rc) {
  10316. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  10317. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  10318. goto free_dai_data;
  10319. }
  10320. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  10321. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  10322. rc = of_property_read_u32(tdm_parent_node,
  10323. "qcom,msm-cpudai-tdm-data-delay",
  10324. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  10325. if (rc) {
  10326. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  10327. __func__, "qcom,msm-cpudai-tdm-data-delay");
  10328. goto free_dai_data;
  10329. }
  10330. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  10331. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  10332. /* TDM CFG -- set default */
  10333. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  10334. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  10335. AFE_API_VERSION_TDM_CONFIG;
  10336. /* TDM SLOT MAPPING CFG */
  10337. rc = of_property_read_u32(pdev->dev.of_node,
  10338. "qcom,msm-cpudai-tdm-data-align",
  10339. &dai_data->port_cfg.slot_mapping.data_align_type);
  10340. if (rc) {
  10341. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  10342. __func__,
  10343. "qcom,msm-cpudai-tdm-data-align");
  10344. goto free_dai_data;
  10345. }
  10346. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  10347. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  10348. /* TDM SLOT MAPPING CFG -- set default */
  10349. dai_data->port_cfg.slot_mapping.minor_version =
  10350. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  10351. dai_data->port_cfg.slot_mapping_v2.minor_version =
  10352. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  10353. /* CUSTOM TDM HEADER CFG */
  10354. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  10355. if (of_find_property(pdev->dev.of_node,
  10356. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  10357. of_find_property(pdev->dev.of_node,
  10358. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  10359. of_find_property(pdev->dev.of_node,
  10360. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  10361. /* if the property exist */
  10362. rc = of_property_read_u32(pdev->dev.of_node,
  10363. "qcom,msm-cpudai-tdm-header-start-offset",
  10364. (u32 *)&custom_tdm_header->start_offset);
  10365. if (rc) {
  10366. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  10367. __func__,
  10368. "qcom,msm-cpudai-tdm-header-start-offset");
  10369. goto free_dai_data;
  10370. }
  10371. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  10372. __func__, custom_tdm_header->start_offset);
  10373. rc = of_property_read_u32(pdev->dev.of_node,
  10374. "qcom,msm-cpudai-tdm-header-width",
  10375. (u32 *)&custom_tdm_header->header_width);
  10376. if (rc) {
  10377. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  10378. __func__, "qcom,msm-cpudai-tdm-header-width");
  10379. goto free_dai_data;
  10380. }
  10381. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  10382. __func__, custom_tdm_header->header_width);
  10383. rc = of_property_read_u32(pdev->dev.of_node,
  10384. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  10385. (u32 *)&custom_tdm_header->num_frame_repeat);
  10386. if (rc) {
  10387. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  10388. __func__,
  10389. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  10390. goto free_dai_data;
  10391. }
  10392. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  10393. __func__, custom_tdm_header->num_frame_repeat);
  10394. /* CUSTOM TDM HEADER CFG -- set default */
  10395. custom_tdm_header->minor_version =
  10396. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  10397. custom_tdm_header->header_type =
  10398. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  10399. } else {
  10400. /* CUSTOM TDM HEADER CFG -- set default */
  10401. custom_tdm_header->header_type =
  10402. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  10403. /* proceed with probe */
  10404. }
  10405. /* copy static clk per parent node */
  10406. dai_data->clk_set = tdm_clk_set;
  10407. /* copy static group cfg per parent node */
  10408. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  10409. /* copy static num group ports per parent node */
  10410. dai_data->num_group_ports = num_tdm_group_ports;
  10411. dai_data->lane_cfg = tdm_lane_cfg;
  10412. dev_set_drvdata(&pdev->dev, dai_data);
  10413. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  10414. if (port_idx < 0) {
  10415. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  10416. __func__, tdm_dev_id);
  10417. rc = -EINVAL;
  10418. goto free_dai_data;
  10419. }
  10420. rc = snd_soc_register_component(&pdev->dev,
  10421. &msm_q6_tdm_dai_component,
  10422. &msm_dai_q6_tdm_dai[port_idx], 1);
  10423. if (rc) {
  10424. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  10425. __func__, tdm_dev_id, rc);
  10426. goto err_register;
  10427. }
  10428. return 0;
  10429. err_register:
  10430. free_dai_data:
  10431. kfree(dai_data);
  10432. rtn:
  10433. return rc;
  10434. }
  10435. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  10436. {
  10437. struct msm_dai_q6_tdm_dai_data *dai_data =
  10438. dev_get_drvdata(&pdev->dev);
  10439. snd_soc_unregister_component(&pdev->dev);
  10440. kfree(dai_data);
  10441. return 0;
  10442. }
  10443. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  10444. { .compatible = "qcom,msm-dai-q6-tdm", },
  10445. {}
  10446. };
  10447. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  10448. static struct platform_driver msm_dai_q6_tdm_driver = {
  10449. .probe = msm_dai_q6_tdm_dev_probe,
  10450. .remove = msm_dai_q6_tdm_dev_remove,
  10451. .driver = {
  10452. .name = "msm-dai-q6-tdm",
  10453. .owner = THIS_MODULE,
  10454. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  10455. .suppress_bind_attrs = true,
  10456. },
  10457. };
  10458. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  10459. struct snd_ctl_elem_value *ucontrol)
  10460. {
  10461. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  10462. int value = ucontrol->value.integer.value[0];
  10463. dai_data->port_config.cdc_dma.data_format = value;
  10464. pr_debug("%s: format = %d\n", __func__, value);
  10465. return 0;
  10466. }
  10467. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  10468. struct snd_ctl_elem_value *ucontrol)
  10469. {
  10470. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  10471. ucontrol->value.integer.value[0] =
  10472. dai_data->port_config.cdc_dma.data_format;
  10473. return 0;
  10474. }
  10475. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  10476. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  10477. msm_dai_q6_cdc_dma_format_get,
  10478. msm_dai_q6_cdc_dma_format_put),
  10479. };
  10480. /* SOC probe for codec DMA interface */
  10481. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  10482. {
  10483. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  10484. int rc = 0;
  10485. if (!dai) {
  10486. pr_err("%s: Invalid params dai\n", __func__);
  10487. return -EINVAL;
  10488. }
  10489. if (!dai->dev) {
  10490. pr_err("%s: Invalid params dai dev\n", __func__);
  10491. return -EINVAL;
  10492. }
  10493. msm_dai_q6_set_dai_id(dai);
  10494. dai_data = dev_get_drvdata(dai->dev);
  10495. switch (dai->id) {
  10496. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  10497. rc = snd_ctl_add(dai->component->card->snd_card,
  10498. snd_ctl_new1(&cdc_dma_config_controls[0],
  10499. dai_data));
  10500. break;
  10501. default:
  10502. break;
  10503. }
  10504. if (rc < 0)
  10505. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  10506. __func__, dai->name);
  10507. if (dai_data->is_island_dai)
  10508. rc = msm_dai_q6_add_island_mx_ctls(
  10509. dai->component->card->snd_card,
  10510. dai->name, dai->id,
  10511. (void *)dai_data);
  10512. rc = msm_dai_q6_dai_add_route(dai);
  10513. return rc;
  10514. }
  10515. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  10516. {
  10517. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10518. dev_get_drvdata(dai->dev);
  10519. int rc = 0;
  10520. /* If AFE port is still up, close it */
  10521. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10522. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  10523. dai->id);
  10524. rc = afe_close(dai->id); /* can block */
  10525. if (rc < 0)
  10526. dev_err(dai->dev, "fail to close AFE port\n");
  10527. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  10528. }
  10529. return rc;
  10530. }
  10531. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  10532. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  10533. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  10534. {
  10535. int rc = 0;
  10536. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10537. dev_get_drvdata(dai->dev);
  10538. unsigned int ch_mask = 0, ch_num = 0;
  10539. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  10540. switch (dai->id) {
  10541. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  10542. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  10543. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  10544. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  10545. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  10546. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  10547. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  10548. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  10549. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  10550. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  10551. if (!rx_ch_mask) {
  10552. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  10553. return -EINVAL;
  10554. }
  10555. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  10556. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  10557. __func__, rx_num_ch);
  10558. return -EINVAL;
  10559. }
  10560. ch_mask = *rx_ch_mask;
  10561. ch_num = rx_num_ch;
  10562. break;
  10563. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  10564. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  10565. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  10566. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  10567. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  10568. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  10569. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  10570. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  10571. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  10572. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  10573. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  10574. if (!tx_ch_mask) {
  10575. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  10576. return -EINVAL;
  10577. }
  10578. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  10579. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  10580. __func__, tx_num_ch);
  10581. return -EINVAL;
  10582. }
  10583. ch_mask = *tx_ch_mask;
  10584. ch_num = tx_num_ch;
  10585. break;
  10586. default:
  10587. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  10588. return -EINVAL;
  10589. }
  10590. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  10591. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  10592. dai->id, ch_num, ch_mask);
  10593. return rc;
  10594. }
  10595. static int msm_dai_q6_cdc_dma_hw_params(
  10596. struct snd_pcm_substream *substream,
  10597. struct snd_pcm_hw_params *params,
  10598. struct snd_soc_dai *dai)
  10599. {
  10600. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10601. dev_get_drvdata(dai->dev);
  10602. switch (params_format(params)) {
  10603. case SNDRV_PCM_FORMAT_S16_LE:
  10604. case SNDRV_PCM_FORMAT_SPECIAL:
  10605. dai_data->port_config.cdc_dma.bit_width = 16;
  10606. break;
  10607. case SNDRV_PCM_FORMAT_S24_LE:
  10608. case SNDRV_PCM_FORMAT_S24_3LE:
  10609. dai_data->port_config.cdc_dma.bit_width = 24;
  10610. break;
  10611. case SNDRV_PCM_FORMAT_S32_LE:
  10612. dai_data->port_config.cdc_dma.bit_width = 32;
  10613. break;
  10614. default:
  10615. dev_err(dai->dev, "%s: format %d\n",
  10616. __func__, params_format(params));
  10617. return -EINVAL;
  10618. }
  10619. dai_data->rate = params_rate(params);
  10620. dai_data->channels = params_channels(params);
  10621. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  10622. AFE_API_VERSION_CODEC_DMA_CONFIG;
  10623. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  10624. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  10625. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  10626. "num_channel %hu sample_rate %d\n", __func__,
  10627. dai_data->port_config.cdc_dma.bit_width,
  10628. dai_data->port_config.cdc_dma.data_format,
  10629. dai_data->port_config.cdc_dma.num_channels,
  10630. dai_data->rate);
  10631. return 0;
  10632. }
  10633. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  10634. struct snd_soc_dai *dai)
  10635. {
  10636. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10637. dev_get_drvdata(dai->dev);
  10638. int rc = 0;
  10639. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10640. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  10641. (dai_data->port_config.cdc_dma.data_format == 1))
  10642. dai_data->port_config.cdc_dma.data_format =
  10643. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  10644. rc = afe_port_start(dai->id, &dai_data->port_config,
  10645. dai_data->rate);
  10646. if (rc < 0)
  10647. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  10648. dai->id);
  10649. else
  10650. set_bit(STATUS_PORT_STARTED,
  10651. dai_data->status_mask);
  10652. }
  10653. return rc;
  10654. }
  10655. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  10656. struct snd_soc_dai *dai)
  10657. {
  10658. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  10659. int rc = 0;
  10660. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10661. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  10662. dai->id);
  10663. rc = afe_close(dai->id); /* can block */
  10664. if (rc < 0)
  10665. dev_err(dai->dev, "fail to close AFE port\n");
  10666. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  10667. *dai_data->status_mask);
  10668. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  10669. }
  10670. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  10671. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  10672. }
  10673. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  10674. .prepare = msm_dai_q6_cdc_dma_prepare,
  10675. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  10676. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  10677. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  10678. };
  10679. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  10680. .prepare = msm_dai_q6_cdc_dma_prepare,
  10681. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  10682. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  10683. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  10684. .digital_mute = msm_dai_q6_spk_digital_mute,
  10685. };
  10686. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  10687. {
  10688. .playback = {
  10689. .stream_name = "WSA CDC DMA0 Playback",
  10690. .aif_name = "WSA_CDC_DMA_RX_0",
  10691. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10692. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10693. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10694. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10695. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10696. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10697. SNDRV_PCM_RATE_384000,
  10698. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10699. SNDRV_PCM_FMTBIT_S24_LE |
  10700. SNDRV_PCM_FMTBIT_S24_3LE |
  10701. SNDRV_PCM_FMTBIT_S32_LE,
  10702. .channels_min = 1,
  10703. .channels_max = 4,
  10704. .rate_min = 8000,
  10705. .rate_max = 384000,
  10706. },
  10707. .name = "WSA_CDC_DMA_RX_0",
  10708. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  10709. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  10710. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10711. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10712. },
  10713. {
  10714. .capture = {
  10715. .stream_name = "WSA CDC DMA0 Capture",
  10716. .aif_name = "WSA_CDC_DMA_TX_0",
  10717. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10718. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10719. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10720. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10721. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10722. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10723. SNDRV_PCM_RATE_384000,
  10724. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10725. SNDRV_PCM_FMTBIT_S24_LE |
  10726. SNDRV_PCM_FMTBIT_S24_3LE |
  10727. SNDRV_PCM_FMTBIT_S32_LE,
  10728. .channels_min = 1,
  10729. .channels_max = 4,
  10730. .rate_min = 8000,
  10731. .rate_max = 384000,
  10732. },
  10733. .name = "WSA_CDC_DMA_TX_0",
  10734. .ops = &msm_dai_q6_cdc_dma_ops,
  10735. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  10736. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10737. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10738. },
  10739. {
  10740. .playback = {
  10741. .stream_name = "WSA CDC DMA1 Playback",
  10742. .aif_name = "WSA_CDC_DMA_RX_1",
  10743. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10744. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10745. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10746. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10747. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10748. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10749. SNDRV_PCM_RATE_384000,
  10750. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10751. SNDRV_PCM_FMTBIT_S24_LE |
  10752. SNDRV_PCM_FMTBIT_S24_3LE |
  10753. SNDRV_PCM_FMTBIT_S32_LE,
  10754. .channels_min = 1,
  10755. .channels_max = 2,
  10756. .rate_min = 8000,
  10757. .rate_max = 384000,
  10758. },
  10759. .name = "WSA_CDC_DMA_RX_1",
  10760. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  10761. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  10762. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10763. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10764. },
  10765. {
  10766. .capture = {
  10767. .stream_name = "WSA CDC DMA1 Capture",
  10768. .aif_name = "WSA_CDC_DMA_TX_1",
  10769. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10770. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10771. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10772. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10773. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10774. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10775. SNDRV_PCM_RATE_384000,
  10776. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10777. SNDRV_PCM_FMTBIT_S24_LE |
  10778. SNDRV_PCM_FMTBIT_S24_3LE |
  10779. SNDRV_PCM_FMTBIT_S32_LE,
  10780. .channels_min = 1,
  10781. .channels_max = 2,
  10782. .rate_min = 8000,
  10783. .rate_max = 384000,
  10784. },
  10785. .name = "WSA_CDC_DMA_TX_1",
  10786. .ops = &msm_dai_q6_cdc_dma_ops,
  10787. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  10788. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10789. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10790. },
  10791. {
  10792. .capture = {
  10793. .stream_name = "WSA CDC DMA2 Capture",
  10794. .aif_name = "WSA_CDC_DMA_TX_2",
  10795. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10796. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10797. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10798. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10799. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10800. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10801. SNDRV_PCM_RATE_384000,
  10802. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10803. SNDRV_PCM_FMTBIT_S24_LE |
  10804. SNDRV_PCM_FMTBIT_S24_3LE |
  10805. SNDRV_PCM_FMTBIT_S32_LE,
  10806. .channels_min = 1,
  10807. .channels_max = 1,
  10808. .rate_min = 8000,
  10809. .rate_max = 384000,
  10810. },
  10811. .name = "WSA_CDC_DMA_TX_2",
  10812. .ops = &msm_dai_q6_cdc_dma_ops,
  10813. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  10814. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10815. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10816. },
  10817. {
  10818. .capture = {
  10819. .stream_name = "VA CDC DMA0 Capture",
  10820. .aif_name = "VA_CDC_DMA_TX_0",
  10821. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10822. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10823. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10824. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10825. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10826. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10827. SNDRV_PCM_RATE_384000,
  10828. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10829. SNDRV_PCM_FMTBIT_S24_LE |
  10830. SNDRV_PCM_FMTBIT_S24_3LE,
  10831. .channels_min = 1,
  10832. .channels_max = 8,
  10833. .rate_min = 8000,
  10834. .rate_max = 384000,
  10835. },
  10836. .name = "VA_CDC_DMA_TX_0",
  10837. .ops = &msm_dai_q6_cdc_dma_ops,
  10838. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  10839. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10840. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10841. },
  10842. {
  10843. .capture = {
  10844. .stream_name = "VA CDC DMA1 Capture",
  10845. .aif_name = "VA_CDC_DMA_TX_1",
  10846. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10847. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10848. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10849. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10850. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10851. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10852. SNDRV_PCM_RATE_384000,
  10853. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10854. SNDRV_PCM_FMTBIT_S24_LE |
  10855. SNDRV_PCM_FMTBIT_S24_3LE,
  10856. .channels_min = 1,
  10857. .channels_max = 8,
  10858. .rate_min = 8000,
  10859. .rate_max = 384000,
  10860. },
  10861. .name = "VA_CDC_DMA_TX_1",
  10862. .ops = &msm_dai_q6_cdc_dma_ops,
  10863. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  10864. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10865. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10866. },
  10867. {
  10868. .capture = {
  10869. .stream_name = "VA CDC DMA2 Capture",
  10870. .aif_name = "VA_CDC_DMA_TX_2",
  10871. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10872. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10873. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10874. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10875. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10876. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10877. SNDRV_PCM_RATE_384000,
  10878. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10879. SNDRV_PCM_FMTBIT_S24_LE |
  10880. SNDRV_PCM_FMTBIT_S24_3LE,
  10881. .channels_min = 1,
  10882. .channels_max = 8,
  10883. .rate_min = 8000,
  10884. .rate_max = 384000,
  10885. },
  10886. .name = "VA_CDC_DMA_TX_2",
  10887. .ops = &msm_dai_q6_cdc_dma_ops,
  10888. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  10889. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10890. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10891. },
  10892. {
  10893. .playback = {
  10894. .stream_name = "RX CDC DMA0 Playback",
  10895. .aif_name = "RX_CDC_DMA_RX_0",
  10896. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10897. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10898. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10899. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10900. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10901. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10902. SNDRV_PCM_RATE_384000,
  10903. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10904. SNDRV_PCM_FMTBIT_S24_LE |
  10905. SNDRV_PCM_FMTBIT_S24_3LE |
  10906. SNDRV_PCM_FMTBIT_S32_LE,
  10907. .channels_min = 1,
  10908. .channels_max = 2,
  10909. .rate_min = 8000,
  10910. .rate_max = 384000,
  10911. },
  10912. .ops = &msm_dai_q6_cdc_dma_ops,
  10913. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  10914. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10915. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10916. },
  10917. {
  10918. .capture = {
  10919. .stream_name = "TX CDC DMA0 Capture",
  10920. .aif_name = "TX_CDC_DMA_TX_0",
  10921. .rates = SNDRV_PCM_RATE_8000 |
  10922. SNDRV_PCM_RATE_16000 |
  10923. SNDRV_PCM_RATE_32000 |
  10924. SNDRV_PCM_RATE_48000 |
  10925. SNDRV_PCM_RATE_96000 |
  10926. SNDRV_PCM_RATE_192000 |
  10927. SNDRV_PCM_RATE_384000,
  10928. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10929. SNDRV_PCM_FMTBIT_S24_LE |
  10930. SNDRV_PCM_FMTBIT_S24_3LE |
  10931. SNDRV_PCM_FMTBIT_S32_LE,
  10932. .channels_min = 1,
  10933. .channels_max = 3,
  10934. .rate_min = 8000,
  10935. .rate_max = 384000,
  10936. },
  10937. .ops = &msm_dai_q6_cdc_dma_ops,
  10938. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  10939. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10940. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10941. },
  10942. {
  10943. .playback = {
  10944. .stream_name = "RX CDC DMA1 Playback",
  10945. .aif_name = "RX_CDC_DMA_RX_1",
  10946. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10947. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10948. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10949. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10950. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10951. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10952. SNDRV_PCM_RATE_384000,
  10953. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10954. SNDRV_PCM_FMTBIT_S24_LE |
  10955. SNDRV_PCM_FMTBIT_S24_3LE |
  10956. SNDRV_PCM_FMTBIT_S32_LE,
  10957. .channels_min = 1,
  10958. .channels_max = 2,
  10959. .rate_min = 8000,
  10960. .rate_max = 384000,
  10961. },
  10962. .ops = &msm_dai_q6_cdc_dma_ops,
  10963. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  10964. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10965. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10966. },
  10967. {
  10968. .capture = {
  10969. .stream_name = "TX CDC DMA1 Capture",
  10970. .aif_name = "TX_CDC_DMA_TX_1",
  10971. .rates = SNDRV_PCM_RATE_8000 |
  10972. SNDRV_PCM_RATE_16000 |
  10973. SNDRV_PCM_RATE_32000 |
  10974. SNDRV_PCM_RATE_48000 |
  10975. SNDRV_PCM_RATE_96000 |
  10976. SNDRV_PCM_RATE_192000 |
  10977. SNDRV_PCM_RATE_384000,
  10978. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10979. SNDRV_PCM_FMTBIT_S24_LE |
  10980. SNDRV_PCM_FMTBIT_S24_3LE |
  10981. SNDRV_PCM_FMTBIT_S32_LE,
  10982. .channels_min = 1,
  10983. .channels_max = 3,
  10984. .rate_min = 8000,
  10985. .rate_max = 384000,
  10986. },
  10987. .ops = &msm_dai_q6_cdc_dma_ops,
  10988. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  10989. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10990. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10991. },
  10992. {
  10993. .playback = {
  10994. .stream_name = "RX CDC DMA2 Playback",
  10995. .aif_name = "RX_CDC_DMA_RX_2",
  10996. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10997. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10998. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10999. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11000. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11001. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11002. SNDRV_PCM_RATE_384000,
  11003. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11004. SNDRV_PCM_FMTBIT_S24_LE |
  11005. SNDRV_PCM_FMTBIT_S24_3LE |
  11006. SNDRV_PCM_FMTBIT_S32_LE,
  11007. .channels_min = 1,
  11008. .channels_max = 1,
  11009. .rate_min = 8000,
  11010. .rate_max = 384000,
  11011. },
  11012. .ops = &msm_dai_q6_cdc_dma_ops,
  11013. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  11014. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11015. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11016. },
  11017. {
  11018. .capture = {
  11019. .stream_name = "TX CDC DMA2 Capture",
  11020. .aif_name = "TX_CDC_DMA_TX_2",
  11021. .rates = SNDRV_PCM_RATE_8000 |
  11022. SNDRV_PCM_RATE_16000 |
  11023. SNDRV_PCM_RATE_32000 |
  11024. SNDRV_PCM_RATE_48000 |
  11025. SNDRV_PCM_RATE_96000 |
  11026. SNDRV_PCM_RATE_192000 |
  11027. SNDRV_PCM_RATE_384000,
  11028. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11029. SNDRV_PCM_FMTBIT_S24_LE |
  11030. SNDRV_PCM_FMTBIT_S24_3LE |
  11031. SNDRV_PCM_FMTBIT_S32_LE,
  11032. .channels_min = 1,
  11033. .channels_max = 4,
  11034. .rate_min = 8000,
  11035. .rate_max = 384000,
  11036. },
  11037. .ops = &msm_dai_q6_cdc_dma_ops,
  11038. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  11039. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11040. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11041. }, {
  11042. .playback = {
  11043. .stream_name = "RX CDC DMA3 Playback",
  11044. .aif_name = "RX_CDC_DMA_RX_3",
  11045. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11046. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11047. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11048. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11049. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11050. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11051. SNDRV_PCM_RATE_384000,
  11052. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11053. SNDRV_PCM_FMTBIT_S24_LE |
  11054. SNDRV_PCM_FMTBIT_S24_3LE |
  11055. SNDRV_PCM_FMTBIT_S32_LE,
  11056. .channels_min = 1,
  11057. .channels_max = 1,
  11058. .rate_min = 8000,
  11059. .rate_max = 384000,
  11060. },
  11061. .ops = &msm_dai_q6_cdc_dma_ops,
  11062. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  11063. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11064. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11065. },
  11066. {
  11067. .capture = {
  11068. .stream_name = "TX CDC DMA3 Capture",
  11069. .aif_name = "TX_CDC_DMA_TX_3",
  11070. .rates = SNDRV_PCM_RATE_8000 |
  11071. SNDRV_PCM_RATE_16000 |
  11072. SNDRV_PCM_RATE_32000 |
  11073. SNDRV_PCM_RATE_48000 |
  11074. SNDRV_PCM_RATE_96000 |
  11075. SNDRV_PCM_RATE_192000 |
  11076. SNDRV_PCM_RATE_384000,
  11077. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11078. SNDRV_PCM_FMTBIT_S24_LE |
  11079. SNDRV_PCM_FMTBIT_S24_3LE |
  11080. SNDRV_PCM_FMTBIT_S32_LE,
  11081. .channels_min = 1,
  11082. .channels_max = 8,
  11083. .rate_min = 8000,
  11084. .rate_max = 384000,
  11085. },
  11086. .ops = &msm_dai_q6_cdc_dma_ops,
  11087. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  11088. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11089. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11090. },
  11091. {
  11092. .playback = {
  11093. .stream_name = "RX CDC DMA4 Playback",
  11094. .aif_name = "RX_CDC_DMA_RX_4",
  11095. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11096. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11097. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11098. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11099. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11100. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11101. SNDRV_PCM_RATE_384000,
  11102. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11103. SNDRV_PCM_FMTBIT_S24_LE |
  11104. SNDRV_PCM_FMTBIT_S24_3LE |
  11105. SNDRV_PCM_FMTBIT_S32_LE,
  11106. .channels_min = 1,
  11107. .channels_max = 6,
  11108. .rate_min = 8000,
  11109. .rate_max = 384000,
  11110. },
  11111. .ops = &msm_dai_q6_cdc_dma_ops,
  11112. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  11113. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11114. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11115. },
  11116. {
  11117. .capture = {
  11118. .stream_name = "TX CDC DMA4 Capture",
  11119. .aif_name = "TX_CDC_DMA_TX_4",
  11120. .rates = SNDRV_PCM_RATE_8000 |
  11121. SNDRV_PCM_RATE_16000 |
  11122. SNDRV_PCM_RATE_32000 |
  11123. SNDRV_PCM_RATE_48000 |
  11124. SNDRV_PCM_RATE_96000 |
  11125. SNDRV_PCM_RATE_192000 |
  11126. SNDRV_PCM_RATE_384000,
  11127. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11128. SNDRV_PCM_FMTBIT_S24_LE |
  11129. SNDRV_PCM_FMTBIT_S24_3LE |
  11130. SNDRV_PCM_FMTBIT_S32_LE,
  11131. .channels_min = 1,
  11132. .channels_max = 8,
  11133. .rate_min = 8000,
  11134. .rate_max = 384000,
  11135. },
  11136. .ops = &msm_dai_q6_cdc_dma_ops,
  11137. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  11138. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11139. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11140. },
  11141. {
  11142. .playback = {
  11143. .stream_name = "RX CDC DMA5 Playback",
  11144. .aif_name = "RX_CDC_DMA_RX_5",
  11145. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11146. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11147. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11148. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11149. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11150. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11151. SNDRV_PCM_RATE_384000,
  11152. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11153. SNDRV_PCM_FMTBIT_S24_LE |
  11154. SNDRV_PCM_FMTBIT_S24_3LE |
  11155. SNDRV_PCM_FMTBIT_S32_LE,
  11156. .channels_min = 1,
  11157. .channels_max = 1,
  11158. .rate_min = 8000,
  11159. .rate_max = 384000,
  11160. },
  11161. .ops = &msm_dai_q6_cdc_dma_ops,
  11162. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  11163. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11164. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11165. },
  11166. {
  11167. .capture = {
  11168. .stream_name = "TX CDC DMA5 Capture",
  11169. .aif_name = "TX_CDC_DMA_TX_5",
  11170. .rates = SNDRV_PCM_RATE_8000 |
  11171. SNDRV_PCM_RATE_16000 |
  11172. SNDRV_PCM_RATE_32000 |
  11173. SNDRV_PCM_RATE_48000 |
  11174. SNDRV_PCM_RATE_96000 |
  11175. SNDRV_PCM_RATE_192000 |
  11176. SNDRV_PCM_RATE_384000,
  11177. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11178. SNDRV_PCM_FMTBIT_S24_LE |
  11179. SNDRV_PCM_FMTBIT_S24_3LE |
  11180. SNDRV_PCM_FMTBIT_S32_LE,
  11181. .channels_min = 1,
  11182. .channels_max = 4,
  11183. .rate_min = 8000,
  11184. .rate_max = 384000,
  11185. },
  11186. .ops = &msm_dai_q6_cdc_dma_ops,
  11187. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  11188. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11189. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11190. },
  11191. {
  11192. .playback = {
  11193. .stream_name = "RX CDC DMA6 Playback",
  11194. .aif_name = "RX_CDC_DMA_RX_6",
  11195. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11196. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11197. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11198. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11199. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11200. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11201. SNDRV_PCM_RATE_384000,
  11202. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11203. SNDRV_PCM_FMTBIT_S24_LE |
  11204. SNDRV_PCM_FMTBIT_S24_3LE |
  11205. SNDRV_PCM_FMTBIT_S32_LE,
  11206. .channels_min = 1,
  11207. .channels_max = 4,
  11208. .rate_min = 8000,
  11209. .rate_max = 384000,
  11210. },
  11211. .ops = &msm_dai_q6_cdc_dma_ops,
  11212. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  11213. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11214. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11215. },
  11216. {
  11217. .playback = {
  11218. .stream_name = "RX CDC DMA7 Playback",
  11219. .aif_name = "RX_CDC_DMA_RX_7",
  11220. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11221. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11222. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11223. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11224. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11225. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11226. SNDRV_PCM_RATE_384000,
  11227. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11228. SNDRV_PCM_FMTBIT_S24_LE |
  11229. SNDRV_PCM_FMTBIT_S24_3LE |
  11230. SNDRV_PCM_FMTBIT_S32_LE,
  11231. .channels_min = 1,
  11232. .channels_max = 2,
  11233. .rate_min = 8000,
  11234. .rate_max = 384000,
  11235. },
  11236. .ops = &msm_dai_q6_cdc_dma_ops,
  11237. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  11238. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11239. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11240. },
  11241. };
  11242. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  11243. .name = "msm-dai-cdc-dma-dev",
  11244. };
  11245. /* DT related probe for each codec DMA interface device */
  11246. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  11247. {
  11248. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  11249. u32 cdc_dma_id = 0;
  11250. int i;
  11251. int rc = 0;
  11252. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11253. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  11254. &cdc_dma_id);
  11255. if (rc) {
  11256. dev_err(&pdev->dev,
  11257. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  11258. return rc;
  11259. }
  11260. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  11261. dev_name(&pdev->dev), cdc_dma_id);
  11262. pdev->id = cdc_dma_id;
  11263. dai_data = devm_kzalloc(&pdev->dev,
  11264. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  11265. GFP_KERNEL);
  11266. if (!dai_data)
  11267. return -ENOMEM;
  11268. rc = of_property_read_u32(pdev->dev.of_node,
  11269. "qcom,msm-dai-is-island-supported",
  11270. &dai_data->is_island_dai);
  11271. if (rc)
  11272. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11273. dev_set_drvdata(&pdev->dev, dai_data);
  11274. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  11275. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  11276. return snd_soc_register_component(&pdev->dev,
  11277. &msm_q6_cdc_dma_dai_component,
  11278. &msm_dai_q6_cdc_dma_dai[i], 1);
  11279. }
  11280. }
  11281. return -ENODEV;
  11282. }
  11283. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  11284. {
  11285. snd_soc_unregister_component(&pdev->dev);
  11286. return 0;
  11287. }
  11288. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  11289. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  11290. { }
  11291. };
  11292. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  11293. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  11294. .probe = msm_dai_q6_cdc_dma_dev_probe,
  11295. .remove = msm_dai_q6_cdc_dma_dev_remove,
  11296. .driver = {
  11297. .name = "msm-dai-cdc-dma-dev",
  11298. .owner = THIS_MODULE,
  11299. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  11300. .suppress_bind_attrs = true,
  11301. },
  11302. };
  11303. /* DT related probe for codec DMA interface device group */
  11304. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  11305. {
  11306. int rc;
  11307. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  11308. if (rc) {
  11309. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  11310. __func__, rc);
  11311. } else
  11312. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  11313. return rc;
  11314. }
  11315. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  11316. {
  11317. of_platform_depopulate(&pdev->dev);
  11318. return 0;
  11319. }
  11320. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  11321. { .compatible = "qcom,msm-dai-cdc-dma", },
  11322. { }
  11323. };
  11324. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  11325. static struct platform_driver msm_dai_cdc_dma_q6 = {
  11326. .probe = msm_dai_cdc_dma_q6_probe,
  11327. .remove = msm_dai_cdc_dma_q6_remove,
  11328. .driver = {
  11329. .name = "msm-dai-cdc-dma",
  11330. .owner = THIS_MODULE,
  11331. .of_match_table = msm_dai_cdc_dma_dt_match,
  11332. .suppress_bind_attrs = true,
  11333. },
  11334. };
  11335. int __init msm_dai_q6_init(void)
  11336. {
  11337. int rc;
  11338. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  11339. if (rc) {
  11340. pr_err("%s: fail to register auxpcm dev driver", __func__);
  11341. goto fail;
  11342. }
  11343. rc = platform_driver_register(&msm_dai_q6);
  11344. if (rc) {
  11345. pr_err("%s: fail to register dai q6 driver", __func__);
  11346. goto dai_q6_fail;
  11347. }
  11348. rc = platform_driver_register(&msm_dai_q6_dev);
  11349. if (rc) {
  11350. pr_err("%s: fail to register dai q6 dev driver", __func__);
  11351. goto dai_q6_dev_fail;
  11352. }
  11353. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  11354. if (rc) {
  11355. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  11356. goto dai_q6_mi2s_drv_fail;
  11357. }
  11358. rc = platform_driver_register(&msm_dai_mi2s_q6);
  11359. if (rc) {
  11360. pr_err("%s: fail to register dai MI2S\n", __func__);
  11361. goto dai_mi2s_q6_fail;
  11362. }
  11363. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  11364. if (rc) {
  11365. pr_err("%s: fail to register dai SPDIF\n", __func__);
  11366. goto dai_spdif_q6_fail;
  11367. }
  11368. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  11369. if (rc) {
  11370. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  11371. goto dai_q6_tdm_drv_fail;
  11372. }
  11373. rc = platform_driver_register(&msm_dai_tdm_q6);
  11374. if (rc) {
  11375. pr_err("%s: fail to register dai TDM\n", __func__);
  11376. goto dai_tdm_q6_fail;
  11377. }
  11378. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  11379. if (rc) {
  11380. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  11381. goto dai_cdc_dma_q6_dev_fail;
  11382. }
  11383. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  11384. if (rc) {
  11385. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  11386. goto dai_cdc_dma_q6_fail;
  11387. }
  11388. return rc;
  11389. dai_cdc_dma_q6_fail:
  11390. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  11391. dai_cdc_dma_q6_dev_fail:
  11392. platform_driver_unregister(&msm_dai_tdm_q6);
  11393. dai_tdm_q6_fail:
  11394. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  11395. dai_q6_tdm_drv_fail:
  11396. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  11397. dai_spdif_q6_fail:
  11398. platform_driver_unregister(&msm_dai_mi2s_q6);
  11399. dai_mi2s_q6_fail:
  11400. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  11401. dai_q6_mi2s_drv_fail:
  11402. platform_driver_unregister(&msm_dai_q6_dev);
  11403. dai_q6_dev_fail:
  11404. platform_driver_unregister(&msm_dai_q6);
  11405. dai_q6_fail:
  11406. platform_driver_unregister(&msm_auxpcm_dev_driver);
  11407. fail:
  11408. return rc;
  11409. }
  11410. void msm_dai_q6_exit(void)
  11411. {
  11412. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  11413. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  11414. platform_driver_unregister(&msm_dai_tdm_q6);
  11415. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  11416. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  11417. platform_driver_unregister(&msm_dai_mi2s_q6);
  11418. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  11419. platform_driver_unregister(&msm_dai_q6_dev);
  11420. platform_driver_unregister(&msm_dai_q6);
  11421. platform_driver_unregister(&msm_auxpcm_dev_driver);
  11422. }
  11423. /* Module information */
  11424. MODULE_DESCRIPTION("MSM DSP DAI driver");
  11425. MODULE_LICENSE("GPL v2");