msm-dai-q6-v2.c 390 KB

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